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)

Revisiting the Shortest Path Problem

We previously discussed several ways to find the shortest path between two nodes in a graph. We began by exploring the most standard forms of graph traversal, namely depth-first search and breadth-first search, and eventually discussed how to approach the more problematic case of graphs containing weighted edges. We demonstrated how Dijkstra's algorithm could be used to efficiently find the shortest distances in weighted graphs by greedily prioritizing each step in the traversal according to the best option immediately available. However, despite the improvement in performance that Dijkstra's algorithm provides, it is not applicable to every situation.

Consider a Wi-Fi signal that is being broadcast through a network; as it travels beyond the point at which it is originally transmitted, its strength is likely to be affected by numerous factors, such as the distance it travels and the number of walls and other obstacles it must pass through. If...