Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Modern C++ Challenge

You're reading from   The Modern C++ Challenge Become an expert programmer by solving real-world problems

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788993869
Length 328 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Marius Bancila Marius Bancila
Author Profile Icon Marius Bancila
Marius Bancila
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Math Problems FREE CHAPTER 2. Language Features 3. Strings and Regular Expressions 4. Streams and Filesystems 5. Date and Time 6. Algorithms and Data Structures 7. Concurrency 8. Design Patterns 9. Data Serialization 10. Archives, Images, and Databases 11. Cryptography 12. Networking and Services 13. Bibliography 14. Other Books You May Enjoy

Problems

45. Priority queue

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime