True or false: A stable sorting algorithm preserves the original relative order of records that have equal keys.
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.
In bubble sort, what is guaranteed after one complete pass through the current unsorted portion?
- A
The smallest unsorted element
- B
The largest unsorted element
- C
The middle unsorted element
- D
The first element examined
Which named sorting algorithm is characterized by approximately n swaps while still performing about n2 comparisons?
Insertion sort builds a one element at a time.
What is the best-case time complexity of the standard selection-sort implementation described in the material?
- A
O(n)
- B
O(nlogn)
- C
O(n2)
- D
O(logn)
True or false: Merge sort can be stable when its merge operation chooses the left element first whenever two next elements are equal.
- A
True
- B
False
Which algorithms below are described as stable under the implementations specified in the material? Select all that apply.
- A
Bubble sort
- B
Insertion sort
- C
Merge sort
- D
Selection sort
How many inversions are in the array [3,1,2]?
In quicksort, the chosen value used to divide the array into partitions is called the .
A small array is already nearly sorted and has few inversions. Which algorithm is the most suitable choice according to the material?
- A
Selection sort
- B
Insertion sort
- C
Merge sort
- D
Quicksort with an unrandomized first-element pivot
Which statements about quicksort are supported by the material? Select all that apply.
- A
Its average-case time can be O(nlogn) with suitable pivot selection.
- B
Its worst-case time is always O(nlogn).
- C
Repeatedly unbalanced partitions can cause O(n2) time.
- D
Its standard implementations preserve equal-key order.
What extra space is required by the usual array implementation of merge sort?
- A
O(1)
- B
O(logn)
- C
O(n)
- D
O(n2)
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(nlogn) time bound; and (3) a setting that prioritizes average-case speed and low extra array memory but can use pivot randomization.
Which algorithm is generally described as using O(1) extra array space for in-place partitioning, while still requiring recursion-stack space?
- A
Quicksort
- B
Merge sort
- C
Selection sort
- D
Bubble sort
What is the primary purpose of sorting a collection of items?
- A
Rearranging items into a specified order
- B
Encrypting every item in an array
- C
Removing all duplicate items
- D
Randomly changing the positions of items
Why might selection sort be chosen when writing to memory is especially expensive?
- A
It guarantees linear running time on every input.
- B
It minimizes the number of swaps compared with the other elementary quadratic sorts.
- C
It is stable in its standard implementation.
- D
It requires O(n) additional array space.
Which situation is the best fit for insertion sort?
- A
A large unsorted array where guaranteed O(nlogn) time is required
- B
A small array that is already nearly sorted
- C
An application that requires the fewest possible comparisons
- D
An application that requires stable sorting with O(n) auxiliary memory
True or false: The standard implementation of selection sort is stable.
- A
True
- B
False
Using the standard selection sort pseudocode, how many element comparisons are performed when sorting an array of 6 elements?
What is the algorithm term for a pair of elements that appears in the opposite order from the desired ordering?
Related study packs and tools
02 — Information and Representation
A progressive guide to how computers encode numbers, text, images, and sound as binary data, including the trade-offs and limits of digital representation.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
04 Conditionals and Boolean Logic
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
05 — Data Structures: Concepts, Operations, and Trade-Offs
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
10 — Data, Systems, and Applications
A progression through how data is organized, searched, exposed through software interfaces, and managed through abstraction layers in modern computer systems.
12 — Foundations Capstone
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.