Stack Operations | Data Structure MCQs

1.

In a stack, if a user tries to remove an element from empty stack it is called ______

   A.) Empty collection
   B.) Underflow
   C.) Overflow
   D.) Garbage Collection

Answer: Option 'B'

Underflow

2.

The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?

   A.) 350
   B.) 150
   C.) 450
   D.) 550

Answer: Option 'A'

350

3.

The postfix form of A*B+C/D is?

   A.) *AB/CD+
   B.) AB*CD/+
   C.) A*BC+/D
   D.) ABCD+/*

Answer: Option 'B'

AB*CD/+

4.

Assume that the operators +,-, X are left associative and ^ is right associative.
The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix expression a + b X c – d ^ e ^ f is

   A.) abc X+ def ^^ –
   B.) ab+c Xd – e ^f^
   C.) abc X+ de^f^ –
   D.) -+aXbc^ ^def

Answer: Option 'A'

abc X+ def ^^ –

5.

Convert the following Infix expression to Postfix form using a stack
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.

   A.) xyz*+pq*r+s*+
   B.) xyz*+pq*r+s+*
   C.) xyz+*pq*r+s*+
   D.) None of the mentioned

Answer: Option 'A'

xyz*+pq*r+s*+

6.

If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is the order of removal?

   A.) ABCD
   B.) DCAB
   C.) DCBA
   D.) ABDC

Answer: Option 'C'

DCBA

7.

If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is the order of removal?

   A.) ABCD
   B.) DCBA
   C.) DCAB
   D.) ABDC

Answer: Option 'B'

DCBA

8.

Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack are

   A.) 1
   B.) 2
   C.) 3
   D.) 4

Answer: Option 'A'

1

9.

The type of expression in which operator succeeds its operands is?

   A.) Infix Expression
   B.) Prefix Expression
   C.) Postfix Expression
   D.) None of the mentioned

Answer: Option 'C'

Postfix Expression

10.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(())) are:

   A.) 1
   B.) 2
   C.) 3
   D.) 4 or more

Answer: Option 'C'

Applying the postfix expression evaluation.

11.

Which of the following is not an inherent application of stack?

   A.) Reversing a string
   B.) Job scheduling
   C.) Evaluation of postfix expression
   D.) Implementation of recursion

Answer: Option 'A'

Reversing a string

12.

Process of inserting an element in stack is called ___________

   A.) Create
   B.) Push
   C.) Evaluation
   D.) Pop

Answer: Option 'B'

Push
Self Explanatory.

13.

Pushing an element into stack already having five elements and stack size of 5 , then stack becomes

   A.) Crash
   B.) Overflow
   C.) User flow
   D.) Underflow

Answer: Option 'B'

Overflow

14.

Entries in a stack are “ordered”. What is the meaning of this statement?

   A.) A collection of stacks is sortable.
   B.) Stack entries may be compared with the ‘<‘ operation.
   C.) The entries are stored in a linked list.
   D.) There is a Sequential entry that is one by one.

Answer: Option 'D'

There is a Sequential entry that is one by one.

15.

Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation.
The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?

   A.) 1
   B.) 2
   C.) 3
   D.) 4

Answer: Option 'D'

4

Stack Operations | Data Structure MCQs Download Pdf