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


    Question

    Consider the array [5, 2, 8, 1, 9]. After the first pass

    of Selection Sort (to find the minimum element and place it at the beginning), what will the array look like?
    A [1, 2, 8, 5, 9] Correct Answer Incorrect Answer
    B [1, 5, 8, 2, 9] Correct Answer Incorrect Answer
    C [2, 5, 8, 1, 9] Correct Answer Incorrect Answer
    D [5, 2, 8, 1, 9] (no change) Correct Answer Incorrect Answer
    E [9, 5, 8, 1, 2] Correct Answer Incorrect Answer

    Solution

    Selection Sort works by repeatedly finding the minimum element from the unsorted part and putting it at the beginning.     Initial array: [5, 2, 8, 1, 9]     In the first pass, the minimum element is 1 (at index 3). It is swapped with the element at index 0 (5).     Resulting array: [1, 2, 8, 5, 9]

    Practice Next
    ask-question