
-----------------------------------
PersonalPinky
Tue Jun 02, 2015 7:03 pm

Trying to make quick sort, program crashes
-----------------------------------
What is it you are trying to achieve?
I am trying to make quick sort in Turing.


What is the problem you are having?
When I run the program it compiles without errors but after a while it crashes, giving this message:
Stack overflow! Attempting to allocate 24 bytes of local variables with 28 bytes of stack space. (Original stack size: 8388608 bytes).


Describe what you have tried to solve this problem
I don't even know where to begin to fix this issue. Maybe it's the algorithm itself that is the issue, but I have made quick sort in Java with no problems.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
 
View.Set ("graphics:max;max,nobuttonbar")

const numberOfElements := 20 %number of elements in the array

%Partitioning array into 2 sections: smaller than pivot and greater then pivot
function partition (var a : array 1 .. * of int, left, right : int) : int
    var i : int := left
    var j : int := right
    var temp : int
    var pivot : int := a (1)

    loop
        exit when upper (a) = 1
        if i  pivot then
                    j -= 1
                else
                    exit
                end if
            end loop
            if i 