Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is Java Code of MergeSort. I tried to run it but it throws this errors Exception in thread main java.lang.ArrayIndexOutOfBoundsException: 7 at Merge.Merge(Merge.java:31) at

This is Java Code of MergeSort. I tried to run it but it throws this errors

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7 at Merge.Merge(Merge.java:31) at Merge.MergeSort(Merge.java:11) at Merge.MergeSort(Merge.java:10) at Merge.main(Merge.java:55)

Please Help me to fix it. Below are the code

import java.util.Arrays;

public class Merge {

public static void MergeSort( int [] A, int p, int r){ if( p < r ) { int q = (int) Math.floor((p+r)/2); MergeSort(A,p,q); MergeSort(A,q + 1,r); Merge(A,p,q,r); } }

public static void Merge( int [] A, int p,int q, int r){ int n1 = q - p +1; int n2 = r - q; int [] left= new int [n1+1 ]; int [] right = new int [n2+1 ]; for(int i = 0;i

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

a. What is the purpose of the team?

Answered: 1 week ago