# What is the difference between bubble sort & quick sort?

#### 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

#### 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.

#### sivanesh.a Profile Answers by sivanesh.a Questions by sivanesh.a

• Feb 6th, 2007

Quick sort is faster than Bubble sort.

#### rohini.nitd Profile Answers by rohini.nitd

• Aug 16th, 2009

There is a major difference between these 2 like complexities in terms of space and time etc.

#### Aqan12 Profile Answers by Aqan12 Questions by Aqan12

• May 26th, 2010

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.