set and map in STL are similar in the sense that they both use Red Black Tree (A self balancing BST). Note that the time complexities of search, insert and delete are O(Log n).
Differences:
The difference is set is used to store only keys while map is used to store key value pairs. For example consider in the problem of printing sorted distinct elements, we use set as there is value needed for a key. While if we change the problem to print frequencies of distinct sorted elements, we use map. We need map to store array values as key and frequencies as value.
Map in STL is used to hash key and value. We generally see map being used for standard data types. We can also use map for pairs.
Thanks for watching this video. If you like this video, please like, comment, share and do subscribe.
For any query : [email protected]