Results 1 to 4 of 4
  1. #1
    Shahwar is offline Member
    Join Date
    Mar 2017
    Rep Power

    Default 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();
    for(int i:inputArr){
    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];
    } else {
    array[k] = tempMergArr[j];
    while (i <= middle) {
    array[k] = tempMergArr[i];

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

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

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

    Please edit your post and wrap your code with code tags:


    to get highlighting and preserve formatting.

    i am not familiar with java language
    Ok, the place to start is here:
    Last edited by Norm; 03-25-2017 at 04:49 PM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default 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.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

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

    Where's the matrix multiplication method?

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2013, 02:36 PM
  2. Non-Square Matrix Multiplication
    By j_arif123 in forum New To Java
    Replies: 4
    Last Post: 01-22-2012, 06:32 PM
  3. Merge sort
    By Aivy in forum New To Java
    Replies: 3
    Last Post: 12-14-2011, 11:29 AM
  4. Implement a multi-threaded matrix multiplication program.
    By redasu in forum Threads and Synchronization
    Replies: 0
    Last Post: 11-17-2010, 09:00 AM
  5. Using Merge Sort to sort an ArrayList of Strings
    By coldfire in forum New To Java
    Replies: 3
    Last Post: 03-13-2009, 01:03 AM

Posting Permissions

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