# Thread: Need help to analyse Merge sort and matrix multiplication code.

1. Member
Join Date
Mar 2017
Posts
1
Rep Power
0

## Need help to analyse Merge sort and matrix multiplication code.

Hi everyone,
I just need a small help, i am not familiar with java language. I want anyone to make an step by step explanation to a code, which i provided below. Kindly check the images. There are two kind of codes for which i need explanation one is "Merge sort" second is "Matrix Multiplication". I will be very thankful to one, will do this for me. Again, i need just step by step explanation of that java code in english which i provide below.
Regard's Shahwar.

.................................................. .........
merge sort ...

public class MyMergeSort {

private int[] array;
private int[] tempMergArr;
private int length;

public static void main(String a[]){

int[] inputArr = {45,23,11,89,77,98,4,28,65,43};
MyMergeSort mms = new MyMergeSort();
mms.sort(inputArr);
for(int i:inputArr){
System.out.print(i);
System.out.print(" ");
}
}

public void sort(int inputArr[]) {
this.array = inputArr;
this.length = inputArr.length;
this.tempMergArr = new int[length];
doMergeSort(0, length - 1);
}

private void doMergeSort(int lowerIndex, int higherIndex) {

if (lowerIndex < higherIndex) {
int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
// Below step sorts the left side of the array
doMergeSort(lowerIndex, middle);
// Below step sorts the right side of the array
doMergeSort(middle + 1, higherIndex);
// Now merge both sides
mergeParts(lowerIndex, middle, higherIndex);
}
}

private void mergeParts(int lowerIndex, int middle, int higherIndex) {

for (int i = lowerIndex; i <= higherIndex; i++) {
tempMergArr[i] = array[i];
}
int i = lowerIndex;
int j = middle + 1;
int k = lowerIndex;
while (i <= middle && j <= higherIndex) {
if (tempMergArr[i] <= tempMergArr[j]) {
array[k] = tempMergArr[i];
i++;
} else {
array[k] = tempMergArr[j];
j++;
}
k++;
}
while (i <= middle) {
array[k] = tempMergArr[i];
k++;
i++;
}

}
}
- See more at: Implement merge sort in java. - Java sorting algorithm programs

2. ## Re: Need help to analyse Merge sort and matrix multiplication code.

[code]
[/code]

to get highlighting and preserve formatting.

i am not familiar with java language
Ok, the place to start is here: http://docs.oracle.com/javase/tutorial/index.html
Last edited by Norm; 03-25-2017 at 04:49 PM.

3. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
13

## Re: Need help to analyse Merge sort and matrix multiplication code.

We prefer not to go to foreign sites. Please post you code here like Norm explained. And please do NOT post any images of your code or snapshots. Just the code.

Regards,
Jim

4. ## Re: Need help to analyse Merge sort and matrix multiplication code.

Where's the matrix multiplication method?

kind regards,

Jos

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•