Monday, 24 July 2017
Subscribe to:
Post Comments (Atom)
Step 1: Create the NEW_NODE using createnode()
NEW_NODE = createnode();
Step 2: If the linked list is empthy (START == NULL)
START = NEW_NODE
Step 3: If the linked list is not empthy
NEW_NODE -> NEXT =START
START -> PREV = NEW_NODE
START = NEW_NODE
Step 4 : EXIT
Step 1: Create the NEW_NODE using createnode()
NEW_NODE = createnode();
Step 2: If the linked list is empthy (START == NULL)
START = NEW_NODE
Step 3: If the linked list is not empthy
PTR = START
while(PTR -> NEXT != NULL)
{
PTR = PTR -> NEXT
}
PTR -> NEXT = NEW_NODE
NEW_NODE ->PREV = PTR
Step 4 : EXIT
Step 1: Create the NEW_NODE using createnode()
NEW_NODE = createnode();
Step 2: Enter the position where u want to insert the node & count total no of node
totalnode = countnode(START)
Step 3: Ensure that enter postion is in between first and last node
IF( POS > 1 && POS < totalnode)
Step 4: Store the starting address in PTR & move the PTR pointer upto specified position .
PTR = START;
MOVE = 1;
while(MOVE< POS-1)
{
PTR = PTR->NEXT;
MOVE++;
}
NEW_NODE -> NEXT = PTR -> NEXT;
NEW_NODE -> PREV = PTR
PTR -> NEXT -> PREV = NEW_NODE
PTR -> NEXT = NEW_NODE
[END OF IF]
ELSE
Write "Position is invalid "
Step 5 : EXIT
0 Comment to "Doubly Linked List | Insertion Algorithm | Data Structures & Algorithm"
Post a Comment