Essential C++ Data Structures for Competitive Programming

Sujal Choudhari,C++data structurescompetitive programming

What is C++ STL?

A standout feature of C++ is the Standard Template Library (STL), setting it apart from other programming languages. STL offers a collection of pre-defined templates, including containers, algorithms, and iterators, simplifying the implementation of various data structures without writing everything from scratch.

Containers and Functions in C++ STL

1. unordered_set

An unordered_set is a container that stores unique elements in no particular order. It allows fast retrieval of individual elements based on their value. Common functions include:

2. vector

A vector is a dynamic array that can resize itself automatically when an element is added or removed. It provides random access to elements. Common functions include:

3. set

A set is a container that stores unique elements in a specific order. Elements are automatically sorted. Common functions include:

4. unordered_multiset

An unordered_multiset is similar to an unordered_set, but it allows duplicate elements. Common functions include:

5. multiset

A multiset is like a set, but it allows duplicate elements, and they are stored in a sorted order. Common functions include:

6. unordered_map

An unordered_map is a key-value pair container where keys are unique, but the order of elements is not maintained. Common functions include:

7. map

A map is an associative container that stores elements in key-value pairs with unique keys. Elements are stored in sorted order based on the key. Common functions include:

8. unordered_multimap

An unordered_multimap is similar to an unordered_map, but it allows multiple pairs with the same key. Common functions include:

9. queue

A queue is a First-In-First-Out (FIFO) data structure that allows insertion at the back and removal from the front. Common functions include:

10. stack

A stack is a Last-In-First-Out (LIFO) data structure that allows insertion and removal of elements at the top of the stack. Common functions include:

11. deque

A deque (double-ended queue) is a container that allows insertion and deletion of elements from both the front and the back. Common functions include:

12. priority_queue

A priority_queue is a type of queue where each element has a priority. Elements with higher priority are served before elements with lower priority, regardless of their order in the queue. Common functions include:

13. multimap

A multimap is similar to a map, but it allows multiple values for the same key. Elements are stored in sorted order based on the key. Common functions include:

This is my prespective, not the official one. Refer official documents for more information

MIT © Sujal Choudhari.