Ch. 10 Review Answers

  1.  
     (a) Time in seconds(b) # in 1 hour
    sequential search609,000,000
    binary search0.69015289692
    insertion sort900094868.33
    selection sort900094868.33
    Shellsort209.9781,456,780.12
  2. 11 27 12 15 31 18 29 39 19 32 49 44 54 55 48 54 72 88 75 84 93 77 84 99 95 85
    1. 15 85 93 11 84 19 29 39 31 54 27 18 77 84 12 95 99
      15 85 93 11 84 19 29 39 31 54 27 18 77 84 12 95 99
      15 85 12 11 84 19 29 39 31 54 27 18 77 84 93 95 99
    2. 15 85 93 11 84 19 29 39 99 54 27 18 77 84 12 95 31
      15 85 93 11 84 19 29 39 99 54 27 18 77 84 12 95 31
      11 15 85 93 84 19 29 39 99 54 27 18 77 84 12 95 31
  3. public static void selectSort(double[] list)
    {
       for (int top = list.length - 1; top > 0; top--)
       {
                          0
          int largeLoc = top;
                                
          for (int i = 1; i <= top; i++)
                         >
             if (list[i] < list[largeLoc])
                largeLoc = i;
          double temp = list[top];
          list[top] = list[largeLoc];
                             temp
          list[largeLoc] = list[top];
       }
    }