Question

State the order of magnitude in Big-O notation (assuming there are N elements), and explain your...

State the order of magnitude in Big-O notation (assuming there are N elements), and explain your answer in detail for the following operations.

2. Sorting an array using quick sort.

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

Answer 2:

Sorting an array using quicksort will take

means that to sort an array of size N, quicksort will not perform worse than the order of . Although, it may sort the array in order of time.

  • Quicksort in worst case takes time to sort an array and this may happen when the array is already sorted either in ascending or descending order. When the array is already sorted the partition procedure will always pick the smallest or largest element as the pivot. The recurrence relation we get in this case is:

    T(N) = T(1) + T(N - 1) + (N)

    which on solving gives

  • Quicksort in the best case takes time to sort an array and this may happen when the partitioning procedure always picks median as the pivot. The recurrence relation we get in this case is:

    T(N) = 2T(N / 2) +  (N)

    which on solving gives

On analysing worst-case and best case it is safe to state that quicksort will take time to sort an array of N elements.

FOR ANY HELP JUST DROP A COMMENT

Add a comment
Know the answer?
Add Answer to:
State the order of magnitude in Big-O notation (assuming there are N elements), and explain your...
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