Which of the following statements is/are true? S1. A sorting algorithm is…
Which of the following statements is/are true?
S1. A sorting algorithm is in-place if the relative order of common elements is maintained after sorting.
S2. A sorting algorithm is stable if it requires very little additional space besides the initial array holding the elements that are to be sorted.
Answer: D. Neither S1 nor S2 — S1 is false: A sorting algorithm is stable if it maintains the relative order of equal elements, not "in-place". An in-place algorithm refers to one that…
- A.
Only S1
- B.
Only S2
- C.
Both S1 & S2
- D.
Neither S1 nor S2
Attempted by 760 students.
Show answer & explanation
Correct answer: D
S1 is false: A sorting algorithm is stable if it maintains the relative order of equal elements, not "in-place".
An in-place algorithm refers to one that sorts the elements using only a small, constant amount of extra space.
S2 is false: A sorting algorithm is in-place if it requires minimal extra space, but stability refers to whether equal elements retain their relative order, not how much extra space is used.
Thus, the correct answer is (D) Neither S1 nor S2.