Saturday, August 27, 2011

Doubly Linked Lists

To insert a node to the left of node M :

get_node(N)
N.right_link := M
N.left_link := M.left_link
M.left_link.right_link := N
M.left_link := N

To delete a node N :

N.left_link.right_link := N.right_link
N.right_link.left_link := N.left_link

No comments:

Post a Comment