Quiz 4 preparation material
Quiz 4 will be 50 minutes long, handwritten, and conducted in the first half of
the weekly lab session.
The quiz will be closed book, closed notes, and no electronics permitted,
but students will be permitted one double-sided 8.5x11" 'cheat sheet'. (These do not need to
be handwritten.)
Some questions on the quiz may ask you to write short explanations/descriptions of different
aspects of C++, some will ask you to write short C++ code segments to achieve specific results,
some will ask you to show and/or explain the results of short C++ code segments.
The topics and suggested preparation activities for the quiz are listed below.
As with prior quizzes, the best way to practice coding in general is to write and debug as many small programs as
you have time for. The best way to practice for hand-written quizzes and exams is to try
writing small programs on paper then take your answers and type them in/debug them to see
where the bugs are. If you need a refresher on how to write/compile 'from scratch' programs
(as opposed to the ones in the provided lab and make files), see the notes near the
top of the quiz 1 prep material.
- arrays
- There will be one general question on arrays: likely with the array passed as a parameter
to a function that is supposed to process the data somehow. Typical objectives for the function would be
things like
- fill the array with user-supplied data
- print the array contents
- copy N elements of one array into another (with two array parameters)
- find the smallest/largest value in an array
- count the number of values in the array that are bigger than some target,
- etc
- searching
- This will likely include one part that checks that you know the circumstances under which
one should choose linear/binary search, then a second part that checks you know how binary search
works (e.g. given the following binary search algorithm, show the sequence of midpoints that are
visited)
- sorting
- This will check that you know how bubblesort works, e.g. given the initial array
content and sorting algorithm shown below, show the revised array content after each of the
first three passes through the outer loop.
- null-terminated character arrays
- This will check that you know how the strlen, strcmp, strcpy functions work on
null-terminated character arrays (checking for the '\0' character as a marker for the
end of the relevant content rather than using a size).
The question will likely involve either writing one of the three functions and showing
the results of another.