Download page.
Download this page onto your computer and place it on your webpage.
Look with an editor at the file. The following commands can be
used.
cd ~/public_html
wget http://www.comp.nus.edu.sg/~gem1501/assignment07.html
chmod 755 *.html
Implement the Bubble Sort Algorithm.
The algorithm is on pages 21-23 in Chapter 2 of Harel's Book.
There is a "document.write" statement at the place of the
missing part.
Keep track of what the algorithm is doing.
Write out all intermediate values during the sorting process.
Bring algorithm in final form.
Modify the program such that it stops sorting whenever in one
round no pairs of list elements are exchanged.
You can use the variable "ready" to track that event down.
For this, you have to delete one appropriate line.
How many rounds does the sorting then need?
Self-Assessment.
After the fifth round, the output should
look like this.
List of words after Round 5.
a is is list not of but should be put in alphabetical
order by bubble sort sorted this which words yet
The number of rounds is less than the number of words.