# Access over 35 millionacademic & study documents

Content type
User Generated
Rating
Showing Page:
1/2
questions:
* 1) What is the best-case runtime complexity of Bubble
Sort?
Of Insertion Sort?
* 2) If you implemented Shell Sort to only ever use a gap
size of 1, what
other sorting algorithm would this be identical to?
* 3) What is the memory complexity of Merge Sort?
* 4) Imagine you changed the Merge Sort algorithm to
divide the data into
four parts instead of just two. What would the runtime
complexity be
in this case? Explain your reasoning.
1) The best case runtime complexity of Bubble Sort is O(n)
This happens when data is already sorted
The best case runtime complexity of Insertion Sort is
O(n^2)
This happens when data is already sorted
2) It will be identical to insertion sort
3) In place merge sort take O(1) Space because we just
swap numbers inplace.
Other varient take O(n) time because we have to store the
left and right sorted data and then merge them.
4) T(n)=4*T(n/4)+cn
In this the value of c matters.
when we use only one partition, c=1
But when we use more than 2 partions c value increase
increasing total complexity.

Showing Page:
2/2

Unformatted Attachment Preview
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4