I have a hierarchical set of data stored in tree format. The tree may or may not be a binary tree ... i.e. each node could have 0 thru N sub-nodes. Now, I need to calculate the length of the longest branch, or otherwise, the depth of the tree. My comp. sci. days are a long way behind me, so does anybody know how this would be calculated? An example tree I have been working with is as follows ... +--------+--------+------+-------+ | parent | title | left | right | +--------+--------+------+-------+ | | Food | 1 | 18 | | Food | Fruit | 2 | 11 | | Fruit | Red | 3 | 6 | | Red | Cherry | 4 | 5 | | Fruit | Yellow | 7 | 10 | | Yellow | Banana | 8 | 9 | | Food | Meat | 12 | 17 | | Meat | Beef | 13 | 14 | | Meat | Pork | 15 | 16 | +--------+--------+------+-------+ So, in this case, the depth would end up being 4 ... Food, Fruit, Red, Cherry - or - Food, Fruit, Yellow, Banana. Any ideas? Thanks -- Jeff
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:211513 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

