Results 1 to 1 of 1
Thread: Doubly Linked List
- 06-02-2010, 05:58 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 8
- Rep Power
- 0
Doubly Linked List
Hi
I have this insertionSort method in my class but really I don't know that if
Java Code:end == list.getLast()
Java Code:public DNode getLast() throws IllegalStateException { if (isEmpty()) { throw new IllegalStateException("the list is empty"); } return trailer.getPrev(); } public void insertionSort(DoublyLinkedList list) { if (list.size <= 1) { return;//L is already sorted in this case } DNode end, p, ins; end = list.getFirst(); while (end != list.getLast()) { p = end.getNext(); list.remove(p); ins = end; while (list.hasPrev(ins) && ins.getElement().compareTo(p.getElement()) > 0) { ins = ins.getPrev(); list.addAfter(ins, p); if (ins == end) { end = end.getNext(); } } } }
Similar Threads
-
Linked list inside a linked list
By viperlasson in forum New To JavaReplies: 5Last Post: 07-26-2010, 11:15 PM -
Doubly Linked Lists
By stevenson15 in forum New To JavaReplies: 6Last Post: 04-21-2009, 12:35 PM -
doubly linked list insert
By ineedhelpwithjava in forum Advanced JavaReplies: 1Last Post: 03-20-2009, 02:05 PM -
Help with Doubly linked list
By Dr Gonzo in forum New To JavaReplies: 5Last Post: 12-06-2008, 07:45 AM -
Doubly-linked list with data structure
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 10:30 PM
Bookmarks