suppose a word is reversed using stack algorithm. what will be the number of stacks required
Mohammed
Guys, does anyone know the answer?
get suppose a word is reversed using stack algorithm. what will be the number of stacks required from screen.
250+ TOP MCQs on Reverse a Word using Stack and Answers 2023
Data Structures & Algorithms Multiple Choice Questions on “Reverse a Word using Stack”. 1. Reversing a word using stack can be used to find if the given
Home » Data Structure Objective Questions » 250+ TOP MCQs on Reverse a Word using Stack and Answers
250+ TOP MCQs on Reverse a Word using Stack and Answers
Data Structures & Algorithms Multiple Choice Questions on “Reverse a Word using Stack”.
1. Reversing a word using stack can be used to find if the given word is a palindrome or not.
a) True b) False Answer: a
Clarification: This application of stack can also be used to find if the given word is a palindrome because, if the reversed is same as that of the original word, the given word is a palindrome.
2. Which is the most appropriate data structure for reversing a word?
a) queue b) stack c) tree d) graph Answer: b
Clarification: Stack is the most appropriate data structure for reversing a word because stack follows LIFO principle.
3. Operations required for reversing a word or a string using stack are push() and pop().
a) True b) False Answer: a
Clarification: Push operation inserts a character into the stack and pop operation pops the top of the stack.
4. What is the time complexity of reversing a word using stack algorithm?
a) O (N log N) b) O (N2) c) O (N) d) O (M log N) Answer: c
Clarification: The time complexity of reversing a stack is mathematically found to be O (N) where N is the input.
5. What will be the word obtained if the word “abbcabb” is reversed using a stack?
a) bbabbca b) abbcabb c) bbacbba d) bbacabb Answer: c
Clarification: The string “abbcabb” is pushed on to the stack. If the characters are popped one by one, the word obtained will be bbacbba.
6. How many stacks are required for reversing a word algorithm?
a) one b) two c) three d) four Answer: a
Clarification: Only 1 stack is required for reversing a word using stack. In that stack, push and pop operations are carried out.
7. What will be result if the given stack is popped?
a) pat b) tap c) atp d) apt Answer: b
Clarification: The word ‘pat’ is pushed on to the stack. When the characters of the stack are popped one by one, the word ‘tap’ is obtained.
8. What will be output if the following sequence of operations are executed?
Push(a,s); Push(b,s); Pop(b); Push(c,s); a) abc b) b c) ac d) acb Answer: b
Clarification: The element ‘b’ is popped out of the stack. Hence the output of the following sequence of operations will be ‘b’.
9. What are the set of functions that are to be executed to get the following output?
cat
a) push(c, s); push(a, s); push(t, s);
pop(s); pop(s); pop(s);
b) push(c,s); pop(s); push(a,s); pop(s);push(t,s);pop(s);
c) pop(c ); pop(a); pop(t);
d) push(c,s); push(a,s); pop(t);
Answer: b
Clarification: During push operation, the characters ‘c’, ’a’, ’t’ are inserted into the stack and popped immediately after push.
10. How will your stack look like if the word ‘java’ is pushed?
a) b) c) d) Answer: a
Clarification: When a character is pushed, it stays on the top of the stack. While popping, the word occurs in reverse order since stack follows LIFO principle.
11. Find the error (if any) in the following code snippet for pop operation.
void pop() //removing an element from a stack
{
printf(“%s”, stack[top++]);
} a) run time error
b) compile time error
c) pop operation is performed, but top moved in wrong direction
d) pop operation is performed properly
Answer: c
Clarification: The statement printf(“%s”, stack[top++]) does a pop, but top gets incremented which is not correct. The statement stack[top++] should be replaced with stack[top–] in order to pop an operand and maintain stack properly.
12. What will be the output of the following program?
main() {
char str[]="san foundry";
int len = strlen(str);
for(i=0;iint i;
push(str[i]); // pushes an element into stack
for(i=0;ipop(); //pops an element from the stack
} a) b) san foundry c) yrdnuof nas d) foundry nas Answer: c
Clarification: First, the string ‘san foundry’ is pushed one by one into the stack.
When it is popped, the output will be as ‘yrdnuof nas’.
---- >> Below Are The Related Posts Of Above Questions :::
------>>[MOST IMPORTANT]<<------250+ TOP MCQs on Stack Operations – 2 and Answers
250+ TOP MCQs on Stack Reversal using Recursion and Answers
250+ TOP MCQs on Stack Operations – 3 and Answers
What is the difference between a Stack and an Array?
250+ TOP MCQs on Stack using Array and Answers
250+ TOP MCQs on Stack and Answers
Difference between heap and stack?
250+ TOP MCQs on Stack using Linked List and Answers
250+ TOP MCQs on Stack Operations – 1 and Answers
250+ TOP MCQs on Word Processing Package and Answers
250+ TOP MCQs on Reverse Engineering and Answers
250+ TOP MCQs on Propositional and Directed Acyclic Word Graph and Answers
250+ TOP MCQs on Towers of Hanoi and Answers
250+ TOP MCQs on Stack Structure of 8086/8088 and Answers
250+ TOP MCQs on Infix to Prefix Conversion and Answers
स्रोत : engineeringinterviewquestions.com
What is the time complexity of reversing a word using stack algorithm?
Click here👆to get an answer to your question ✍️ What is the time complexity of reversing a word using stack algorithm?
Question
What is the time complexity of reversing a word using stack algorithm?
AO (N log N)
BO(N2 )
CO (N)
DO (M log N)
Medium Open in App Solution Verified by Toppr
Correct option is C)
Was this answer helpful?
0 0
How many stacks are required for reversing a word algorithm?
How many stacks are required for reversing a word algorithm? (a) one (b) two (c) three (d) four
How many stacks are required for reversing a word algorithm?
← Prev Question Next Question →
1 Answer
← Prev Question Next Question →
Find MCQs & Mock Test
JEE Main 2024 Test Series
NEET Test Series
Class 12 Chapterwise MCQ Test
Class 11 Chapterwise Practice Test
Class 10 Chapterwise MCQ Test
Class 9 Chapterwise MCQ Test
Class 8 Chapterwise MCQ Test
Class 7 Chapterwise MCQ Test
Guys, does anyone know the answer?