Write an Algorithm for Creating Circular Doubly Linked List in Dfs

1
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) <-- S RIGHT (T) <-- 0 RIGHT (S) <-- T S <-- T 2. [Checking the value and calling the function recursively] if (DATA (T) <= 0) RIGHT(LEFT (T)) <-- HEAD LEFT (HEAD) <-- LEFT (T) P <-- LEFT (T) CALL REMOVE NODE (T) return else Call CREATE_CD (T). 3. [FINISH] return.

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

Page 1: 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.