Question

What is the worst – case performance of Quicksort? Prove it.

What is the worst – case performance of Quicksort? Prove it.

Homework Answers

Answer #1
Worst case performance of Quicksort is when it divides the array into sizes 1 and n-1

Then
Recurrence relation for the Quicksort function is
T(n) = T(n-1) + n

Solving Recurrence relation 
T(n) = T(n-1) + n
     = T(n-2) + (n-1) + n
     = T(n-3) + (n-2) + (n-1) + n
     = T(n-4) + (n-3) + (n-2) + (n-1) + n
     ....
     ....
     = T(n-n) + 1 + ... + (n-3) + (n-2) + (n-1) + n
     = T(0) + 1 + ... + (n-3) + (n-2) + (n-1) + n
     = 0 + 1 + ... + (n-3) + (n-2) + (n-1) + n
     = 1 + ... + (n-3) + (n-2) + (n-1) + n
     = n(n+1)/2
    = (n^2+n)/2
    = O(n^2)


Know the answer?
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
Similar Questions
Show that the worst case of the Quicksort is Ω(n2)
Show that the worst case of the Quicksort is Ω(n2)
H. The practical worst case performance level is the optimum level of performance that is used...
H. The practical worst case performance level is the optimum level of performance that is used to evaluate the actual performance of the line and it is fixed when the amount of work in process is changed
(4 pts) What is the worst-case Big-O of the insert () algorithm for the red-black tree?...
(4 pts) What is the worst-case Big-O of the insert () algorithm for the red-black tree? Explain. (4 pts) What is the worst-case Big-O of the remove () algorithm for the red-black tree? Explain. (2 pts) What is the worst-case Big-O of the clear () algorithm for the red-black tree? Explain.
What is the worst case runtime for creating a Huffman Tree for N characters, and the...
What is the worst case runtime for creating a Huffman Tree for N characters, and the run time to combine the trees is O(size of resulting tree)?
what is the best and worst case for o(n^2) ? I need example with explanation. DEEP...
what is the best and worst case for o(n^2) ? I need example with explanation. DEEP explanation and at least 3 example.
out of the following four: 1.Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort a. Which...
out of the following four: 1.Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort a. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is random? b. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is 90% sorted? c. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is reverse sorted? d. Which sorting methods perform best and...
Fill in the following table, using Big-O notation to give the worst and average-case times for...
Fill in the following table, using Big-O notation to give the worst and average-case times for each of the stack methods for a stack of size N. OPERATION WORST-CASE TIME AVERAGE-CASE TIME constructor empty size push pop peek
What is the worst-case time (in Big-O) for building a Min-Heap of N nodes, using bulk...
What is the worst-case time (in Big-O) for building a Min-Heap of N nodes, using bulk insertion (bottom-up construction), assuming comparing two keys takes constant time. Justify your answer. You may assume N = 2h+1 – 1, for simplicity.
Consider the radiation emitted by a worst-case solar flare. (a) What is the maximum photon energy...
Consider the radiation emitted by a worst-case solar flare. (a) What is the maximum photon energy that will be prevented from reaching a solar cell by a quartz coverslide that is 0.15 mm thick? 23 mm thick? (assume coverslide density of 2.5 g/cm3) (b) If all of the radiation passing the coverslide is absorbed by the underlying cell, estimate the difference in radiation dose for both the 0.15 and 0.23 mm coverslides. Assume the radiation is deposited uniformly over a...
(5 pts) Compare and contrast the worst-case time complexities for inserts, deletes, and searches in an...
(5 pts) Compare and contrast the worst-case time complexities for inserts, deletes, and searches in an AVL tree and red-black tree. Provide some insights to how the complexities are determined.