Presentation is loading. Please wait.

Presentation is loading. Please wait.

One implementation of the LIST ADT Insert new node before current and new node becomes current (assume new node created) node newNode = new node; head.

Similar presentations


Presentation on theme: "One implementation of the LIST ADT Insert new node before current and new node becomes current (assume new node created) node newNode = new node; head."— Presentation transcript:

1 One implementation of the LIST ADT Insert new node before current and new node becomes current (assume new node created) node newNode = new node; head current

2 One implementation of the LIST ADT head current prev = head; while (prev->next != current) prev = prev->next; prev

3 One implementation of the LIST ADT head current prev = head; while (prev->next != current) prev = prev->next; prev

4 One implementation of the LIST ADT head current node newNode = new node; prev->next = newNode; prev newNode

5 One implementation of the LIST ADT head current node newNode = new node; prev->next = newNode; newNode->next = current; prev newNode

6 One implementation of the LIST ADT head current node newNode = new node; prev->next = newNode; newNode->next = current; current = newNode; prev newNode

7 One more implementation of the LIST ADT Circular single linked list tail Start function. current = tail->link;

8 One more implementation of the LIST ADT Doubly linked list head current Insert new node before current and new node becomes current (assume new node created) node newNode = new node;

9 One more implementation of the LIST ADT Doubly linked list head current newNode->prev=current->prev; newNode

10 One more implementation of the LIST ADT Doubly linked list head current newNode->prev=current->prev; newNode->next=current; newNode

11 One more implementation of the LIST ADT Doubly linked list head current newNode->prev=current->prev; newNode->next=current; newNode->prev->next = newNode; newNode

12 One more implementation of the LIST ADT Doubly linked list head current newNode->prev=current->prev; newNode->next=current; newNode->prev->next = newNode; current->prev = newNode; newNode

13 One more implementation of the LIST ADT Doubly linked list head current newNode->prev=current->prev; newNode->next=current; newNode->prev->next = newNode; current->prev = newNode; current = newNode; newNode


Download ppt "One implementation of the LIST ADT Insert new node before current and new node becomes current (assume new node created) node newNode = new node; head."

Similar presentations


Ads by Google