Describe the concept of stable sorting algorithms and provide an example.
- Bubble Sort
- Heap Sort
- Merge Sort
- Quick Sort
Stable sorting algorithms maintain the relative order of equal elements in the sorted output as they were in the original input. Merge Sort is an example of a stable sorting algorithm because it preserves the order of equal elements during the merge phase. Quick Sort, Heap Sort, and Bubble Sort are not inherently stable unless additional steps are taken to maintain stability, such as using indexes or comparing indices during sorting. Understanding stable sorting is crucial in scenarios where maintaining the original order of equal elements is necessary.
Loading...
Related Quiz
- The "A" in ACID properties guarantees that database transactions are ___________.
- What is the purpose of primary keys in a relational database?
- You're tasked with optimizing resource utilization in a virtualized environment. How would you leverage container orchestration tools to achieve this goal?
- What is the primary goal of database normalization?
- Web application firewalls (WAFs) can help mitigate attacks by filtering incoming ________.