Send to a Friend

DeloreanLover's avatar

Is there a good way to determine if a stack is a palindrome?

Asked by DeloreanLover (5points) December 7th, 2010 from iPhone

I’ve already written a solution that first reverses one of the stacks and then directly compares each element on the original stack with that reversed stack. The time complexity of this operation is high, however. I’m wondering if there’s a way to do this more efficiently…namely, if I can write a method with lower time complexity, given that stacks do not natively “know” their length and such a computation would require a linear time operation.

Thanks…a lot! I’m writing an advanced simulation and this could really help me improve my rendering time…

Using Fluther

or

Using Email

Separate multiple emails with commas.
We’ll only use these emails for this message.