📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    A sorting algorithm is considered "stable" if it

    maintains the relative order of records with equal keys. Which of the following algorithms is generally stable?
    A Quick Sort Correct Answer Incorrect Answer
    B Heap Sort Correct Answer Incorrect Answer
    C Selection Sort Correct Answer Incorrect Answer
    D Merge Sort Correct Answer Incorrect Answer
    E Shell Sort Correct Answer Incorrect Answer

    Solution

    Merge Sort is a stable sorting algorithm because it can be implemented to preserve the relative order of equal elements during the merging process. Quick Sort, Heap Sort, and Selection Sort are typically unstable as they might swap equal elements, changing their original relative order. Shell Sort is also generally unstable.

    Practice Next
    ask-question