Friday, 8 February 2013


Consider the following pseudocode:

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 )
write the stack's top character to the screen
pop a character off the stack

What is written to the screen for the input "carpets"?

A. serc
B. carpets
C. steprac
D. ccaarrppeettss
Join me on Facebook