Question
6
6. Merge Bubble Sort: a) How does the merge bubble sort break the array into sublists? b) What does it need to use for each sublist and then what does it do with all of the sublists? c) What is the Big-O notation for this sort? 7. Merge Sort: a) How does the merge sort use recursion to break the array into sublists? b) What happens to each of these sublists to get the final sorted list? c) What is the best and worst case Big-O notation for this sort? 8. External File Sort: a) Why are three files used to implement this sort and how is each used? b) What is its major advantage and its major disadvantage over internal sorts? 9. Quick Sort: a) How do you select the pivot value and how is it used to create two sublists? b) When every sublist of 1 or 2 elements is sorted, what assertion ensures that the entire array must be sorted? c) What is the best and worst case Big-O notation for this sort? d) What are the kinds of lists for which it is best? 10. Heap Sort: a) How is the initial array of data values conceptually represented? b) what are the two subscripts that are used to access the two children of node #X? c) What is the definition of a heap? d) Explain the basic process of filtering, swapping, and freezing to get each element of the array in its final location.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

7. Merge Sort - lets's answer each part one by one

a) How does merge sort use recursion to break array into sublists ---> merge sorts finds the middle element index of the array and divides the array into 2 parts , one to the left of middle index and other containing the middle index and elements to the right of it. Let's say we have array and its starting and ending indices as first and last , we find middle index as (first+last) / 2 and we make recursive functions call to the left array and right array. left and rght parts are the sublists.

mergesort(int[] arr, int first , int last ){
int middle = (first+last) / 2 ;
mergesort(arr, first, middle-1); // recursive function callse
   mergesort(arr, middle, last); // recursive function calls
   merge(arr,first,last);

}

b. What happens to each of the sublist to get the final sublist ---> When we make recursive function calls to the sublist we get the sublist. as sorted lists. and in mergesort function we call merge function passing the sorted sublist. as the sublists are sorted they take linear tie to merge . when we merge the 2 sorted sublist we get the sorted list. As the merge sort function is called repetedly to create sublist we get a base case of 1 element in sublist and we have base condtion there t return the lsublist of 1 element as it is. hence we get the completley sorted list at the end of first mergesort() function call.

c. what is the best and worst big-O notation for the sort - both the  best and worst case bigO notations for merge sort is O(N LogN) where N is number of elements in the list. the reason beign irrsepective of ordering of elements in the list - we have to traverse the complete array LogN times hence total time taken is LogN times N which is N LogN -even if orignal list is sorted we will call merge function every time.

Add a comment
Know the answer?
Add Answer to:
6 6. Merge Bubble Sort: a) How does the merge bubble sort break the array into...
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