What sorting algorithm is implemented by the following function?
public class another {
public static void sort(int[] a, int n) {
if (n < 2) {
return;
}
int mid = n / 2;
int[] l = new int[mid];
int[] r = new int[n - mid];
for (int i = 0; i < mid; i++) {
l[i] = a[i];
}
for (int i = mid; i < n; i++) {
r[i - mid] = a[i];
}
sort(l, mid);
sort(r, n - mid);
concat(a, l, r, mid, n - mid);
}
}
a. Merge sort
b. Bubble sort
c. Quick sort
d. Selection sort
a. Merge sort
Conceptually, a merge sort works as follows: it divided the unsorted list into n sublists, each containing one element (a list of one element is considered sorted). It repeatedly merges sublists to produce new sorted sublists until there is only one sublist remaining. This is the sorted list.
You might also like to view...
On single-processor systems, the operating system uses________to divide processor time among the many processes.
a) process slicing. b) time slicing. c) time splitting. d) None of the above
Filtering the Last_Name field to show only records that begin with the letter S is an application of a ________ Filter
Fill in the blank(s) with correct word
The graphic components that are overlaid onto data in worksheet cells are called ________
Fill in the blank(s) with the appropriate word(s).
User policies are not effective unless there are clear consequences for violating them
Indicate whether the statement is true or false.