Hi all, I wasn’t sure where else to post a question about a closed topic. I apologize if I’m posting in the wrong place, but I’m nerding out on this algorithm tutorial:
I am a beginner, obvs, and would like to access ‘depth’ in a tree. I.e. if root is depth 0, when I add children they should be depth 1, the next children would be depth 2, etc.
I know this should be super basic, but I’m having a little trouble wrapping my brain around it.
I tried something like: in the Node class initialize depth: Int, and then in the add(child:) function I could say depth +=. But then I would have to add it manually to each Node, which is unnecessary. Should I instead add a value to the array? Or…?
aTdHvAaNnKcSe
(THANKS in advance)
Side note. It seems odd to close forum topics — makes it much harder to continue or organize the discussion. Feature request: keep tutorial discussions open? (all discussions?)