Access over 35 million academic & study documents

About CS261In comments in bubble sort c answer the following q

Content type
User Generated
Rating
Showing Page:
1/2
About CS261
In comments in \"bubble_sort.c\" answer the following
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?
Explain your reasoning.
* 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.
This is my answer, please help me to find the wrong
answer.
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.
About CS261

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
About CS261 In comments in \"bubble_sort.c\" answer the following 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? Explain your reasoning. * 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. This is my answer, please help me to find the wrong answer. 1 ...
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.

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