how many recursive calls will quicksort make in the worst case for a file
of N items?
Wrong newsgroup: there's no "quicksort" in the C language.
Try a different newsgroup, like alt.do.your.own .stupid.homewor k
or or alt.careers.in. sewer.maintenan ce.
>how many recursive calls will quicksort make in the worst case for a
>file of N items?
>
Wrong newsgroup: there's no "quicksort" in the C language.
Try a different newsgroup, like alt.do.your.own .stupid.homewor k
or or alt.careers.in. sewer.maintenan ce.
Hmm, you might have misinterpreted the question, there is nothing on job
seeking or DIY, let alone specific to waste drainage and its upkeep.
Anyway, to answer the OP (or at least, partly): If you do the worst case
scenario on a piece of paper for a set of, say, five elements, you should be
easily able to figure this one out.
Or ask your question elsewhere. GIYF: quicksort recurse depth
"zoro" <omarzahdan@nos pam.yahoo.comwr ote in message
news:f28a7b425b e86675af5f495ca d5945e5@localho st.talkaboutpro gramming.com...
: how many recursive calls will quicksort make in the worst case
: for a file of N items?
This depends on the implementation of the algorithm.
A naive implementation could have a worst case of N, but
a decent implementation (which qsort() should be in your
C library) will have a worst case of lg(N) recursions.
[ it is common for industrial strength implementations
to recurse on the smaller partition and iterate on
the larger one ]
On Nov 12, 4:04 pm, "Ivan Vecerina"
<_INVALID_use_w ebfo...@ivan.ve cerina.comwrote :
"zoro" <omarzah...@nos pam.yahoo.comwr ote in messagenews:f28 a7b425be86675af 5f495cad5945e5@ localhost.talka boutprogramming .com...
: how many recursive calls will quicksort make in the worst case
: for a file of N items?
This depends on the implementation of the algorithm.
A naive implementation could have a worst case of N, but
a decent implementation (which qsort() should be in your
C library) will have a worst case of lg(N) recursions.
While I see how you can limit the worst case _depth_ of recursion to
O(log N), the worst case _count_ of recursive calls is still O(N), no?
(The data arrangements that hit the worst cases for those two are
different, of course.)
I seem to recall a USENIX paper from 2000 or 2001 co-authored by Doug
McIlroy, in which the authors described a torture test for quicksort
which dynamically created a worst-case data arrangement for whatever
quicksort implementation it was given.
On Nov 12, 4:04 pm, "Ivan Vecerina"
<_INVALID_use_w ebfo...@ivan.ve cerina.comwrote :
"zoro" <omarzah...@nos pam.yahoo.comwr ote in messagenews:f28 a7b425be86675af 5f495cad5945e5@ localhost.talka boutprogramming .com...
: how many recursive calls will quicksort make in the worst case
: for a file of N items?
This depends on the implementation of the algorithm.
A naive implementation could have a worst case of N, but
a decent implementation (which qsort() should be in your
C library) will have a worst case of lg(N) recursions.
>
While I see how you can limit the worst case _depth_ of recursion to
O(log N), the worst case _count_ of recursive calls is still O(N), no?
(The data arrangements that hit the worst cases for those two are
different, of course.)
>
I seem to recall a USENIX paper from 2000 or 2001 co-authored by Doug
McIlroy, in which the authors described a torture test for quicksort
which dynamically created a worst-case data arrangement for whatever
quicksort implementation it was given.
>
On Nov 12, 4:04 pm, "Ivan Vecerina"
<_INVALID_use_w ebfo...@ivan.ve cerina.comwrote :
"zoro" <omarzah...@nos pam.yahoo.com>
wrote in
messagenews:f28 a7b425be86675af 5f495cad5945e5@ localhost.
talkaboutprogra mming.com...
: how many recursive calls will quicksort make in the worst case
: for a file of N items?
This depends on the implementation of the algorithm.
A naive implementation could have a worst case of N, but
a decent implementation (which qsort() should be in your
C library) will have a worst case of lg(N) recursions.
>
While I see how you can limit the worst case _depth_ of recursion to
O(log N), the worst case _count_ of recursive calls is still O(N), no?
You are correct about that
for the kinds recursion schemes that Ivan Vecerina suggested
as in q0sort and q1sort,
but "This depends on the implementation of the algorithm."
is still true, since the quicksort algorithm
can also be implemented nonrecursively, as in q2sort.
Comment