|
-
July 13th, 1999, 09:49 AM
#1
Algotithms
HI !
Where ca I find some exemples of recursive algorithms ?
-
July 13th, 1999, 10:06 AM
#2
Re: Algotithms
example :
void Execute(int i)
{
i++;
if (i < 10)
Execute(i);
}
-
July 13th, 1999, 10:16 AM
#3
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
-
July 13th, 1999, 10:23 AM
#4
Re: Algotithms
if u know how.. why did u ask?
-
July 13th, 1999, 10:24 AM
#5
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.
-
July 13th, 1999, 10:37 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|