By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

stacks...

P: 6
hi, can anyone give me the different stack functions...our teacher just gave us the bare bones, what the different functions do...but no sample code...thank you
Oct 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: 43
hi, can anyone give me the different stack functions...our teacher just gave us the bare bones, what the different functions do...but no sample code...thank you
hi..
do you need the functions those can be done on stack or else the implementation of stack??

any way :-
Functions on stack are:
1. Push - to add element into stack
2. Pop - to remove TOP element from stack (FILO order)
3. IsFull -to check whether stack is full
4. IsEmpty - to check whether stack is empty.
(i think 3,4 are proper stack functions)

Implementation of stack:
(place where we can implement stack)
1. When function calll occurs (operands and controls are stored to stack)
2. for infix ,postfix notations..
3. all the places when you need to serve the last come first serve basis..
Oct 4 '06 #2

100+
P: 144
hi, can anyone give me the different stack functions...our teacher just gave us the bare bones, what the different functions do...but no sample code...thank you
Stacks are pretty simple and most only have 3 or 4 functions.

Expand|Select|Wrap|Line Numbers
  1.  
  2. // These functions assume a stack that stores values of type int
  3.  
  4. int empty();  // Tests if the stack is empty
  5.  
  6. int peek(); // Returns the value on the top of the stack, but doesn't removei it.
  7.  
  8. int pop(); // Removes the value on the top of the stack and returns it
  9.  
  10. void push(int value);  // Pushes a value onto the top of the stack
  11.  
  12.  
Oct 4 '06 #3

P: 6
ok thanks for the replies but that's not what i needed, our teacher gave us the functions but not what's in those functions, and it should be for char not int
Oct 5 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.