Author: Stan Eisenstat
Subject: Re: [Cs223] 3 Deque Limit
Date: Thursday, 02 Apr 2020, 08:17:02
> Message Posted By: Unknown
>
> I've gotten my code working using unlimited queues, where 2 new ones are
> made per recursive call, but I'm having a really hard time translating
> that into a solution that only uses 2 stacks and 1 queue. I'm trying to
> use tip #4 about using partially full stacks as empty ones (and keeping
> track of how many items you push onto them), but that only makes sense to
> me if you limit yourself to 3 stacks and 0 queues. The 1 queue is messing
> things up because it keeps reversing orders when moving items onto it from
> a stack, which messes up stable sorting. Do you have any suggestions on
> how I should approach this?
You can always reverse the order of the elements on a
queue by copying them to a stack and then back again.
--Stan-
PREV
INDEX
NEXT