Jump to content

Sorting algorithms/Strand sort: Difference between revisions

(GP)
Line 42:
LinkedList<E> sorted = new LinkedList<E>();
sorted.add(list.removeFirst()); //same as remove() or remove(0)
for(intIterator<E> iit = 0list.iterator(); i < listit.sizehasNext();i++ ){
E elem = listit.getnext(i);
if(sorted.peekLast().compareTo(elem) <= 0){
sorted.addLast(elem); //same as add(elem) or add(0, elem)
listit.remove(i--);
}
}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.