Skills101
← All practice quizzes

Quiz: STL Containers

5 questionsNo time limitPass: 60%+10 XP on first pass

The containers every C++ programmer uses daily, with their costs: vector, pair, map and set, unordered_map, stack, queue, deque and priority_queue — with runnable examples.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    Which container keeps keys in sorted order?

  2. Question 2

    What does this print?

    #include <iostream>
    #include <set>
    using namespace std;
    int main() {
        set<int> s = {3, 1, 3, 2, 1};
        cout << s.size();
        return 0;
    }
    
  3. Question 3

    By default, priority_queue<int> gives the:

  4. Question 4

    What is the average time to find a key in unordered_map?

  5. Question 5

    What does this print?

    #include <iostream>
    #include <map>
    using namespace std;
    int main() {
        map<string, int> m;
        int x = m["missing"];
        cout << x << " " << m.size();
        return 0;
    }