Author: Stan Eisenstat
Subject: Re: [Cs223] Why would the value stored in deque be char*
Date: Wednesday, 18 Mar 2020, 17:30:03
> Message Posted By: Unknown
>
> Hi, I am just a little confused why the value stored in deque is char*
> instead of just char. My confusion is: I thought we could implement Qsort
> by pushing/adding each char of the string returned by getline to ADT and
> sort them by recursion (each time create three new deques, one for less
> than pivot, one for pivot, one for more than pivot). So I am confused why
> the value stored is a pointer to a string.
As stated in the specification, Qsort
... reads lines from the files specified; removes their trailing newlines if
any; sorts them in ascending order using quickSort; and writes the sorted
lines to the standard output, each followed by a newline. ...
It uses strcmp() or strncmp() to compare pairs of lines
when sorting. The two stacks and a queue are used to
hold the pointers to the lines as they are sorted.
--Stan-
PREV
INDEX
NEXT