Hello everybody,
i am working on n level category tree structure, for your information the category tree structure image is attached with this post.
Let's consider, each of the category have hundreds( n level ) of category in each, i want to traverse each category without using recursive functions, reason being recursive functions are very slow, is there any way to do this??
Thanks,
phpeid
N level tree traversing
Moderator: General Moderators
N level tree traversing
- Attachments
-
- tree_structure.png (4.89 KiB) Viewed 503 times
Re: N level tree traversing
Couple of notes:
- Recursive functions are not slow, what could be slow is how you using them. For example, running queries like 'select * from nodes where parent_id=$current_id' is certainly not a good idea in a recursive function.
- Your 'tree' is not a tree, since tree is an acyclic graph, while you have cycles in your structure.
Re: N level tree traversing
You can traverse tree iteratively
http://en.wikipedia.org/wiki/Tree_trave ... _Traversal
http://en.wikipedia.org/wiki/Tree_trave ... _Traversal