I have a very fundamental question in Java. I searched for this everywhere but just could not find a solution anywhere.
I am trying to read about deleting a binary tree. Before dwelling into DFS, BFS etc, I was thinking that if I just release all active references to the root of the tree, the entire tree should get GCed automatically. What I mean is if I just drop the only active reference to the root, then the root must get GCed and hence, there are no more active references to the children of root and they should get GCed. This must continue as a chain reaction till the entire tree is GCed. Am I right or is something wrong with my analysis?
Assumption: All nodes are referenced by only its parents and nobody else.