Book Image

The Modern C++ Challenger

By : Brent Arnold, Kristian Secor
Book Image

The Modern C++ Challenger

By: Brent Arnold, Kristian Secor

Overview of this book

C++ is one of the most widely-used programming languages and has applications in a variety of fields, such as gaming, GUI programming, and operating systems, to name a few. Through the years, C++ has evolved into one of the top choices for software developers worldwide. You’ll begin your challenge with various math problems, including Armstrong numbers. As you progress through the course, the complexity of the challenges will increase. You’ll write a class template that represents a two-dimensional array container. You’ll also write a program to find files in a directory that match a regular expression. While tackling algorithms and data structures, you’ll create buffers and print histograms. Things will get tougher when you’ll write code to implement a general-purpose parallel algorithm using asynchronous functions. Whether it is creating an EAN-13 barcode generator or encrypting and decrypting files, this course will put your skills to test and in turn teach you several new features of C++.
Table of Contents (10 chapters)
Chapter 4
Algorithms and Data Structures
Content Locked
Section 2
Level 4 - Problem 1
Write a data structure that represents a priority queue that provides constant time lookup for the largest element, but has logarithmic time complexity for adding and removing elements. A queue inserts new elements at the end and removes elements from the top. By default, the queue should use operator< to compare elements, but it should be possible for the user to provide a comparison function object that returns true if the first argument is less than the second. The implementation must provide at least the following operations: - push() to add a new element - pop() to remove the top element - top() to provide access to the top element - size() to indicate the number of elements in the queue - empty() to indicate whether the queue is empty