Logo 
Search:

C++ Programming FAQ

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

Write an algorithm for Pushing a Node at the end of queue using Singly Linked List in dfs.

  Shared By: Redmond Fischer    Date: Dec 12    Category: C++ Programming    Views: 1396

Answer:

PROCEDURE PUSH_QUEUE(TOP)
[Where the starting pointer head has been caught in pointer ‘TOP’]

1. [Traversing to end of queue]

while (LINK(TOP) !=0)
TOP <-- LINK (TOP).

2. [Allocating the memory for new node & pushing it into queue]

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

3. [FINISH]
return.

Share: 
 


Related Topics:

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


Tagged: