473,395 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

recursive stuff

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
1 1151
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: replace-this-with-my-name | last post by:
Hi. How do I return a string containing an entire menu-tree from a recursive function? Here is my current recursive function: function page_tree( $_i ){ //Call global mysql connection...
7
by: Jon Slaughter | last post by:
#pragma once #include <vector> class empty_class { }; template <int _I, int _J, class _element, class _property> class RDES_T {
4
by: Nicolas Vigier | last post by:
Hello, I have in my python script a function that look like this : def my_function(arg1, arg2, opt1=0, opt2=1, opt3=42): if type(arg1) is ListType: for a in arg1: my_function(a, arg2,...
64
by: dmattis | last post by:
I am trying to write a recursive version of Power(x,n) that works by breaking n down into halves(where half of n=n/2), squaring Power(x,n/2), and multiplying by x again if n was odd, and to find a...
9
by: Csaba Gabor | last post by:
Inside a function, I'd like to know the call stack. By this I mean that I'd like to know the function that called this one, that one's caller and so on. So I thought to do: <script...
14
by: Fabian Steiner | last post by:
Hello! I have got a Python "Device" Object which has got a attribute (list) called children which my contain several other "Device" objects. I implemented it this way in order to achieve a kind...
8
by: joel_maina | last post by:
Due to my question not well understood i have briefly explained in words what i ment.i.e x0 was to mean x raised to power 0=1.NOW THE QUESTION WAS AS BELOW. Pliz i need to know this thank you....
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
6
by: nathanM | last post by:
Hi, I have a function, looks a bit like this: def function(): if condition: do stuff, including a few recursive calls (to function()), this 'stuff' also changes the state of 'condition'. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.