Logo 
Search:

C++ Programming FAQ

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

Write an algorithm for Creating Singly Linked List in dfs (data file structure).

  Shared By: Francesca Hughes    Date: Nov 10    Category: C++ Programming    Views: 9084

Answer:

PROCEDURE CREATE(T)
[Where ‘head’ pointer has been caught in pointer ‘T’]

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

Call GETNODE (T)
DATA (T) ? ‘xyz’
LINK (T) ? 0.

2. [Checking the value & calling the function recursiverly]

if(DATA (T) <= 0)
return
else
Call CREATE (LINK(T))

3. [FINISH]
return.

Share: 
 


Related Topics:

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


Tagged: