CS253: Software Development with C++

Spring 2020

IQ 15

CS253 IQ 15

Show Main.IQ15 as a slide show.

set<int> default second template argument

  1. operator<
  2. less
  3. less<int>
  4. less<int>()
  5. There isn’t one.

C: it must be a type, a comparison functor, not an object.

bind

What’s the easiest way to create a variable pointing to the function beta, which calls the two-argument function alpha, but with the arguments swapped?

  1. bind(beta, alpha, 2, 1);
  2. auto beta = bind(alpha, 2, 1);
  3. auto beta = bind(alpha, _2, _1);
  4. A lambda function would be shorter.
  5. int beta(int a, int b) { return alpha(b,a); }

C: _1 means the first argument, _2 the second argument, …

What is the period of minstd_rand?

  1. 232
  2. 232−1
  3. 231
  4. 231−1
  5. 231−2
  6. I don’t know what “period” means. ☹

The word “period” means how many values it returns before it repeats.
E: x = x * 48271 % 2147483647 // always positive, never zero

Random Numbers

mt19937 is deterministic—given the same seed, it will produce the same sequence of numbers each time.

  1. yes
  2. no
  3. depends on the implementation
  4. mt19937 is not a generator.

A: All generators are deterministic, perhaps except for random_device.

Where is the final exam?

  1. CSB 110
  2. Chem A 103
  3. The White House
  4. Castle Doom, Latveria
  5. None of the above

E: We’re livin’ la vida virtual, so take it where you like, but CSU won’t let you into the first two places, and, of the next two, one is occupied by a madman, and the other …

When is the final exam?

  1. Monday May 11 2:00ᴀᴍ
  2. Monday May 11 2:00ᴘᴀ
  3. Monday May 11 2:00ᴍᴘ
  4. Monday May 11 2:00ᴘᴍ
  5. Monday May 11 2:00ᴍᴀ
  6. Monday May 11 2:00ᴀᴘ

D: Monday May 11 2:00ᴘᴍ