Stack
Data Structures 15CS33
1. Define
stack and List and implement basic operations in stack using C (push, pop,
isempty, isfull). Implement reversing a string using stack (array
implementation) in C.
(December 2007)
(June 2009)
(June 2010)
(December 2010)
(December 2010)
(December 2011)
(December 2012)
(December 2013)
(December 2014)
(December 2015)
(12 marks)
2.
Write
a C program to implement multiple stacks using single array
(December 2007)
(12 marks)
3.
Write
short notes on Applications of stacks
(December 2007)
(5 marks)
4.
Write
an algorithm to evaluate postfix expression. Trace the same algorithm with
stack contents for the following expression A B C + * C B A - + * with A=1, B=2, C=3.
(June 2009)
(December 2009)
(10 marks)
5.
Convert
each of the following expression to its postfix and prefix forms
a)
( A + B ) * C –
D $ E * F
b)
A - B / C * D $
E
c)
( A + B ) * ( C
+ D – E ) * F
d)
( ( ( A + ( B -
C ) * D ) ^ E ) + F )
e)
( a + b ) * d + e
/ ( f + a * d ) + c
f)
( ( a / ( b - c +
d ) ) * ( e - a ) * c )
g)
a / b – c + d * e
– a * c
(June 2009)
(December 2012)
(December 2013)
(12 marks)
6.
What
is stack? Indicate how stack is represented in C.
(December 2009)
(5 marks)
7.
Show
using the tabular column how the expression (a+b)*c is converted to a postfix
expression according to the infix to postfix coversion algorithm
(June 2010)
(5 marks)
8. Write
the algorithm to evaluate a valid postfix expression and hence evaluate the
postfix expression.
6 2 3 + - 3 8 2
/ + *
1 2 3 + * 3 2 1
- + *
A B + C D E - * / for A=5 B=6 C=4 D=3 E=7
6 2 3 + 3 8 2 / +
* 2 $ 3 +
All
the operands are single digit positive integers and operators are binary in
nature.
(June 2010)
(December 2010)
(December 2011)
(June 2013)
(June 2015)
(December 2015)
(10 marks)
9.
Write
a algorithm and function to convert a valid infix expression to postfix
expression. Demonstrate the same function with example.(using stack)
a)
( a * b ) + c /
d
b)
( ( ( a / b ) –
c ) + ( d * e ) ) - (a * c)
c)
a * ( b + c ) * d
d)
A $ B * C – D + E
/ F / ( G + H )
e)
A – B / ( C * D $
E )
(June 2011)
(June 2012)
(June 2014)
(December 2015)
(12 marks)
10.
Write
a C program to implement a two primitive operations on stack using dynamic
memory allocation.
(June 2012)
(8 marks)
11.
What
is system stack? How the control is transferred to or from the function with
the help of activation records.
(December 2012)
(6 marks)
12.
Convert
the infix expression to postfix expression and evaluate the same.
a / b – c + d * e – a * c for a=6 b=3 c=1 d=2 e=4
(June 2013)
(6 marks)
13.
How
multiple stacks implemented using one dimensional array? Explain with suitable
example.
(June 2014)
(4 marks)