Skip to content

Commit

Permalink
Corrected logic error
Browse files Browse the repository at this point in the history
  • Loading branch information
singhpratyush committed Feb 14, 2016
1 parent 9bc7840 commit 688c89b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lab2/3/merge_sort_sdm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ void merge_sort_sdm(int *arr, int length, int *grpArr, int grpLength)
{
if(grpLength == 0)
return;

int start = 0;
for(int i = 0 ; i < grpLength ; i ++)
int newGrpArr[grpLength], grpCtr = 0;
for(int i = 0 ; i < grpLength ; i += 2 )
{
int mid = grpArr[i];
int end = grpArr[i+1];
int end = (i+1 <= grpLength)?grpArr[i+1]:grpArr[i];
newGrpArr[grpCtr++] = end;
merge(arr, start, mid, end);
start = end + 1;
}
merge_sort_sdm(arr, length, newGrpArr, grpCtr-1);
}

int main(void)
Expand Down

0 comments on commit 688c89b

Please sign in to comment.