CS Grade 9-12

CS: Merge Sort and Quick Sort Algorithms

Comparing divide-and-conquer sorting strategies

View Answer Key
Name:
Date:
Score: / 12

Comparing divide-and-conquer sorting strategies

CS - Grade 9-12

Instructions: Read each problem carefully. Show your work in the space provided. For tracing problems, write the array after each important step.
  1. 1
    Merge sort diagram showing four bars split into singles and merged into ascending order.

    Trace one full merge sort on the array [8, 3, 5, 1]. Show how the array is split and then merged into sorted order.

  2. 2
    Quick sort partition diagram with smaller bars moved left of the pivot and a larger bar moved right.

    Trace the partition step of quick sort on the array [6, 2, 8, 4, 1] using 6 as the pivot. Write the values that should go to the left and right of the pivot after partitioning.

  3. 3

    Explain why merge sort is called a divide-and-conquer algorithm.

  4. 4

    For the array [9, 7, 5, 3, 1], suppose quick sort always chooses the first element as the pivot. Explain why this is a poor pivot choice for this array.

  5. 5

    What is the worst-case time complexity of merge sort, and why does it have that complexity?

  6. 6

    What is the worst-case time complexity of quick sort, and what type of partitioning causes it?

  7. 7

    Compare the extra memory usage of merge sort and quick sort in a typical array implementation.

  8. 8
    Two three-bar halves are shown before and after sorting within each half.

    The array [4, 1, 6, 2, 5, 3] is being sorted using merge sort. After the array is split into [4, 1, 6] and [2, 5, 3], what are the sorted versions of those two halves before the final merge?

  9. 9
    Two sorted bar groups merge into one longer sorted sequence.

    Merge the two sorted lists [2, 6, 9] and [1, 5, 7, 10]. Show the final sorted list.

  10. 10

    A quick sort implementation chooses a random pivot. Explain one reason this can improve performance compared with always choosing the first element.

  11. 11

    A sorting algorithm is stable if equal values keep their original relative order. Is standard merge sort usually stable, and why?

  12. 12

    You need to sort a very large array, and you want guaranteed O(n log n) worst-case time. Between merge sort and quick sort, which would you choose and why?

LivePhysics™.com CS - Grade 9-12

More CS Worksheets

See all CS worksheets

More Grade 9-12 Worksheets

See all Grade 9-12 worksheets