I know how to perform a bubble sort but is there any difference between a quick sort and bubble sort ??
What is a quick sort?
Hi shikhar.
1 .Bubble Sort is inefficient compared to Quick Sort.
2.Bubble Sort, on average, has a time complexity of O(n^2), that is, for 2 elements in the array, there are 4 operations that happen, for 3, 9 operations, for 4, 16 operations, and so on. For each element, the algorithm iterates through the whole array ( minus an increasing number from the end of the array, when optimized). This becomes a problem when you have thousands of elements you’re trying to sort.
3.Quick Sort, on the other hand, has an average time complexity of O(n log n), meaning that it is less efficient than a linear algorithm, but each element added to the array is less expensive than the last.
4.Quick Sort recursively (or iteratively, based on implementation) splits the array, and subsequent parts, into left and right arrays, based on a pivot value. Worst case scenario, your pivot point is either the greatest or smallest element in the array, in which case, your time complexity increases to O(n^2), but if you choose a random pivot point, this shouldn’t be something you have to worry about too much.
I hope this will certainly help you.
If you are completely satisified with your doubt then please mark it resolved else revert back here.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.