CS 112 - Lab 7
Questions


Provide answers (on this sheet) to the questions below, and hand them to the TAs at the beginning of lab on Friday, April 4.

  1. Using the seed 23 for the rand( ) function, what are the approximate sorting times for the three different routines?
    
    
    
    
    
    
  2. Modify your loop that loads the random numbers in the array so it loads a list already sorted in ascending order (change the assignment list_q[i]=r; to list_q[i]=i; and so on). Now, what are the approximate sorting times for the three routines?
    
    
    
    
    
  3. Modify your loop that loads the random numbers in the array so it loads a list already sorted in descending order (change the assignment list_q[i]=r; to list_q[i]=MAXSIZE-i; and so on). Now, what are the approximate sorting times for the three routines?
    
    
    
    
    
  4. Upon any return from the function qsort( ), can your program immediately tell what position (for any i) the i-th element in the original list now occupies in the sorted list? Explain.