[thelist] [DB Design] Recursive Directory Structure
Paul Cowan
evolt at funkwit.com
Sun Feb 2 20:50:00 CST 2003
Lachlan wrote:
> So what happens if hamburger had children too... does it go ribeye ->
> hamburger or ribeye -> hamburger children -> hamburger?
If you have a hamburger child called "cheeseburger":
It goes ribeye -> hamburger left -> cheesburger left -> cheeseburger
right -> hamburger right.
Dammit, Cannon, I told you to draw a diagram. Don't make me say it
twice! :)
It might also help 'get' it if you think of it recursively.
Have some pseudocode:
assign_numbers(node, index)
{
node.left = index
for each child in node.children
index = assign_numbers(child, index + 1)
next
node.right = index + 1
return index + 1
}
start by calling "assign_numbers(beef, 1)" and follow it through...
Cheers,
Paul
More information about the thelist
mailing list