What is the difference between bubble sort & quick sort?

Showing Answers 1 - 18 of 18 Answers

mahesh

  • Dec 12th, 2006
 

Bubble sort is a sort in which at each pass highest value is taken to right

Quick sort is a sort in which pivot is chosen and all the elements less than pivot are kept to left and elements greater than pivot are kept to right

  Was this answer useful?  Yes

GCTHere

  • Feb 5th, 2007
 

Bubble sort is easy to program, slower, iterative. Compares neighboring numbers swaps it if required and continues this procedure until there are no more swaps

Quick Sort is little difficult to program, Fastest, Recursive. Pivot number is selected, other numbers are compared with it and shifted to the right of number or left depending upon criteria again this method is applied to the left and right list generated to the pivot point number. Select pivot point among that list.

Bubble sort is a very simple algorithm which compares two neighbouring elements and swaps them if they are not in the right order.  

In a worst case scenario when the list is already sorted in reverse order, bubble sort will make n^2 comparisons.

QuickSort is slighly more complex algorithm that devides the array into two parts using a pivot point and recursively sorts sub arrays.

Both BS & QS can be implemented as in-place-sort without needing temp memory space, so they are comparable in terms of memory requirements.

So in the end key difference is performance
Avg & Worst case performance of bubble sort O(n^2)
Best case performance of bubble sort is O(n) - when the list is already sorted.
Performance of quick sort is O(n log(n))

aahwini m

  • Feb 8th, 2016
 

Quicksort is faster than bubble sort and the main difference is time complexity.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions