Question

Explain why recursive implementation of QuickSort will require O(log n) of additional space.

Explain why recursive implementation of QuickSort will require O(log n) of additional space.

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

Solution:

Explanation:

Quick sort:

=>Quick sort is a sorting algorithm and is used to sort the elements in the array.

=>Quick sort algorithm is based on the devide and conquer algorithm which uses partiotioning method means deviding the array based on the pivot element.

=>Quick sort can be implemented using recursion as well as without recursion.

=>When quick sort is implemented without recursion it required constant space that is O(1) because no recursive step is there so no need to have stack data structure.

=>When quick sort is implemented with recursion then iterative partitioned are required and recursive calls are made.Each recursive call require constant space that is O(1) and in the best case there can be log(n) recursive calls.

=>Hence total extra space in stack = logn*O(1)

=>Total additional space = O(log(n))

I have explained each and every part with the help of statements attached to it.

Add a comment
Know the answer?
Add Answer to:
Explain why recursive implementation of QuickSort will require O(log n) of additional space.
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