I have a data structure as shown below:
Task(id,name,subTasks[Task])
But the problem is that subtasks can contain tasks that have other subtasks. This can be very deep:
Task1 Contains SubTask1
SubTask1 contains subtasks
and you can understand that it can be run very deeply.
I can get this data from database tables. But how can I save this in a data structure in java. Using for loops without knowledge of depth is useless and not elegant. What will be the best data structure and data path?
source share