Given a stack S, need to sort the stack using only Push, Pop, Top, IsEmpty, IsFull.
Looking for most simple solution.
Edited: Removed in place condition. Can’t use another stack or queue.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It can be done…
Ok: sorted, ahem, “in-place” with only the listed ops, didn’t need Top() or IsFull() or another stack or data structure other than the call frames. (Presumably the whole point of the
homeworkproblem was to require a recursive solution.)Ruby