Sign in to follow this  
_jinx_

Recursion and a little more..

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this