1, 3, 4, 7, 9, 11, 13, 14 and 2, 5, 6, 8, 10, 12
There are above two lists given.
This does not change the sequence of appearance of items in the
original. Now we divide these two arrays into halves.
After divinding the list in two items lists we get the below
lists:
(1, 3) (4, 7) (9, 11) (13, 14) (2, 5) (6, 8) (10, 12)
We further divide these arrays and we achieve atomic value which can no more be divided.
1 3 4 7 9 11 13 14 2 5 6 8 10 12
Now, we combine them in exactly the same manner as they were broken down
We first compare the element for each list and then combine them
into another list in a sorted manner. We see that 1 and 3 are in
sorted positions. We compare 4 and 7 and see that they are in
sorted positions.We compare 9 and 11 , they are also in sorted
positions same for 13 and 14.
In the second list, we see that 2 and 5 are in sorted positions,
same for pair 6 and 8 and pair 10,12
so now the list becomes:
(1, 3) (4, 7) (9, 11) (13, 14) (2, 5) (6, 8) (10, 12)
In the next iteration of the combining phase, we compare lists of two data values, and merge them into a list of found data values placing all in a sorted order.
we compare 1 and 4, and keep 1 in first position, then compare 3
with 4 and keep 3 in second position and 4 and 7 in third and
fourth position. similarly we follow the iteration for other lists.
and the final list beccomes
(1, 3, 4, 7) (9, 11, 13, 14) (2, 5, 6, 8) (10, 12)
In the next iteration of the combining phase, we compare lists of four data values, and merge them into a list of found data values placing all in a sorted order.
(1, 3, 4, 7, 9, 11, 13, 14) (2, 5, 6, 8, 10, 12)
After the final merging, the list should look like this
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
Show step by step how the merge procedure of merge sort will merge the arrays 1,...
Show how to sort the sequence by using 3-merge-sort respectively,each time you divide the sequence into 3 sub arrays instead of 2 subarrays 2 90 3 25 46 7 8 9 0 74 100
2) Sorting (a) (5 pts) In a Merge Sort of 8 elements, the Merge function gets called 7 times. Consider a Merge Sort being executed on the array shown below. What does the array look like right AFTER the sixth call to the Merge function completes? نرا index value 0 40 2 12 4 11 5 99 6 31 7 16 27 18 0 1 2 زيا 4 5 6 7 Index Value (b) (5 pts) Consider sorting the array...
Sort the sequence 3, 10, 7, 2, 11, 6, 9, 4 using Merge sort. Show the intermediate steps .
Write a program to merge two sorted arrays into a third array. Ask the user to enter the size of the two arrays. The length of array1 could be greater than, equal to or less than the length of array2. Fill both with random numbers 0-99. Sort both arrays as explained below. Write a method merge that takes the two arrays as arguments. The method returns a merged array with size equal to the size of both arrays combined. Note:...
8. Related to the merge sort is an efficient procedure called quick sort. Here we start with a list L : a,a2,, an, and use a as a pivot to develop two sublists L and L2 as follows. For i > 1, if aa, place a at the end of the first list being developed (which is L1 at the end the process); otherwise, place a at the end of L2. After all a,, i >1, have been processed, place...
Apply the merge sort to the following array. Show how the array is divided and then merged step by step. A = [64, 19, 26, 14, 63, 40, 80, 75]
Suppose that we've completed the split (divide) step of the merge sort, and produced 6 single item sub-lists. [1] [2] [3] [4] [5] [6] What will be the values of the 2-item sub-lists in the merge step?
For C++ Write a program that randomly generates 100 integers and sorts them using radix sort. Note: Your output would not be the same as this sample output due to the randomness. Sample output: 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 4 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7...
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...
Problem solving manually 2. Using Figure 2.4 as a model, illustrate the operation of merge sort on the array A = 〈11, 9, 13, 2, 7, 8, 3, 11, 5〉.