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


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

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

View Answer


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

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

View Answer


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


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


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


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


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


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


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


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

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

View Answer


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

View Answer


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

View Answer


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

View Answer


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

View Answer


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

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

View Answer


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

View Answer


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

A. Linked List
B. Stack
C. Queue
D. Tree

View Answer


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

View Answer


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

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

View Answer


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

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

View Answer


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

View Answer


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

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

View Answer


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

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

View Answer


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

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

View Answer






Also Check :


Discussion



* You must be logged in to add comment.