Logo 
Search:

C++ Programming FAQ

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

Write an algorithm for Creating Queue(fifo) using Singly Linked List in dfs.

  Shared By: Bittan Fischer    Date: Dec 04    Category: C++ Programming    Views: 5233

Answer:

PROCEDURE CREATE_QUEUE(TOP)
[Where ‘head’ pointer has been caught in pointer ‘TOP’ and function is void]

1. [Allocating memory for new node & having the value from user]

Call GETNODE (TOP)
DATA (TOP) <-- ‘xyz’
LINK (TOP) <-- 0.

2. [Checking the value of last node & calling the function recursiverly]

if(DATA (TOP) <= 0)
return
else
Call CREATE_QUEUE (LINK(TOP))

3. [FINISH]
return.

Share: 
 


Related Topics:

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


Tagged: