Logo 
Search:

C++ Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C++ ProgrammingRSS Feeds

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

  Shared By: Lauren Hughes    Date: Sep 28    Category: C++ Programming    Views: 10299

Answer:

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.

Share: 
 


Related Topics:

Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: