#### 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.
Free Chapter
1. Lists, Stacks, and Queues
2. Trees, Heaps, and Graphs
3. Hash Tables and Bloom Filters
4. Divide and Conquer
5. Greedy Algorithms
6. Graph Algorithms I
7. Graph Algorithms II
8. Dynamic Programming I
9. Dynamic Programming II

## Reconsidering the Subset Sum Problem

In the previous chapter, we discussed the subset sum problem, which we saw possessed exponential complexity in the worst cases. Let's consider the two ways this problem can be expressed – in terms of the relative difficulty of finding a solution and verifying the validity of a solution.

Let's consider the problem of verifying the validity of a solution:

Set    —> { 2 6 4 15 3 9 }

Target —> 24

Subset —> { 2 6 4 }

Sum = 2 + 6 + 4 = 12

FALSE

Subset —> { 2 6 15 3 }

Sum = 2 + 6 + 15 + 3 = 24

TRUE

Subset —> { 15 9 }

Sum = 15 + 9 = 24

TRUE

Subset —> { 6 4 3 9 }

Sum = 6 ...