Daniel Zilcsak
July 13th, 1999, 09:49 AM
HI !
Where ca I find some exemples of recursive algorithms ?
Where ca I find some exemples of recursive algorithms ?
|
Click to See Complete Forum and Search --> : Algotithms Daniel Zilcsak July 13th, 1999, 09:49 AM HI ! Where ca I find some exemples of recursive algorithms ? ChristianM July 13th, 1999, 10:06 AM example : void Execute(int i) { i++; if (i < 10) Execute(i); } Daniel Zilcsak July 13th, 1999, 10:16 AM 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 ChristianM July 13th, 1999, 10:23 AM if u know how.. why did u ask? Oliver Kinne July 13th, 1999, 10:24 AM 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. Dennis Jump July 13th, 1999, 10:37 AM 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 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |