Question
Which of the following sorting algorithms is NOT
stable?ÂSolution
Quick Sort is not a stable sorting algorithm. Stability in sorting algorithms means that equal elements retain their relative order before and after sorting. Quick Sort does not guarantee this behavior because, during partitioning, equal elements may get swapped in such a way that their relative order is not preserved. Although Quick Sort is an efficient comparison-based sorting algorithm with an average time complexity of O(n log n), its lack of stability makes it unsuitable for cases where maintaining relative order of equivalent elements is crucial. Why Other Options are Incorrect: A) Merge Sort: This is a stable sorting algorithm as it ensures that the relative order of equal elements remains unchanged. B) Bubble Sort: Bubble Sort is stable as elements are swapped only if necessary. D) Insertion Sort: Insertion Sort is stable because it inserts equal elements in their original order. E) Tim Sort: Tim Sort is a stable sorting algorithm, combining Merge Sort and Insertion Sort properties.
If 75% of a number is added to 75, the result is the number itself, then the number is:
- Ritesh got 84 marks in an exam, which is 100% more than the marks secured by Mohan. If Mohan failed the exam by 4 marks, then find the total marks of Rites...
Rohit spends 25% of his income on groceries, 40% of the remaining income on entertainment, 60% of the amount left after expenditure on groceries and ent...
In an election between two candidates, winner got 65% of total valid votes. If total number of votes cast were 2000 out of which 6% were invalid, then f...
Pawan has some money left after spending 20%, 15% and 30% of monthly salary on rent, electricity and shopping respectively. The remaining money with Paw...
- Rohit spends 69% of his monthly income and saves Rs. 6,510. What is the income of his friend whose income is 30% more than Rohit’s?
Total number of students in a class is 1920, and the ratio of number of boys to girls is 7:9. If the number of boys and girls is increased by a% and (a ...
40 Litres of water is added to 60 litres of a solution containing 40% alcohol . What is the concentration of alcohol in solution now?
If 25% of ‘a’ is equal to 5 times 60% of ‘b’ and ‘a’ is 80% of 500, then find the value of ‘b’.
In a village election between two candidates, the winner secured 70% of the total votes cast and won by a majority of 13000 votes. How many votes did th...