MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / mergeSort

Method mergeSort

CountInversions.java:13–24  ·  view source on GitHub ↗
(long arr[],long s, long f)

Source from the content-addressed store, hash-verified

11
12 }
13 public static long mergeSort(long arr[],long s, long f)
14 {
15 long inv_count=0;
16 if(s<f)
17 {
18 long mid=s+(f-s)/2;
19 inv_count+=mergeSort(arr,s,mid); //left sub problem!
20 inv_count+=mergeSort(arr,mid+1,f); //right ub problem!
21 inv_count+=merge(arr,s,mid,f);
22 }
23 return inv_count;
24 }
25
26 public static long merge(long arr[],long s,long m, long e)
27 {

Callers 1

inversionCountMethod · 0.95

Calls 1

mergeMethod · 0.95

Tested by

no test coverage detected