An Algorithmist
Brief explanation and solutions to coding problems I solved / learned.
Wednesday, June 19, 2013
Reversing the stack contents
Algorithm:
Pop all the elements of stack till it becomes empty.
After each recursive call, push the popped element at the bottom of stack.
Time Complexity:
O(n^2)
Space Complexity:
O(n): For recursion stack.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment