I am trying to convert a Categories Tree to a flat list.
In the Categories any category can have n levels of subcategories.
For Ex.:
Category1
-SubCategory1
-SubCategory2
--SubCategor1
---SubCategory1
---SubCategory2
----SubCategory1
----SubCategory2
---SubCategory3
--SubCategory2
-SubCategory3
Category2
-SubCategory1
--SubCategory1
---SubCategory1
----SubCategory1
---SubCategory3
-SubCategory3
...etc and so on.
Language is not a barrier I am just trying to formulate loops/nested loops to create this logic to convert it into a flattened list.
Any help will be highly appreciated.
Thanks in Advance
Each entry to your flat List will be a node of your Tree as that is visited according to Depth First Search. For more information please see here
Edit:
The original post was edited a couple of times. Initially, it looked like the OP was after a flat list as that would be the output of BFS but after a later edit it looked like the OP was after a flat list as that would be the output of DFS. The more general case then would be that “Each entry to the flat list will be a node of the Tree as that is visited by some traversal function (such as BFS or DFS).”