Contents

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)

c

Explanation: The time complexity of reversing a stack is mathematically found to be O (N) where N is the input.


What will be the word obtained if the word “abbcabb” is reversed using a stack?
a) bbabbca                          
b) abbcabb
c) bbacbba                           
d) bbacabb

c

Explanation: The string “abbcabb” is pushed on to the stack. If the characters are popped one by one, the word obtained will be bbacbba.


How many stacks are required for reversing a word algorithm?
a) one    
b) two    
c) three  
d) four

a

Explanation: Only 1 stack is required for reversing a word using stack. In that stack, push and pop operations are carried out.