Lesson 12 of 23
Searching और Bubble Sort
11 min 30 XP
Bubble sort पड़ोसियों की तुलना करता है और गलत क्रम में हों तो swap करता है; हर pass सबसे बड़ी value को अंत तक ले जाता है। Time complexity: O(n²)।
Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.Sorted array पर binary search बीच के तत्व से तुलना करता है और हर बार आधा हिस्सा छोड़ देता है: O(log n), यानी दस लाख तत्वों में भी लगभग 20 कदम!
Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.