CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Algotithms

  1. #1
    Join Date
    Jun 1999
    Posts
    47

    Algotithms

    HI !

    Where ca I find some exemples of recursive algorithms ?




  2. #2
    Join Date
    Jun 1999
    Location
    Canada - Québec
    Posts
    273

    Re: Algotithms

    example :

    void Execute(int i)
    {
    i++;
    if (i < 10)
    Execute(i);
    }





  3. #3
    Join Date
    Jun 1999
    Posts
    47

    Re: Algotithms

    void Execute(int i=0){
    if( i < 10)
    Execute(i++);
    }

    Ofcourse! Well i'm not a beginner and is not that I don't know how to write a recursive function.
    I ment by 'recursive algorithms' somthing a little bit more complex than this stupid exemple. I need those algorithms sources because I don't want to copy them from a book or write them manualy.
    Thancks anyway.

    Zizi



  4. #4
    Join Date
    Jun 1999
    Location
    Canada - Québec
    Posts
    273

    Re: Algotithms

    if u know how.. why did u ask?


  5. #5
    Join Date
    May 1999
    Location
    United Kingdom
    Posts
    136

    Re: Algotithms

    Could you specify what your recursive function is supposed to be doing? Otherwise we won't be able to help you much, I'm afraid.

    Oliver.


  6. #6
    Join Date
    Jun 1999
    Posts
    26

    Re: Algotithms

    I have a problem with "not wanting to write it manually" .... but ...
    Space prohibits submitting a full recursive descent parser, so suppose you have a binary tree built with the following:

    typedef struct abc abc;
    struct abc
    {
    abc *left;
    abc *right;
    int count;
    };
    abc *anchor; // tree attached here
    int node_count = 0;




    the algorithm to visit each node and increment the count and report the number of nodes is:

    int Visit(abc *here,int n)
    {
    if (here == NULL) return n;
    if (here->left) n = Visit(here->left,n);
    here->count++;
    if (here->right) n = Visit(here->right,n);
    return (n+1);
    }

    node_count = Visit(anchor,0);




    Copy Away!!!

    Dennis


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured