maths.com

Bookmark and Share
SEARCH USING KEY WORDS  or  ASK A QUESTION
Games     Challenge    
NUMBERS      ALGEBRA      GEOMETRY      TRIGONOMETRY      CALCULUS      MORE
 

Decision Theory

Decision Mathematics

Bubble Sort Algorithm

 

Bubble Sort Algorithm With Music

 

Bubble Sort Algorithm With Silent Film Music

 
 
 
 
 
 
 

Go to Decision Index

Go to maths.com Home Page

 

Bubble Sort Algorithm
External Links

Do Some YourSelf - Step By Step

Bubble Sort First 4 Digits

Bubble Sort First 5 Digits

Bubble Sort First 7 Digits

Bubble Sort 4 Random Digits

Bubble Sort 5 Random Digits

Bubble Sort 7 Random Digits


Bubble Sort Algorithm
Worked Example

Sort The Numbers
Into Ascending Order

arranged from left to right

We start working from left to right
and compare each pair of numbers as we reach them - 1st & 2rd, 2rd & 3rd, 3rd & 4th then 4th & 5th

If the number on the left is larger
then we move it to the right
and the number that was on the right
we move to the left

If the number on the left is smaller
then we leave that pair of numbers as they are

7 4 9 6 1
4 7 9 6 1
4 7 6 9 1
4 7 6 1 9

End of first pass - the largest number is at the right hand side

Again, work from left to right

4 7 6 1 9
4 6 7 1 9
4 6 1 7 9

End of second pass - the largest two numbers are at the right hand side

Now again, work from left to right

4 6 1 7 9
4 1 6 7 9

End of third pass - the largest three numbers are at the right hand side

Last time, work from left to right

4 1 6 7 9
1 4 6 7 9

End of fourth pass
the numbers are in order



BUBBLE SORT

Input Numbers
Into The Box Below
To Get Them Sorted
Into Ascending Order

arranged from left to right

Enter numbers here:
The sorted numbers are:

Free JavaScripts provided
by The JavaScript Source

 

Worksheets

Practice Papers

Join The Mailing List

MultiSearch - Key Words or Ask A Question
Searches maths.com And Selected Maths Dictionary Type Websites

thesaurus.maths.org

mathworld.wolfram.com

BBC News Feed Mathematics

Created and Edited by Dr David Cornelius an Independent Private Maths Tutor with over 25 years of experience and The Secretary of The Association of Tutors in the UK for 15 years
Contact   Disclaimer   Copyright   Privacy   Feedback