Author: Stan Eisenstat
Subject: Re: [Cs223] remD
Date: Wednesday, 25 Mar 2020, 17:19:16
> Message Posted By: Unknown > > Hi, for remD, > > do we need to move the last element in the Tail linked list to the end of > the Head linked list each time when we call remD? > > Or do we only need to do that when the Head linked list is empty? As stated in the specification: To remove an item from the head of the Deque, pop it off the top of the H stack (but if the H stack is empty, first move items one at a time from the top of the T stack to the top of the H stack until the T stack is empty). Thus means that when (and only when) the H stack is empty but the T stack is not, both remD() and headD() should start by repeatedly moving the top of the T stack to the top of the H stack until the T stack is empty. They should never move the last element of the T stack unless it is the only one. --Stan-PREV INDEX NEXT