Previous Section
 < Free Open Study > 
Next Section


Chapter 10

    1. Bubble sort

    2. Selection sort

    3. Insertion sort

    1. 4950

    2. 99

    1. O(N2)

    2. O(N)

    3. O(N2)

    4. O(Nlog2N)

    5. O(N)

    6. O(Nlog2N)

  1. The correct answer is (c).

  2. The correct answer is (d).

  3. QuickSort would take the longest; InsertionSort and ShortBubble would take the shortest.

    1. A bubble sort is O(N) if the values are already sorted, and if the algorithm stops processing when the sorting is complete (e.g., ShortBubble).

    2. None.

    3. QuickSort is O(N2) if the values are already sorted and the split algorithm causes the array to be split into one element and the rest of the array.

    1. True.

    2. False. HeapSort is better for nearly sorted data than QuickSort is.

    3. True

  1. Only (b) is true.

  2. Programmer time refers to the amount of time it takes a programmer to generate a piece of software, including the time to design, code, and test it. If a programmer needs to finish a software project quickly, sometimes his or her time is a more critical efficiency consideration than how fast the resulting program runs on a computer. In this chapter, recursive sorting algorithms are cited as time-savers for the programmer, possibly at the expense of computing time.

  3. The correct answer is (b).

  4. All of the algorithms are stable except HeapSort.

  1. Declare an array indexed from 0 through 99. Use the slots in the array as counters for that percentile score-that is, the slot indexed by 0 is the counter for percentile scores of 0; the slot indexed by 2 is the counter for percentile scores of 2; and so on. To produce the required output, go through the array from 99 down to 0, printing the loop counter as many times as values appear in that slot.

    1. HeapSort

    2. QuickSort or InsertionSort

    3. QuickSort

    4. MergeSort

    1. For the best case, O(N)

    2. For the worst case, O(N)

    1. For the best case, O(1)

    2. For the worst case, O(N2)

  1. Click To expand
  2. Click To expand
  3. Click To expand
  4. Click To expand
    1. 50

    2. 50

    3. 50

  1. The correct answer is (a).

  1. To sort the file in descending order, collect the queues from Queues [9] down to Queues [0].

  2. No. Simply substituting the Stack ADT for the Queue ADT would not work. The elements would be gathered in the wrong order.



Previous Section
 < Free Open Study > 
Next Section
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)