Lecture On D.S
Lecture On D.S
Lecture On D.S
head
head = NULL;
head
current
x
a x b
current
a b c d
Empty List
header
pHead
a b c
Advantages:
Convenient to traverse the list backwards.
Simplifies insertion and deletion because you no longer
have to refer to the previous node.
Disadvantage:
Increase in space requirements.
17 M. H. Bhuyan Lec 20, 21, 22 and 23
Deletion
head current
oldNode = current;
oldNode->prev->next = oldNode->next;
oldNode->next->prev = oldNode->prev;
delete oldNode;
current = head;
Size
Increasing the size of a resizable array can waste storage and
time
Storage requirements
Array-based implementations require less memory than a
pointer-based ones
Access time
Array-based: constant access time
Pointer-based: the time to access the ith node depends on i
Insertion and deletions
Array-based: require shifting of data
Pointer-based: require a list traversal