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.