Questions on this exam will be true/false, fill-in-blank, multiple choice, or short answer, for the most part. You might be asked to complete or modify the implementation of an algorithm.
Exam covers all material discussed in lecture and this reading:
Chapter 1 incl. insert sort and merge sort.
Section 4.3 solving recurrences using "master method"
Chapter 7 heap sort, heaps as priority queues
Sections 8.1 8.2 quick sort
Sections 10.1 10.2 median finding and selection of k-th element
(randomized method)
Section 9.1 Decision tree proof that comparison based sorting requires Omega(n lg(n)) comparisons.
Scan Chapter 11 Elementary data structures (CISC 220 review).
Chapter 12 (excluding proofs) hash tables.
Scan Chapter 13 binary search trees
Chapter 14 Red Black Trees
Chapter 19 B-trees
Major categories of algorithmic problem:
Sort sequences (assuming random access): Achieve sorted order
Order statistic: find item of rank k, (eg. median is item of rank n/2).
Priority Queue: extract-min, insert
Dictionary: search, insert, delete
Major points about analysis: Worst case time, average case time, expected case time. Use of master theorem,
The old exam exam questions attached are not completely representative of what you can expect. Nonetheless they shows where the emphasis is on comparing the merits of various algorithms for sorting and dictionary search.
More questions (from previous semesters)
a) How long should we expect insertion sort to run on an array of size about one million (1,000,000)? ________
b) a) How long should we expect the STL sort to run on the same array? ________
a) Each day the Weather Service receives a million weather station reports. It is essential that the data be sorted rather fast. However it is more important to be absolutely sure of being fairly fast than to be fairly sure of being really fast, with some data sets taking much longer. This is because the sort must be done in time to run the analysis program before the evening news. There is not enough memory on the computer to store two copies of the data set at once.
b) The boss wants these records sorted and sorted now. She is hopping mad that this wasn't done yesterday. The world will not end if the data set happens to be bad for the method, but you get a big win if it is really fast and you suprise her with the quick turnaround. Again, there is not enough memory to store two copies of the data.
c) This time there is lots of memory, but the dataset is so huge that even one copy of it doesn't fit in memory. Thus the data is on disk (or tape) and the sorted result must end on disk.
void mergesort(double A[], int firstindex, int lastindex) // sorts A[firstindex] thru A[lastindex] { if (firstindex < lastindex) { int midindex = (lastindex-firstindex-1)/2; mergesort(A, firstindex, midindex); mergesort(A, midindex+1, lastindex); merge(A, firstindex, midindex, lastindex); // merges A[firstindex]..A[midindex] with A[midindex+1]..A[lastindex] } }Consider the calls that would be made during this recursive process. For example, if X is an array of doubles, the call
mergesort(X, 1, 3)would involve the following function calls in the stated order.
mergesort(X, 1, 2) mergesort(X, 1, 1) mergesort(X, 2, 2) merge(X, 1, 1, 2) mergesort(X, 3, 3) merge(X, 1, 2, 3)List the calls to merge in the order they are done in mergesort(X, 1, 10). Include the specific values for the indices in each call. You do not need to include the recursive calls to mergesort, though you may want to keep track of them in some way to help you get the merges right.
merge(X, , , ) ...
___________ | D I | ----------- ___________ ___________ ___________ | A B C | | D E F H | | I J K | ----------- ----------- -----------