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.