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
View Answer
Ans : D
Explanation: No explanation.
2. Process of inserting an element in stack is called ____________.
A. Create
B. Push
C. Evaluation
D. Pop
View Answer
Ans : B
Explanation: Process of inserting an element in stack is called Push.
3. The postfix form of A*B+C/D is?
A. *AB/CD+
B. AB*CD/+
C. A*BC+/D
D. ABCD+/*
View Answer
Ans : B
Explanation: The postfix form of A*B+C/D is AB*CD/+.
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
View Answer
Ans : D
Explanation: To keep the Last In First Out order, a stack can be implemented using linked list in two ways: a) In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from beginning. b) In push operation, if new nodes are inserted at the end of linked list, then in pop operation, nodes must be removed from end.
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
View Answer
Ans : A
Explanation:In a stack, if a user tries to remove an element from empty stack it is called Underflow.
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 )
{
read a character
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
View Answer
Ans : B
Explanation: No explanation.
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
View Answer
Ans : D
Explanation: It means 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
View Answer
Ans : C
Explanation: The prefix form of A-B/ (C * D ⋀ E) is -A/B*C⋀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)
{
read a character
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. (()))()
View Answer
Ans : A
Explanation: At the end of while loop, we must check whether the stack is empty or not. For input ((()), the stack doesn't remain empty after the loop.
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
View Answer
Ans : D
Explanation:On solving the postfix expression the answer comes out to 18.
Also Check :
Discussion