Data Structure MCQ - Stack
Q1.Process of inserting an element in stack is called ____________
- Create
- Evaluation
- Pop
- Push
Answer:- (D).
Explanations :Push operation allows users to insert elements in the stack. If the stack is filled completely and trying to perform push operation stack – overflow can happen.
Explanations :Push operation allows users to insert elements in the stack. If the stack is filled completely and trying to perform push operation stack – overflow can happen.
- Pop
- Create
- Push
- Evaluated
Answer:- (A).
Explanations :Elements in the stack are removed using pop operation. Pop operation removes the top most element in the stack i.e. last entered element.
Explanations :Elements in the stack are removed using pop operation. Pop operation removes the top most element in the stack i.e. last entered element.
- Underflow
- User flow
- Overflow
- Crash
Answer:- (C).
Explanations :The stack is filled with 5 elements and pushing one more element causes a stack overflow. This results in overwriting memory, code and loss of unsaved work on the computer.
Explanations :The stack is filled with 5 elements and pushing one more element causes a stack overflow. This results in overwriting memory, code and loss of unsaved work on the computer.
- A collection of stacks is sortable
- The entries are stored in a linked list
- There is a Sequential entry that is one by one
- Stack entries may be compared with the ‘<‘ operation
Answer:- (C).
Explanations : In stack data structure, elements are added one by one using push operation. Stack follows LIFO Principle i.e. Last In First Out(LIFO).
Explanations : In stack data structure, elements are added one by one using push operation. Stack follows LIFO Principle i.e. Last In First Out(LIFO).
- 1
- 3
- 2
- 4 or more
Answer:- (C).
Explanations :In the entire parenthesis balancing method when the incoming token is a left parenthesis it is pushed into stack. A right parenthesis makes pop operation to delete the elements in stack till we get left parenthesis as top most element. 2 left parenthesis are pushed whereas one right parenthesis removes one of left parenthesis. 2 elements are there before right parenthesis which is the maximum number of elements in stack at run time.
Explanations :In the entire parenthesis balancing method when the incoming token is a left parenthesis it is pushed into stack. A right parenthesis makes pop operation to delete the elements in stack till we get left parenthesis as top most element. 2 left parenthesis are pushed whereas one right parenthesis removes one of left parenthesis. 2 elements are there before right parenthesis which is the maximum number of elements in stack at run time.
- AB+ CD*E – FG /**
- AB+ CD*E – FG /**
- AB + CDE * – * F *G /
- AB + CD* E – F **G
Answer:- (B).
Explanations :(((A+ B)*(C*D- E)*F) / G) is converted to postfix expression as
(AB+(*(C*D- E)*F )/ G)
(AB+CD*E-*F) / G
(AB+CD*E-*F * G/). Thus Postfix expression is AB+CD*E-*F*G/
Explanations :(((A+ B)*(C*D- E)*F) / G) is converted to postfix expression as
(AB+(*(C*D- E)*F )/ G)
(AB+CD*E-*F) / G
(AB+CD*E-*F * G/). Thus Postfix expression is AB+CD*E-*F*G/
- Stack
- Queue
- Tree
- Array
Answer:- (A).
void fun(int n) { Stack S; // Say it creates an empty stack S while (n > 0) { // This line pushes the value of n%2 to stack S push(&S, n%2); n = n/2; } // Run while Stack S is not empty while (!isEmpty(&S)) printf("%d ", pop(&S)); // pop an element from S and print it }
- Prints binary representation of n in reverse order
- Prints binary representation of n
- Prints the value of Logn
- Prints the value of Logn in reverse order
Answer:- (B).
- Managing function calls
- The stock span problem
- Arithmetic expression evaluation
- All of the above
Answer:- (D).
- Underflow
- Empty collection
- Overflow
- Garbage Collection
Answer:- (A).
Explanations :In a stack, if a user tries to remove an element from empty stack it is called Underflow.
Explanations :In a stack, if a user tries to remove an element from empty stack it is called Underflow.
Copyright © 2022 Shineskill Software Pvt. Ltd., All rights reserved.