Author: Stan Eisenstat
Subject: Re: [Cs223] addD()
Date: Wednesday, 18 Mar 2020, 06:59:06
> Message Posted By: Unknown > > Why might the value of *d change as a result of addD()? Don't we just > allocate a new Node *e, fill in the values for *e, and then update the > value of *d->T? The value of **d changes, but shouldn't the value of *d > remain the same? That depends on how the Deque ADT is implemented. What you describe above is a headed, two-headless-stack version where the storage for the head of the Deque (which contains the stack pointers) is allocated by createD() and its address never changes. But you could also implement the Deque ADT with the convention that an empty Deque is represented by the NULL pointer and storage for the head of the Deque is allocated when an item is added to an empty Deque and freed when removing the last item, leaving an empty Deque. In this case addD() would change the value of *d whenever adding an item to an empty Deque. --Stan-PREV INDEX NEXT