Recursion and a little more..

Started by
1 comment, last by _jinx_ 18 years, 9 months ago
For the past hour I have been studying Recursion, as I began to practice I started thinking of a method that would look like this:
[SOURCE]

int main()
{
for (i = 1; i <= Divs; i++)
    {
        function(one, two, three, level);
        cout << ruler << "\n";
    }
}
void function(int a, int b, int c, int stage)
{
    if (stage == 0)
        return;
    //some funky code what ever..
    anotherFunction( a, b, c, d );	
    function(ar, low, mid, level - 1);
    function(ar, mid, high, level - 1);
}

void anotherFunction( int uno, int dos, int tres, int var)
{
    if (var == 0)
        return;
    //some funky code what ever..
    anotherFunction( a, b, c, d );	
    function(ar, low, mid, level - 1);
    function(ar, mid, high, level - 1);
}

[/SOURCE]
[/source] This is sorta out there and I don't even have an idea of what I would to this for, just curious if this has a name to it so I can look into it. I read that recursion is often used in AI, is this true? If this is just another branch of recursion that could be understood too. Thanks to anyone who helps! PS: some of the code may be a little off, but it's just the idea of how the funtion inside of a function calls its parent.
Advertisement
It is recursion and it looks a lot like a recursive divide-and-conquer approach. Maybe you like this. It is a recursive implementation of merge sort much along the lines in your example. It might help you sort this topic out.

Greetz,

Illco
Thanks!

This topic is closed to new replies.

Advertisement