Analyze the time complexity of the following variant of merge
sort: given a constant k, divide...
Analyze the time complexity of the following variant of merge
sort: given a constant k, divide the array into k parts, sort each
part recursively, and merge the results.
a. Develop a divide-and-conquer algorithm to perform a parallel
merge sort of an array. Hint: After division, each process sorts
its part of the array using an efficient algorithm. Then, the
subarrays are merged into larger sorted subarrays. b. Analyze the
communication and computation times if the number of processes is
equal to the number of array elements, n. c. Repeat Part b if the
number of processes is less than the number of array elements.
Assume that the computation...
Write a program in Java to sort the given array using merge
sort, quick sort, insertion sort, selection sort and bubble sort
based on the input from the user which sorting technique they
wanted to use. Get the array size, array elements from the user,
and also display the sorted array along with the name of the
sorting technique used.
Which of the following sorting algorithms are stable: insertion
sort, selection sort, merge sort and quick sort? Give a simple
scheme that makes any sorting algorithm stable. How much additional
time and space does your scheme entail?
4. Write out the pseudocode for when Merge-Sort is stable based
on the information given below:
Comparision Based Stable Sorts such as Merge Sort maintain
stability by ensuring that Element A[ j ] comes before A[ i ] if
and only if A[ j ] < A[ i ], here i, j are indices and i < j.
The relative order is preserved if A[ i ] comes before A[ j ].
Mergesort is stable, provided its implementation employs the...
Given an unsorted integer array A of size n, develop an
pseudocode with time complexity as low as possible to find two
indexes i and j such that A[i] + A[j] = 100. Indexes i and j may or
may not be the same value.
Find the Asymptotic time complexity for each of the functions in
the following:
#Q2
# to denote ayymptotic time complexity use the following
notation
# O(l) O(m) O(a) O(b)
# e.g. traversing through l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
is O(l)
#1
def merge():
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
m = [15, 16, 17, 18]
lm = []
for l_i in l:
lm.append(l_i)
for m_i in m:...