Procedure CRETE(TEMPHEAD)
[This Procedure Create the Doubly linked list TEMPHEAD is the pointer variable which point to the first element of the list and LPTR and RPTR is the pointer field of the NODE which points the Previous and new Node of the list respectively.]
1. [Repeat thru step]
Repeat while choice! = ‘n’
2. [Allocate the new Node]

3. [Set field of new Node]
INFO (NEW) = X
LPTR (NEW) = RPTR (RPTR) = NULL
4. [Insert the element]
RPTR (TEMPHEAD) = NEW
LPTR (RPTR (TEMPHEAD)) = TEMPHEAD
TEMPHEAD = RPTR (TEMPHEAD)
5. [Read the Choice]
Read (choice)
6. [Finished]
No comments:
Post a Comment