Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Translate the following pseudo code into Java Note that merge takes two already sorted files. Therefore, we need another procedure, merge Sort, to actually sort
Translate the following pseudo code into Java
Note that merge takes two already sorted files. Therefore, we need another procedure, merge Sort, to actually sort these files. merge Sort is a recursive procedure, which at each step takes a file to be sorted and produces two sorted halves of this file. Because merge Sort continuously calls merge, and merge works on two identical arrays, we must create a copy of original array, source, which we will call destination. Algorithm merge Sort (source, destination, lower, upper) Input: source array; a copy of source, destination; lower and upper are integers defining the current sublist to be sorted. Output: destination array sorted. if (lower upper) { mid := (lower + upper)/2 merge Sort (destination, source, lower, mid) merge Sort (destination, source, mid+1, upper) merge (source, destination, lower, mid, upper) } Algorithm Sort (A, N) Input: Array, A, of items to be sorted; integer N defining the number of items to be sorted. Output: Array, A, sorted. create & initialize destionation[N] merge Sort (A, destination, 1, N)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started