Consider the following pseudocode that uses a stack
# Declare a stack of characters
word = "example" # Replace with the word you want to read
char_stack = []
# While there are more characters in the word to read
for c in word:
char_stack.append(c) # Push the character on the stack
# While the stack is not empty
while char_stack:
c = char_stack.pop() # Pop a character off the stack
print(c, end='') # Write the character to the screen
What is output for input "geeksquiz"?
geeksquizgeeksquiz
ziuqskeeg
geeksquiz
ziuqskeegziuqskeeg
This question is part of this quiz :
Top MCQs on Stack Data Structure with Answers