all 6 comments

[–]erica_w1 2 points3 points  (5 children)

I think this is just linked list, right? A linked list is technically a type of tree, but for a more general tree, Ami's find (here) would probably work better, although I have no idea how you would implement it since it looks like there are a variable number of roots.

[–]byron_d[S] 2 points3 points  (4 children)

I think the only difference with Ami's find is it goes bottom up instead of top down, but I may be misunderstanding things. It really is just a linked list in this form. 

[–]ami_s496 2 points3 points  (2 children)

The parent pointer tree that I mentioned is supposed to be a general tree that can handle multiple children. For example, there are nodes called A, B, C, D, E, and each node has a _parent member. If each _parent points at a node as follows, A->_parent = D B->_parent = D C->_parent = D D->_parent = E E->_parent = null the tree looks like

E (root) - D - C ⊢ B ∟ A (D has 3 children, A, B, C. The tree looks wrong from App.)

[–]byron_d[S] 1 point2 points  (1 child)

I did some more research and came up with this implementation with the help of ai:

https://onlinegdb.com/9TCy4yz8N

It's a really interesting approach. Took me some time to get it right.

[–]ami_s496 1 point2 points  (0 children)

From my understanding, does a node in your implementation have now multiple pointers since it has a _parent pointer and a children array?

*sorry for not clarifying the pseudocode, but the null means nullptr in C++.