CS253: Software Development with C++

Fall 2019

IQ 12

CS253 IQ 12

Show Main.IQ12 as a slide show.

Which has O(1) amortized insertion at the end?

  1. array
  2. cache
  3. set
  4. string
  5. unordered_map

In which does 12 always appear before 34?

  1. deque<int>
  2. list<int>
  3. set<int>
  4. unordered_set<int>
  5. vector<int>

A set<int> is sorted by numeric value.

Which uses std::pair?

  1. array
  2. deque
  3. multimap
  4. string
  5. unordered_set

map and multimap have key,value pairs.

Which is correct?

  1. pair<int,double> p = {1,2.3}; cout << p[1];
  2. pair<int,double> p = {1,2.3}; cout << p<double>;
  3. pair<int,double> p = {1,2.3}; cout << p.double;
  4. pair<int,double> p = {1,2.3}; cout << p<second>;
  5. pair<int,double> p = {1,2.3}; cout << p.second;

E

Which is a valid λ-function declaration?

  1. auto lf = [](int n) -> int { return n*n; };
  2. auto lf = [](int n) { return n*n; };
  3. auto lf = [](int n) { return n*n; }
  4. auto lf = [](int n) { return n*n };

  1. 1
  2. 1 and 2
  3. 1, 2, and 3
  4. 1, 2, 3, and 4
  5. 2, 3, and 4

B: 1 & 2 are the same. 3 & 4 are missing semicolons.