How do I call Recursive Function ?

Get help using Construct 2

Post » Sat Oct 29, 2016 4:29 pm

Hi, guys
I try to convert a C++ code to C2 code, It is a Recursive Function.
code here
Code: Select all
void mergeSort(int array[], int first, int last) {
    if(first < last) {
        int middle = int((first + last) / 2);
        mergeSort(array, first, middle);
        mergeSort(array, middle + 1, last);
        merge(array, first, middle, last);
    }
}


I try to
Image

but I receive a bug "Maximum call stack size exceeded".

Its seem I can't call 2 times mergeSort Function. Someone can help me!



Please Excuse my poor English :D
Last edited by gameba on Sat Oct 29, 2016 6:39 pm, edited 1 time in total.
B
34
S
16
G
18
Posts: 58
Reputation: 11,710

Post » Sat Oct 29, 2016 5:07 pm

There's not enough here to work with. Your array is blank, you are arbitrarily sending 0 and 7 as parameters, and the "merge" function isn't there. You've hard coded the "last" as 7 on the second call. If you follow the source exactly, it should work. Start by having locals for first and last, set them from the Params, then it will be easier to follow. You are taking too many shortcuts.
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994


Return to How do I....?

Who is online

Users browsing this forum: KTML5 and 28 guests