Book Image

C++ Data Structures and Algorithm Design Principles

By : John Carey, Anil Achary, Shreyans Doshi, Payas Rajan
Book Image

C++ Data Structures and Algorithm Design Principles

By: John Carey, Anil Achary, Shreyans Doshi, Payas Rajan

Overview of this book

C++ is a mature multi-paradigm programming language that enables you to write high-level code with a high degree of control over the hardware. Today, significant parts of software infrastructure, including databases, browsers, multimedia frameworks, and GUI toolkits, are written in C++. This book starts by introducing C++ data structures and how to store data using linked lists, arrays, stacks, and queues. In later chapters, the book explains the basic algorithm design paradigms, such as the greedy approach and the divide-and-conquer approach, which are used to solve a large variety of computational problems. Finally, you will learn the advanced technique of dynamic programming to develop optimized implementations of several algorithms discussed in the book. By the end of this book, you will have learned how to implement standard data structures and algorithms in efficient and scalable C++ 14 code.
Table of Contents (11 chapters)

Activity 21: Melodic Permutations

Note

This activity is based around the traditional Western 8-note equal temperament scale, although students do not need to know anything about music theory to perform this activity. All the necessary information about the musical aspect is provided here.

Musical set theory is a form of categorization for musical harmonies and melodies according to the intervallic relations of their notes. In musical terminology, an interval can be defined as the distance between two notes in terms of their relative positions when written in musical notation:

Figure 8.19: Musical notations
Figure 8.19: Musical notations

The following figure demonstrates the distance between different musical notes when represented as musical notations:

Figure 8.20: Musical intervals
Figure 8.20: Musical intervals

You are a music theorist who is curious about how many times a permutation of a particular note set appears within the melodies of various composers. Given the notes of a complete melody and a set of notes...