Question

(30 points) Prove or disprove the following statement: There exists a comparison-based sorting algorithm whose running time i
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Explanation:- The above statement can not be proved,Because,any deterministic comparison-based sorting algorithm must perform Ω(n log n) comparisons to sort n elements in the worst case. Specifically, for any deterministic comparison-based sorting algorithm A, for all n ≥ 2 there exists an input I of size n such that A makes at least log2 (n!) = Ω(n log n) comparisons to sort I.

For half of the n! inputs:-  h ≥ log(n!/2) = logn! - log2 ≥ n*logn - n*loge – 1 = Ω(nlogn)

For Fraction of 1/n inputs:-  log(n!/n) = logn! - logn ≥ n*logn - n*loge – logn = Ω(nlogn)

Similarly,

For Fraction of 1/2n inputs:-

log(n!/2n) = logn! – log2n

= logn! – n  ≥ n*logn - n*loge – n = Ω(nlogn)

From all the above statements ,we can conclude that there exists comparison based algorithm whose running time is Ω(nlogn) but not linear for at least .a fraction of 1/2n of the n! possible input instances of length n.

Proof of Comparison based sorting algorithm:-

let S be the set of these inputs that are consistent with the answers to all comparisons made so far (so, initially, |S| = n!). We can think of a new comparison as splitting S into two groups: those inputs for which the answer would be YES and those for which the answer would be NO. Now, suppose an adversary always gives the answer to each comparison corresponding to the larger group. Then, each comparison will cut down the size of S by at most a factor of 2. Since S initially has size n!, and by construction, the algorithm at the end must have reduced |S| down to 1 in order to know which output to produce, the algorithm must make at least log2 (n!) comparisons before it can halt. We can then solve:

log2 (n!) = log2 (n) + log2 (n − 1) + ... + log2 (2) = Ω(n log n).

Add a comment
Know the answer?
Add Answer to:
(30 points) Prove or disprove the following statement: There exists a comparison-based sorting algorithm whose running...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT