Presentation is loading. Please wait.

Presentation is loading. Please wait.

Doubly linked lists Idea: same as singly linked list, but each node also points to the previous: Can optionally also have a pointer to the tail, so we.

Similar presentations


Presentation on theme: "Doubly linked lists Idea: same as singly linked list, but each node also points to the previous: Can optionally also have a pointer to the tail, so we."— Presentation transcript:

1 Doubly linked lists Idea: same as singly linked list, but each node also points to the previous: Can optionally also have a pointer to the tail, so we can start scanning from the end, and make appending easier Also helps with binary search

2 Inserting into a DLL Find node before the new one, nextNode
Set newNode.prev = nextNode.prev Set newNode.prev.next = newNode Set newNode.next = nextNode Set nextNode.prev = newNode

3 Queues Main idea: similar to a stack, but use “First in, first out” methodology ”Push” and “Pop” now become “enqueue” and “dequeue” Primary stipulation: dequeue returns the least-recently enqueued item


Download ppt "Doubly linked lists Idea: same as singly linked list, but each node also points to the previous: Can optionally also have a pointer to the tail, so we."

Similar presentations


Ads by Google