Question

Give an example input (6 elements) for quick sort which would result in worst case performance,...

Give an example input (6 elements) for quick sort which would result in worst case performance, (using the scheme of choosing the left-most element as the pivot).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The worst-case performance of quicksort can be achieved by a number of permutations of the input sequence. One such input sequence is when all the elements in the input sequence are of same value i.e say for our case it is [6, 6, 6, 6, 6, 6] or any other number with same value. This always gives the worst-case no matter what is the pivot because it has to go through all the elements and every step will produce a worst-case partitioning of the problem. Hence, the time complexity of quicksort with n elements having equal values is always O(n2).

Add a comment
Know the answer?
Add Answer to:
Give an example input (6 elements) for quick sort which would result in worst case performance,...
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