Function to delete an element from the beginning of a doubly link list
Answers
Answered by
0
An element from the beginning of the list can be deleted by performing the following steps:
Assign the value of head (address of the first element of the list) to a temporary variable (say temp)
There are two further cases:
If there is only one element in the existing list, both head and tail are set to NULL.
If there is more than one element in the list then
Assign NULL to the prev pointer field of the second node.
Assign the address of the second node to head.
Deallocate the memory occupied by the node pointed to by temp.
C Code
.cf { font-family: Lucida Console; font-size: 9pt; color: black; background: white; }
.cl { margin: 0px; }
.cb1 { color: green; }
.cb2 { color: blue; }
.cb3 { color: maroon; }
Attachments:
Similar questions