Unit testing
Sorting
Random numbers
Enumerations
Potpourri
100

What does unit test typically test?

A function.

100

What sorting algorithm always compares adjacent (side-by-side) elements, swapping them when they are out of order?

Bubble sort

100

What function seeds the random number generator?

srand()

100

What type of value is assigned to each enum value?

Integer
100

How many elements should a vector have to represent a tic-tac-toe board?

9

200

What is a unique set of input values for a unit test called?

A test vector.

200

Which sorting algorithm is almost always going to be the slowest?

Selection sort

200

What is the smallest and largest number assigned to x?

x = rand() % 8;

0 and 7

200

True or false: A function can have a parameter with an enum type AND return an enum type.

True

200

What should you have used an enum for in your Math Quiz program?

The difficulty levels

300

What kind of functions are difficult to unit test?

A function that displays output, receives user input, or generates random numbers.

300

Which sorting algorithm is fast if the array is already nearly sorted?

Bubble sort

300

What value should srand() be called with to ensure the program always generates different random numbers?

time(0) or the number of seconds that have elapsed since Jan 1, 1970

300

Declare an enum called Medals with GOLD, SILVER, and BRONZE.

enum Medals {GOLD, SILVER, BRONZE};
300
The GetHumanMove() function for our tic-tac-toe program had to ensure the user didn't values that were _____.

too small, too large, already had an X or O

400

Write an assert for this function:

int Max(int x, int y) { ... }
assert(Max(1, 2) == 2);
400

What does a vector with [3 8 1 6 9] contain after swapping once with selection sort?

[1 8 3 6 9]

400

What statement assigns x with a random number between 1 and 10?

x = rand() % 10 + 1;
400

Create a variable called myMedal that uses the enum type Medal and is assigned with SILVER.

Medal myMedal = SILVER;
400

The GetComputerMove() function had a loop to keep choosing random numbers if what happened?

rand() returned an index where the element was X or O
500

How would a SelectionSort() function be tested with assert()?

Call SelectionSort() with an unsorted vector, then call assert() to see if the vector is now equal to an equivalent sorted vector.
500

What does the vector [ 3 8 9 6 1 ] contain after swapping twice with bubble sort?

[ 3 8 6 1 9 ] 

500

What statement assigns x with a random number between -10 and 10?

x = rand() % 21 - 10;
500

If an GroceryItem is declared with APPLES, BANANAS, and WATER using the default values, what does outputting userItem display?

GroceryItem userItem = WATER;

2

500

What phrase does the MCP from the movie Tron always sign off with?  In C++, an output statement might use a constant, which is an abbreviation for this phrase.

"End of line"

M
e
n
u