Computers and Technology

List the resulting array after each call of the merge method. Indicate the number of character-to-character comparisons made for each call to merge (line 22 of the merge method at the end of the assignment). Sort the following array of characters into alphabetical order: C Q S A X B T. 01 public static void mergesort (char[] a, int i, int r){
02
03 if (1 >= r) {
04 return;
05 }
06 int middle = (1+r)/2;
07 mergesort(a, l, middle);
08 mergesort(a, middle+1, r);
09 merge(a, l, middle, r);
10 }
11
12 public static void merge (char[] a, int i, int m, int r){
13
14 //copy lower half of the array into b
15 char [] b = new char[m-1+1];
16 for (int i = 0; i <= m-1; i++ ) {
17 b[i] = a (1+i);
18 }
19
20 int i = 0, j m+1, k = 1;
21 while (i <= m-1 && j <= r ) {
22 if (a[j] < b[i]) {
23 a[j];
24 k += 1;
25 j += 1;
26 } else {
27 a[k] b[i];
28 k += 1;
29 i += 1;
30 }
31 }
32 while (i <= m-1) {
33 a[k] b[i];
34 k += 1;
35 i += 1;
36 }
37 while ( j <= r ) {
38 a[k] a[j];
39 k += 1;
40 j += 1;
41 }
42 }

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 06:50, emmv565628
What are the things you are considering before uploading photos on social media?
Answers: 1
image
Computers and Technology, 24.06.2019 12:10, breezer20042
What is it called during the editing process when the processor ensures that a character holding a coffee mug from one angle is holding the same mug in the same way when the shot switches to another camera at another angle? cinematography continuity technology prop use
Answers: 1
image
Computers and Technology, 24.06.2019 15:00, mbede002
Who introduced the concept of combining artificial and natural light in the studio
Answers: 1
image
Computers and Technology, 25.06.2019 00:30, jayzelgaspar8005
You are to write a series of steps that anyone could follow to solve the following three problems: 1. even odd a. assume that someone tells you a number (an integer number) b. you hear the number and respond with the word even or odd 2. average a. assume that someone tells you between 3 and 5 numeric values. b. you hear the numbers and respond with the average is some number 3. dog or cat a. explain to a child the differences between a dog and a cat. b. your explanation could be used by a child or anyone to distinguish the difference between a dog and a cat
Answers: 1
Do you know the correct answer?
List the resulting array after each call of the merge method. Indicate the number of character-to-ch...

Questions in other subjects: