+ 4

Would replacing Bubble Sort by Quick Sort increase the Search speed?

https://code.sololearn.com/czT1HfcObspH/?ref=app

25th Nov 2021, 7:57 AM
Sanjay Kamath
Sanjay Kamath - avatar
4 Antworten
+ 5
BUBBLE SORT =========== Worst Time Complexity: O(n^2) Best Time Complexity: O(n) Space Complexity: O(1) QUICK SORT ========== Worst Complexity: O(n^2) Best Time Complexity: O(n log n) Space Complexity: O(1) From this you can see depending on your input, using quick sort might help. Also using quick sort can be faster in the best case whereas in bubble sort for the best case will give slower sorting. Remember, Best Case represents, already sorted. Worst Case represents, sorted in opposite. If you are looking for more faster sorting, then you can use Linear search, Tournament Method or Paris Comparison. Refer: www.geeksforgeeks.org/maximum-and-minimum-in-an-array/amp/ If have any questions, feel free to ask.
25th Nov 2021, 9:03 AM
Arun Bhattacharya
Arun Bhattacharya - avatar
+ 2
Martin Taylor Agree. Loading stack frames for Quick Sort seems to be overkill. Swapping values on a single stack appears to have low overhead, in Bubble Sort. IMHO Indirection may help....Do you agree?
25th Nov 2021, 12:40 PM
Sanjay Kamath
Sanjay Kamath - avatar