0% found this document useful (0 votes)
67 views2 pages

DSA Chapter-4 Stack Assignment

This document contains a data structures and algorithms assignment on stacks. It has 5 questions: 1. Name the data structure used in recursion and give two applications of stacks. 2. Provide the output of two code segments that perform stack operations and explain the steps. 3. Convert an infix expression to postfix and show the steps to evaluate the postfix expression using a stack. 4. Write a C function to reverse a string using a stack without defining stack functions. 5. Write a C function to check if a string is a palindrome using a stack without stack functions.

Uploaded by

OM PATIL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views2 pages

DSA Chapter-4 Stack Assignment

This document contains a data structures and algorithms assignment on stacks. It has 5 questions: 1. Name the data structure used in recursion and give two applications of stacks. 2. Provide the output of two code segments that perform stack operations and explain the steps. 3. Convert an infix expression to postfix and show the steps to evaluate the postfix expression using a stack. 4. Write a C function to reverse a string using a stack without defining stack functions. 5. Write a C function to check if a string is a palindrome using a stack without stack functions.

Uploaded by

OM PATIL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

P.D.E.

A’s
Prof. Ramkrishna More Arts, Commerce and Science College,
Akurdi, Pune-44
S.Y.B.Sc.(Comp.Sci.) 2022-23
Subject: (CS-231) : Data Structures and Algorithms – I
Assignment-3
Chapter 4 : Stack

Q.1] Attempt the following : [1 Marks]


1. Name the data structure used in recursion.
2. Write any two applications of stack.
3. Convert the following infix expression to postfix form
a) ( A * B * C) / ( ( F * C ) – D)
b) P – Q^R + S * T - U

Q.2] Attempt the following : [4 or 3 Marks]

1. Give the output of the following code 2. Give the output of the following
segment : code :
void fun (int n) { int i = 1, x, y, z ;
{ initstack ( ) ;
struct stack s ; while ( i < 5)
initstack(&s); {
while (n > 0) push (i * 2) ; i = i + 1;
{ }
push (&s, n%2); x = pop ( ) ;
n = n/2; y = pop ( ) ;
} Push ( i*i ) ;
while (! isempty (&s)) z = POP ( ) ;
printf (“%d”, pop (&s)); push (x + y) ;
} push (x + z) ;
The call to the function is fun (10), also while (! stackempty ( ) )
explain the steps of the output. printf (“\n %d”, pop ( ) ) ;
}
Also explain the steps of the output.
3. Consider the given infix expression u * v + z/w. Write its postfix expression. Also show
steps to evaluate the postfix expression using stack.
Given : u = 3, v = 1, z = 4, w = 2.
4. Write a ‘C’ function to reverse a string using stack (Do not define any stack functions).
5. Write a ‘C’ function to check if a string is a palindrome using stack. (Do not write stack
functions).

Mr. S. G. Lakhdive
P.D.E.A’s
Prof. Ramkrishna More Arts, Commerce and Science College,
Akurdi, Pune-44
S.Y.B.Sc.(Comp.Sci.) 2022-23
Subject: (CS-231) : Data Structures and Algorithms – I
Assignment-3
Chapter 4 : Stack

You might also like