Friday, July 16, 2010

How to implement bubble sort with linked list with java language ?

i must implement bubble sort with linked list in java programming

How to implement bubble sort with linked list with java language ?
I think this link will be wonderful resource for you:





http://www.cs.ubc.ca/~harrison/Java/sort...
Reply:import java.util.LinkedList;





class BubbleSort{


void sort(LinkedList a) throws Exception {


for (int i = a.size(); --i%26gt;=0; ) {


boolean flipped = false;


for (int j = 0; j%26lt;i; j++) {


if (a.get(j) %26gt; a.get(j+1)) {


int T = a.get(j);


a.set(j,a.get(j+1));


a.set(j+1,T);


flipped = true;


}


}


if (!flipped) {


return;


}


}


}


}
Reply:just try

shoe zippers

No comments:

Post a Comment