CPS 100E, Fall 1996 Inlab 8


Name:

Lab Section:


You should answer the following questions and either turn in the sheet during lab, or answer the questions when you submit your README file. These questions are worth 2 out of the 10 points for each lab. You don't need to get all the answers right to get the 2 points, but you must try.

It's ok to ask a UTA or TA for help, but first you must try to find the answers on your own.

  1. What is the purpose of the constants MIN_STR and MAX_STR in sortall.cc



  2. The function InsertSort is defined as the following template <class Type> void InsertSort(Vector<Type> & a, int size) // precondition: size = # of elements of a // postcondition: a is sorted // // uses insertion sort { Insert(a,0,size-1); } Why don't we just call Insert rather than go through InsertSort



  3. (This question was also asked in the lab writeup.) What happened to the speed of Quick Sort when the elements in the array were limited to be less than 100? Why did the speed decrease so much? How and why did the new partition function Pivot3 affect the speed of the algorithm?



  4. In this lab, we generated random strings to be sorted. Is this a fair test of the sorting algorithms? Why or why not?



  5. How is the "pivot" (element to partition) the array for Quick sort chosen?