Write an Algorithm for Creating Circular Doubly Linked List in Dfs

Post on 08-Mar-2015

21 views 0 download

Transcript of Write an Algorithm for Creating Circular Doubly Linked List in Dfs

Write an algorithm for Creating Circular Doubly Linked List in dfs.

PROCEDURE CREATE_CD(T)[Where pointer ‘HEAD’ has been caought in pointer ‘T’ and pointer ‘head’ and ‘p’ are global variables]

1. [Allocating the memory for the node and taking value from the user]

Call GETNODE (T)DATA (T) <-- ‘xyz’LEFT (T) <-- SRIGHT (T) <-- 0RIGHT (S) <-- TS <-- T

2. [Checking the value and calling the function recursively]

if (DATA (T) <= 0)RIGHT(LEFT (T)) <-- HEADLEFT (HEAD) <-- LEFT (T)P <-- LEFT (T)CALL REMOVE NODE (T)returnelseCall CREATE_CD (T).

3. [FINISH]return.