By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,687 Members | 1,806 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,687 IT Pros & Developers. It's quick & easy.

recursive stuff

P: n/a
Hi,

Using a TreeView component to create a tree of the directories within my
file system.

I can't get my head around the logic of the recursion. Anyone with a bigger
brain is welcome to help!!

I want the vaild drives to be the top layer with 'children' drilling down
through the directory structure.

Many thanks in advance
Dane

Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi, Dane

I suggest to take any basic CS book and check there examples for n!
calculation - which is classic example of recursive solution of the problem.
Basically it means, that your definition of recursive function should call
itself with arguments, which allow to reduce complexity of solved task

for example:

int Factorial(int n) {
if (n<0) throw new Exception("I don't know how to calculate factorial for
negative number!");
if (n=0) return 0;
return n*Factorial(n-1);
}

Try to run this in debugger, say as Factorial(4), and see step by step what
happens. Just don't call it with too big N, you might get overflow or stack
exception.

Same logic would apply to traversing trees like directory structure

HTH
Alex

"Dane Carty" <da**@REMOVEMEcartyonline.net> wrote in message
news:Qr*******************@front-1.news.blueyonder.co.uk...
Hi,

Using a TreeView component to create a tree of the directories within my
file system.

I can't get my head around the logic of the recursion. Anyone with a bigger brain is welcome to help!!

I want the vaild drives to be the top layer with 'children' drilling down
through the directory structure.

Many thanks in advance
Dane


Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.