Free Practice Quiz Question List

09 Sorting Algorithms Online Quiz Questions

Use this free practice quiz with 20 questions to review 09 Sorting Algorithms, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

What property does a stable sorting algorithm guarantee?

  1. A

    It always runs in O(n)O(n) time.

  2. B

    It preserves the relative order of equal-key records.

  3. C

    It uses no extra memory.

  4. D

    It never compares two elements.

02
True or false
1 point

True or false: Standard selection sort performs Θ(n2)\Theta(n^2) comparisons in its best, average, and worst cases.

  1. A

    True

  2. B

    False

03
Written response
1 point

Using selection sort that executes one swap operation at the end of each of the first n−1n-1 passes, how many swap operations are executed for an array of five elements?

04
Fill in the blank
1 point

Insertion sort builds a one element at a time.

05
Choose one
1 point

A small array is already nearly sorted, and the goal is to use a simple algorithm that can take advantage of that order. Which algorithm is the most appropriate choice?

  1. A

    Selection sort

  2. B

    Merge sort

  3. C

    Insertion sort

  4. D

    Heap sort

06
Choose all
1 point

Select all algorithms that are described as stable in their standard forms in the material.

  1. A

    Insertion sort

  2. B

    Bubble sort

  3. C

    Selection sort

  4. D

    Merge sort

07
True or false
1 point

True or false: Quicksort can take O(n2)O(n^2) time when pivot choices repeatedly produce highly unbalanced partitions.

  1. A

    True

  2. B

    False

08
Written response
1 point

For heap sort in ascending order, which type of heap is built?

09
Fill in the blank
1 point

For ascending heap sort, the algorithm builds a .

10
Choose one
1 point

Merge sort produces the sorted halves [3,7,8][3,7,8] and [2,4,9][2,4,9]. What is the result of merging these halves?

  1. A

    [3, 2, 4, 7, 8, 9]

  2. B

    [2, 4, 3, 7, 8, 9]

  3. C

    [2, 3, 4, 7, 8, 9]

  4. D

    [2, 3, 7, 4, 8, 9]

11
Choose all
1 point

Select all algorithms in this list that can preserve the relative order of equal-key records under the standard conditions described in the material.

  1. A

    Insertion sort

  2. B

    Bubble sort

  3. C

    Quicksort

  4. D

    Merge sort

12
True or false
1 point

True or false: For arbitrary inputs, no comparison-based sorting algorithm can guarantee a worst-case running time in o(nlog⁡n)o(n\log n).

  1. A

    True

  2. B

    False

13
Open ended
1 point

Explain what stability means in sorting and why it is useful when records are sorted by multiple fields. Use the equal-score example involving Ana and Cara to support your explanation.

14
Choose one
1 point

A system requires a sorting algorithm with guaranteed worst-case O(nlog⁡n)O(n\log n) time and O(1)O(1) extra space. Which algorithm best matches these requirements?

  1. A

    Merge sort

  2. B

    Heap sort

  3. C

    Quicksort

  4. D

    Insertion sort

15
Choose one
1 point

Which sequence is a correct ascending sort of the input [4, 1, 3, 2]?

  1. A

    [1, 2, 3, 4]

  2. B

    [1, 2, 4, 4]

  3. C

    [1, 3, 2, 4]

  4. D

    [4, 3, 2, 1]

16
Choose one
1 point

Bubble sort compares adjacent elements and swaps them when they are out of order. What is the array after the first complete left-to-right pass on [5, 1, 4, 2]?

  1. A

    [1, 4, 2, 5]

  2. B

    [1, 2, 4, 5]

  3. C

    [5, 1, 4, 2]

  4. D

    [4, 1, 2, 5]

17
Written response
1 point

In a zero-based array representation of a binary heap, what is the parent index of the node at index 55?

18
Written response
1 point

Which sorting algorithm is generally a good choice for a small collection that is already nearly sorted?

19
Choose one
1 point

A collection is first sorted by last name and then stably sorted by department. Which property ensures that records in the same department remain in their previous last-name order?

  1. A

    In-place operation

  2. B

    Stability

  3. C

    Worst-case linear time

  4. D

    Constant-time merging

20
Choose one
1 point

Merge sort satisfies the recurrence T(n)=2T(n2)+Θ(n)T(n)=2T(\frac{n}{2})+\Theta(n). What is its asymptotic running time?

  1. A

    O(n)O(n)

  2. B

    O(n2)O(n^2)

  3. C

    O(nlog⁡n)O(n\log n)

  4. D

    O(log⁡n)O(\log n)