PREV INDEX NEXT

Author: Unknown
Subject: Re: CPSC223 xQuick.pl
Date: Thursday, 02 Apr 2020, 21:10:37

I have corrected this issue by setting
int n = strncmp (...)
if (n > 0)
...
if (n < 0)
However, xQuick.pl says I am not using quicksort.
I hope you could kindly help me.

---------------
    > I saw your recent message about testing whether our code is actually
    > running quicksort. I pass all 15 test cases and the number of adds/pushes
    > I use is always <= 2#compares + n. However, for some inputs, when I run
    > xQuick.pl, it says I am not using quicksort. I have attached my code to
    > this email so that maybe you can give me more insight into why it is
    > saying what it does on xQuick.pl.

The problem is the sequence

  if (strncmp(...) > 0)
     ...
  else if (strncmp(...) <= 0)
     ...

which performs the comparison twice.  This inflates the
number of compares and thus the limit C*#compares + N on
the number of calls to pushdD() and addD(), making it
easier to satisfy.
PREV INDEX NEXT