Which of the following sorting algorithms is not stable?
Practice Questions
Q1
Which of the following sorting algorithms is not stable?
Bubble Sort
Merge Sort
Quick Sort
Insertion Sort
Questions & Step-by-Step Solutions
Which of the following sorting algorithms is not stable?
Step 1: Understand what a sorting algorithm is. A sorting algorithm is a method for arranging elements in a list in a certain order (like ascending or descending).
Step 2: Learn about stability in sorting algorithms. A stable sorting algorithm maintains the relative order of equal elements (elements that are the same).
Step 3: Identify some common sorting algorithms. Examples include Bubble Sort, Merge Sort, Quick Sort, and Insertion Sort.
Step 4: Check which of these algorithms are stable. Bubble Sort, Merge Sort, and Insertion Sort are stable. Quick Sort is not stable.
Step 5: Understand why Quick Sort is not stable. During the sorting process, Quick Sort can rearrange equal elements, changing their original order.