PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs223] Restrictions on Strings
Date: Monday, 16 Mar 2020, 19:26:04


    > Message Posted By: Unknown
    >
    > The assignment says that Qsort may only use the strings returned by
    > getline(). Are we not allowed to initialize any other strings? For
    > example, to use remD, we have to pass in a string (which will be set to
    > the value removed), and this would have to be initialized beforehand. How
    > does this scenario relate to the rule?

You seem to be confusing a string pointer (which is just
a char*) with a string (which is a block of storage that
contains a sequence of characters followed by a null
character).

The char** argument to remD() is the address of a char*
variable to which is assigned the value of the string
pointer at the head/top of the Deque.  No new strings
(i.e., blocks of storage containing null-terminated
strings) need to be created.
=====

    > Another example: In our partition function, let's say we initialize a
    > string and set it equal to our pivot, which we will then use to compare
    > with the other elements. Are we not allowed to save the value of the
    > pivot?

Again, you setting a char* to the pivot string pointer,
which does not require creating a string.

--Stan-
PREV INDEX NEXT