This week's book giveaway is in the Servlets forum. We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line! See this thread for details.

Well, I'm rather sure your course notes or text has a pseudo-code algorithm for Bubble-sort. Even if its missing, a Google search is definitely able to help you get it, then you merely need to implement the algorithm into Java code.

Don't say it's Data Structures and Algorithms related subject. I am also currently studying in that subject in MSCS. But in my master course, I do not need to implement them at all. Rather I have to analyze the running time and detailed worst-case, average-case and best-case running of each of them...

I do miss the time when I had to implement them in Java, when I was in bachelor course... But, Iqbal Ali, don't be discourage... As Cheng Wei Lee suggested, you'd better learn with Pseudocode from the textbook and implement them in Java... Just concentrate on understanding how they work, then you'll be able to beat it...

Co-author of SCMAD Exam Guide, Author of JMADPlus SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0

Bubble sort is named "bubble" because the largest value (or the smallest value, depending on whther you use < or > in your comparison) will float to the top of the list, like a bubble in a tank of water.

Assume you have a list of numbers, a, b, and c. The bubble sort is a variation on a swap - you compare two numbers, if a > b, then swap a & b. Next, compare (the new) b to c. At the end of the first iteration, the largest value will be at the top of the list. Simply start at the bottom of the list, and do it again. You are done when you pass through the list and no swaps take place.

There are several variation on it to enhance processing time - such as: the first time through, loop n times, where n is the number of items in the list - 1. Next time, loop n-2 times (because you know that the largest value is already at the top, there is no need to compare it and waste the cycles). I will leave you to discover the other variations.