Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago

Question

3. What are potential solutions?

Answered: 1 week ago