Free Practice Quiz Question List

9 Sorting Algorithms Online Quiz Questions

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

20 questions
01
True or false
1 point

True or false: A stable sorting algorithm preserves the original relative order of records that have equal keys.

  1. A

    True

  2. B

    False

02
Choose one
1 point

In bubble sort, what is guaranteed after one complete pass through the current unsorted portion?

  1. A

    The smallest unsorted element

  2. B

    The largest unsorted element

  3. C

    The middle unsorted element

  4. D

    The first element examined

03
Written response
1 point

Which named sorting algorithm is characterized by approximately nn swaps while still performing about n2n^2 comparisons?

04
Fill in the blank
1 point

Insertion sort builds a one element at a time.

05
Choose one
1 point

What is the best-case time complexity of the standard selection-sort implementation described in the material?

  1. A

    O(n)O(n)

  2. B

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

  3. C

    O(n2)O(n^2)

  4. D

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

06
True or false
1 point

True or false: Merge sort can be stable when its merge operation chooses the left element first whenever two next elements are equal.

  1. A

    True

  2. B

    False

07
Choose all
1 point

Which algorithms below are described as stable under the implementations specified in the material? Select all that apply.

  1. A

    Bubble sort

  2. B

    Insertion sort

  3. C

    Merge sort

  4. D

    Selection sort

08
Written response
1 point

How many inversions are in the array [3,1,2][3, 1, 2]?

09
Fill in the blank
1 point

In quicksort, the chosen value used to divide the array into partitions is called the .

10
Choose one
1 point

A small array is already nearly sorted and has few inversions. Which algorithm is the most suitable choice according to the material?

  1. A

    Selection sort

  2. B

    Insertion sort

  3. C

    Merge sort

  4. D

    Quicksort with an unrandomized first-element pivot

11
Choose all
1 point

Which statements about quicksort are supported by the material? Select all that apply.

  1. A

    Its average-case time can be O(nlog⁡n)O(n \log n) with suitable pivot selection.

  2. B

    Its worst-case time is always O(nlog⁡n)O(n \log n).

  3. C

    Repeatedly unbalanced partitions can cause O(n2)O(n^2) time.

  4. D

    Its standard implementations preserve equal-key order.

12
Choose one
1 point

What extra space is required by the usual array implementation of merge sort?

  1. A

    O(1)O(1)

  2. B

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

  3. C

    O(n)O(n)

  4. D

    O(n2)O(n^2)

13
Open ended
1 point

Recommend suitable algorithms for each of these situations and justify each recommendation: (1) a small, nearly sorted array; (2) records that must retain equal-key order with a guaranteed O(nlog⁡n)O(n \log n) time bound; and (3) a setting that prioritizes average-case speed and low extra array memory but can use pivot randomization.

14
Choose one
1 point

Which algorithm is generally described as using O(1)O(1) extra array space for in-place partitioning, while still requiring recursion-stack space?

  1. A

    Quicksort

  2. B

    Merge sort

  3. C

    Selection sort

  4. D

    Bubble sort

15
Choose one
1 point

What is the primary purpose of sorting a collection of items?

  1. A

    Rearranging items into a specified order

  2. B

    Encrypting every item in an array

  3. C

    Removing all duplicate items

  4. D

    Randomly changing the positions of items

16
Choose one
1 point

Why might selection sort be chosen when writing to memory is especially expensive?

  1. A

    It guarantees linear running time on every input.

  2. B

    It minimizes the number of swaps compared with the other elementary quadratic sorts.

  3. C

    It is stable in its standard implementation.

  4. D

    It requires O(n)O(n) additional array space.

17
Choose one
1 point

Which situation is the best fit for insertion sort?

  1. A

    A large unsorted array where guaranteed O(nlog⁡n)O(n \log n) time is required

  2. B

    A small array that is already nearly sorted

  3. C

    An application that requires the fewest possible comparisons

  4. D

    An application that requires stable sorting with O(n)O(n) auxiliary memory

18
True or false
1 point

True or false: The standard implementation of selection sort is stable.

  1. A

    True

  2. B

    False

19
Written response
1 point

Using the standard selection sort pseudocode, how many element comparisons are performed when sorting an array of 6 elements?

20
Written response
1 point

What is the algorithm term for a pair of elements that appears in the opposite order from the desired ordering?