Question

2) Sorting (a) (5 pts) In a Merge Sort of 8 elements, the Merge function gets called 7 times. Consider a Merge Sort being exe

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

2.(a)

402712 18 99/31/16 ist Call 40/2712 18 1199 3116 99311167 zolace 140/27 12 18 3 Call 1199 3116 140 21 12 18 199] 31 [16 - 9th

(b)

lbs o 2. 3 4. Index Original 5 33 18 22 15 14 After gst 18 22 IS 14 33 After and 189 15 14. 22 133 After 3rd 9 15 18. 22 133

Add a comment
Know the answer?
Add Answer to:
2) Sorting (a) (5 pts) In a Merge Sort of 8 elements, the Merge function gets...
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
  • C++ Sorting and Searching 1. Mark the following statements as true or false. a. A sequential...

    C++ Sorting and Searching 1. Mark the following statements as true or false. a. A sequential search of a list assumes that the list elements are sorted in ascending order. b. A binary search of a list assumes that the list is sorted. 2. Consider the following list: 63 45 32 98 46 57 28 100 Using a sequential search, how many comparisons are required to determine whether the following items are in the list or not? (Recall that comparisons...

  • Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8...

    Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8 9 7 0 4 Pivot selection is defined to be the first element of each sub-list. Show the array before and after each quicksort round (when the array is partitioned after placing the pivot at its correct position). Also, clearly highlight the pivot in each partition b. Consider an unsorted array of integers of size n. Write a Java program to arrange the array...

  • . Shell sort is a sorting algorithm similar to insertion sort. Research shell sort and apply...

    . Shell sort is a sorting algorithm similar to insertion sort. Research shell sort and apply that to the following array. Show your work in Detail. [15 points] 45 20 50 10 80 30 60 70 40 90 2. Is Shell sort a stable sorting algorithm? Answer this with an example. [10 points] 3. Apply Merge Sort to sort the following list. Show your work in Detail. [15 Points] 45 20 50 10 80 30 60 70 40 90 4....

  • 8. (5 points) Trace merge sort algorithm as it sorts the following sequence of integer array into...

    8. (5 points) Trace merge sort algorithm as it sorts the following sequence of integer array into a descending order. 42 45 10 64 55 37 96 7 9. (5 points) Trace shell sort algorithm that halves the gap size at each iteration as it sorts the following sequence of integer array into an ascending order. 42 18 10 64 85 37 96 71 8. (5 points) Trace merge sort algorithm as it sorts the following sequence of integer array...

  • 5. [30 pts.] Sorting: Fundamentals (a) [10 pts.] llustrate the performance of the merge-sort algorithm by...

    5. [30 pts.] Sorting: Fundamentals (a) [10 pts.] llustrate the performance of the merge-sort algorithm by providing the merge- sort tree T corresponding to (1) the input sequence processed and (2) the output sequence generated based on the following input sequence: (20, 17,5,9, 19,40, 60, 11) i. Phase 1: input sequences processed at each node of T ii. Phase 2: output sequences generated at each node of T We were unable to transcribe this image(c) [10 pts.] Illustrate the performance...

  • Show the contents of the array below, once the “pivot” element is placed at its appropriate...

    Show the contents of the array below, once the “pivot” element is placed at its appropriate location after each call of the “Partition” algorithm, in the process of running Quick-Sort on said array. Arrange the data in ascending order (from smallest to largest value). Always select the first element of the partition as “pivot” Apply sorting on the following data set 19,       20,       1,         13,       16,       5,         4,         9,         14,       7 Index 0 1 2 3 4 5 6 7...

  • [5 marks] Using selection sort algorithm to sort the array int array[7]-5, 6, 2, 7, 9,...

    [5 marks] Using selection sort algorithm to sort the array int array[7]-5, 6, 2, 7, 9, 4, 3). Assuming we call the following function using statement selection sort (int array, 7); Please fill the table to show the changes of the array int_array after each iteration. The first column is filled. void selection_sort (int list[], int list_size) for (int i = 0; i < list size - 1; 1++) int current min = list[1]; int current_min_index-i for (int j -...

  • Bubble sort is a popular, but inefficient, sorting algorithm. It works by repeatedly swapping adjacent elements...

    Bubble sort is a popular, but inefficient, sorting algorithm. It works by repeatedly swapping adjacent elements that out of order. BUBBLESORT(A) 1. for i = 1 to A.length – 1 2. for j = i + 1 to A.length 3. if A[j] < A[i] 4. exchange A[j] with A[i] a) A loop invariant for the outer for loop in lines 1 – 4 is: At iteration i, the sub-array A[1..i] is sorted and any element in A[i+1..A.size] is greater or...

  • Consider a variation of Merge sort called 4-way Merge sort. Instead of splitting the array into...

    Consider a variation of Merge sort called 4-way Merge sort. Instead of splitting the array into two parts like Merge sort, 4-way Merge sort splits the array into four parts. 4-way Merge divides the input array into fourths, calls itself for each fourth and then merges the four sorted fourths. a)Implement 4-way Merge sort from Problem 4 to sort an array/vector of integers and name it merge4. Implement the algorithm in the same language you used for the sorting algorithms...

  • Modify the sorts (selection sort, insertion sort, bubble sort, quick sort, and merge sort) by adding code to each to tally the total number of comparisons and total execution time of each algorithm. E...

    Modify the sorts (selection sort, insertion sort, bubble sort, quick sort, and merge sort) by adding code to each to tally the total number of comparisons and total execution time of each algorithm. Execute the sort algorithms against the same list, recording information for the total number of comparisons and total execution time for each algorithm. Try several different lists, including at least one that is already in sorted order. ---------------------------------------------------------------------------------------------------------------- /** * Sorting demonstrates sorting and searching on an...

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