answersLogoWhite

0

Bubble sort work by comparing values of two numbers and then swapping them if they are in the wrong order until no more swapping can be done. procedure bubbleSort( A : list of sortable items ) defined as:

do

swapped := false

for each i in 0 to length(A) - 1 inclusive do:

if A[i] > A[i+1] then

swap( A[i], A[i+1] )

swapped := true

end if

end for

while swapped

end procedure

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is another name for bubble sort?

Bubble sort is also known as sinking sort.


Is bubble sort a stable sorting algorithm?

Yes, bubble sort is a stable sorting algorithm.


Which sorting algorithm is more efficient for small datasets: bubble sort or selection sort?

Selection sort is more efficient for small datasets compared to bubble sort.


What are the advantages for bubble sort?

Bubble sort has no practical applications other than that it is often cited as an example of how not to write an algorithm. Insert sort is the best algorithm for sorting small lists of items and is often used in conjunction with quick sort to sort larger lists. Like insert sort, bubble sort is simple to implement and is a stable sort (equal items remain in the same order they were input). However, insert sort uses copy or move operations rather than swaps (which is actually three operations per swap) and is therefore quicker. The only time a bubble sort will work quicker than insert sort is when the array is already sorted, which renders the entire algorithm redundant. A modified algorithm that specifically tests if an array is sorted or not would be more efficient than a single-pass bubble sort.


What is a bubble sort used for?

Bubble sort, incorrectly referred to as sinking sort is a simple sorting algorithm (step by step procedure of calculations) that works to repeatedly step through list to be sorted. With the comparing of each adjacent items and swapping them into the correct order. This repeated until there are no swaps needed and the list of items are sorted.


What is time complexity of bubble sort?

O(n*n)


Who invented the bubble sort?

ramesh


Bubble sort Extra or in space?

Bubble sort is an "in place" algorithm. Other than a temporary "switch" variable, no extra space is required.


What is bubble sort and explain with examples?

bubbles


Can you draw a flow chart for bubble sort?

no


What are some sorting rules for math?

Binary sort and bubble sort are two.


How do you sort the given contents of an array?

You would sort the given elements of an array by a bubble sort or heap sort code!!