You are on page 1of 1

DSA Quiz 2

Name & Matrix No & Section: 12 Jan 2023


Given the following program, answer question a and b

// Program A
Stack aStack;
aStack.push(‘a’);
aStack.push(‘b’);
aStack.pop();
aStack.push(‘c’);
aStack.pop();
aStack.push(‘d’);
a. If a program is executed on stack implementation array, draw the situation of stack after each
implementation in figure below.

Top

[4]
[3]
[2]
[1]
[0]
data data data data data data data

INITIAL STEP STEP STEP STEP STEP STEP


STEP 1 2 3 4 5 6

b. If the program is executed on stack implementation link list, draw the situation of stack after
each implementation in figure.

Top NULL

STEP 1 Top

STEP 2 Top

STEP 3 Top

STEP 4 Top

STEP 5 Top

STEP 6 Top

c. Convert the following infix expressions to prefix and postfix form by using the knowledge you
learn in this chapter.
I. a/b/c-(d+e)*f II. a-(b/c*d)

You might also like