Which sorting algorithm has a worst-case time complexity of O(n^2) in its basic form?किस छंटाई एल्गोरिथ्म में अपने मूल रूप में O (n^2) की सबसे खराब स्थिति की जटिलता है?
Show answerHide answer
Correct answer: (C) Insertion Sortसम्मिलन सॉर्ट
Explanation
Insertion sort makes about n²/2 comparisons and shifts on reverse-sorted input, so its worst case is O(n²). Merge sort is O(n log n) and counting sort is O(n + k). Basic quick sort also has an O(n²) worst case, which makes the question loose.Insertion sort उलटे क्रम के इनपुट पर लगभग n²/2 तुलनाएँ और खिसकाव करती है, इसलिए उसका सबसे बुरा मामला O(n²) है। Merge sort O(n log n) और counting sort O(n + k) है। साधारण quick sort का भी सबसे बुरा मामला O(n²) है, जिससे प्रश्न ढीला है।