doublyLinkedLists

doublyLinkedLists - Doubly Linked List Simple linked lists...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Doubly Linked List Simple linked lists only allow making search from the beginning to end. Doubly linked lists allow searches in both directions (while keeping a single pointer) Each node contains two pointers, one to the next node, one to the preceding node. struct dllNode { int data; struct dllNode *left; struct dllNode *right; } Node Structure: Advantage: insertion and deletion can be easily done with a single pointer. left data right pHead
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Deletion pCur->left->right = pCur->right; pCur->right->left = pCur->left; (Assuming pCur->left and pCur->right are not NULL) pCur pHead
Background image of page 2
Insertion pNew->left = pCur; pNew->right = pCur->right; pCur->right->left = pNew; pCur->right = pNew; Disadvantage of Doubly Linked Lists: extra space for extra link fields maintaining extra link during insertion and deletion pHead pCur pNew
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Array Implementation of Linked Lists The idea is to begin with a large array and regard the array as our allocation of unused space. We then set up our own
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

doublyLinkedLists - Doubly Linked List Simple linked lists...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online