PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs223] Assuming the value of *D does not change
Date: Sunday, 29 Mar 2020, 14:29:29

    > Message Posted By: Unknown
    >
    > The homework assignment states:
    >    Hwk4/Deque.o has a MOVING_DEQUES mode where it
    >    moves the block of storage (if any) to which the
    >    Deque variable points (which changes *D) on every call.  When this mode
    >    is used you cannot assume that the value of *D does not change when
    >    calling isEmptyD(), addD(), remD(), headD(), pushD(), popD(), or
    >    topD().
    >
    > Though we are not supposed to assume the value of *D doesn't change, I'm
    > confused as to how making that assumption would even change the way we
    > approach the problem and how it might change our code.

Let LINES be the name of the Deque variable that holds
the stack or queue of lines, and suppose that you pass
LINES (and not &LINES) to your quickSort as the argument
LINES_ARG.  Within quickSort you pass &LINES_ARG to the
Deque functions, as is done in Hwk4/example.c.  If the
head of the Deque never moves, when you return to main()
LINES will point to the sorted Deque.  But if the value
of LINES_ARG had changed, how would LINES have gotten
the new value?

--Stan-
PREV INDEX NEXT