• Data Structure Reference

• Other Reference

# Data Structure MCQ - Stack

This section focuses on the "Stack" of the Data Structure. These Multiple Choice Questions (mcq) should be practiced to improve the Data Structure skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. Which one of the following is an application of Stack Data Structure?

A. Managing function calls
B. The stock span problem
C. Arithmetic expression evaluation
D. All of the above

2. Process of inserting an element in stack is called ____________.

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

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

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

4.Which of the following is true about linked list implementation of stack?

A. In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end.
B. In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning.
C. Both of the above
D. None of the above

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

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

6. Consider the following pseudocode that uses a stack. What is output for input "letsfindc"?

```
declare a stack of characters
while ( there are more characters in the word to read )
{
push the character on the stack
}
while ( the stack is not empty )
{
pop a character off the stack
write the character to the screen
}
```

A. letsfindcletsfindc
B. cdnifstel
C. letsfindc
D. cdnifstelcdnifstel

7.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

8. The prefix form of A-B/ (C * D ⋀ E) is?

A. -/*⋀ACBDE
B. -ABCD*⋀DE
C. -A/B*C⋀DE
D. -A/BC*⋀DE

9.Following is an incorrect pseudocode for the algorithm which is supposed to determine whether a sequence of parentheses is balanced: Which of these unbalanced sequences does the above code think is balanced?

```
declare a character stack
while ( more input is available)
{
if ( the character is a '(' )
push it on the stack
else if ( the character is a ')' and the stack is not empty )
pop a character off the stack
else
print "unbalanced" and exit
}
print "balanced"
```

A. ((())
B. ())(()
C. (()()))
D. (()))()

10.What is the value of the postfix expression 6 3 2 4 + – *:

A. Something between -5 and -15
B. Something between 5 and -5
C. Something between 5 and 15
D. Something between 15 and 100

11. Process of removing an element from stack is called __________

A. Create
B. Push
C. Evaluation
D. Pod

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

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

13. Which of the following applications may use a stack?

A. A parentheses balancing program
B. Tracking of local variables at run time
C. Compiler Syntax Analyzer
D. All of the mentioned

14.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

15.Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order).
The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?

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

16. The data structure required to check whether an expression contains balanced parenthesis is?

A. Stack
B. Queue
C. Array
D. Tree

17. 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

18. What data structure would you mostly likely see in a non recursive implementation of a recursive algorithm?

B. Stack
C. Queue
D. Tree

19.The process of accessing data stored in a serial access memory is similar to manipulating data on a ________

A. Heap
B. Binary Tree
C. Array
D. Stack

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

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

21. Which data structure is needed to convert infix notation to postfix notation?

A. Branch
B. Tree
C. Queue
D. Stack

22. The prefix form of A-B/ (C * D ^ E) is?

A. -/*^ACBDE
B. -ABCD*^DE
C. -A/B*C^DE
D. -A/BC*^DE

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

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

24.What is the result of the following operation
Top (Push (S, X))

A. X
B. Null
C. S
D. None of the mentioned

25.The prefix form of an infix expression p + q – r * t is?

A. + pq – *rt
B. – +pqr * t
C. – +pq * rt
D. – + * pqrt

Also Check :

Discussion