Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could you please help me with this question. It asks only the result after one s

ID: 663895 • Letter: C

Question

Could you please help me with this question.
It asks only the result after one slit call on the array, not the final sorted result which has no difference than using any other sorting algorithms.

You only need to show what the contents of the table will be after the split function is executed, then say what splitPos is. You don't need to describe or come up with an algorithm. As for the table position numbers, they really don't mean anything particular to this example, except that the function calls the range given to us. Theoretically, you could use this same function call for a table that goes from 0 to 100 and it will only sort the range given. For the final question regarding the actual sorting, what you described is a mergesort. The question asks to use a split function, which divides the contents of the array between the contents that are higher and lower than the pivot, which is the first value in this case.

1. For the following array x,show the contents of x after the function call splitPos 1, 10); is executed, and give the value of the array index splitPos: -split(x, i123456789 10 x 452050 30 80 10 60 7040 90

Explanation / Answer

#include<stdio.h>
#define MAX 100

void Sort(int arr[],int low,int mid,int high);
void partition(int arr[],int low,int high);

int main(){

    int merge[MAX],i,n;

    printf("Enter the total number of elements which you wannt to sort: ");
    scanf("%d",&n);

    printf("Enter the numbers one by one for sorting ");
    for(i=0;i<n;i++){
         scanf("%d",&merge[i]);
    }

    partition(merge,0,n-1);

    printf("After sorting elements are: ");
    for(i=0;i<n;i++){
         printf("%d ",merge[i]);
    }

   return 0;
}

void partition(int arr[],int low,int high){

    int mid;

    if(low<high){
         mid=(low+high)/2;
         partition(arr,low,mid);
         partition(arr,mid+1,high);
         Sort(arr,low,mid,high);
    }
}

void Sort(int arr[],int low,int mid,int high){

    int i,m,k,l,temp[MAX];

    l=low;
    i=low;
    m=mid+1;

    while((l<=mid)&&(m<=high)){

         if(arr[l]<=arr[m]){
             temp[i]=arr[l];
             l++;
         }
         else{
             temp[i]=arr[m];
             m++;
         }
         i++;
    }

    if(l>mid){
         for(k=m;k<=high;k++){
             temp[i]=arr[k];
             i++;
         }
    }
    else{
         for(k=l;k<=mid;k++){
             temp[i]=arr[k];
             i++;
         }
    }

    for(k=low;k<=high;k++){
         arr[k]=temp[k];
    }
}

the partition function can be used to parition the array.