Logo 
Search:

C++ Programming FAQ

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

Inserting an element into the stack using array in dfs (data file structure)

  Shared By: Adaliz Fischer    Date: Dec 20    Category: C++ Programming    Views: 3631

Answer:

PROCEDURE ADD(ITEM, STACK, N, TOP)
[Inserts ‘item’ into the ‘stack’ of maximum size ‘n’, top is the number of elements currently in ‘stack’.]

1. [Overflow ?]

if (TOP >= N)
write Stack is full.
return.

2. [Increment top]

top <-- top + 1

3. [Insert Element]

stack [top] <-- item.

4. [FINISH]
return.

Share: 
 



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


Tagged: