zippoxer Newbie cheater
Reputation: 0
Joined: 04 Feb 2008 Posts: 23
|
Posted: Thu Oct 13, 2011 12:44 pm Post subject: Finding the root of a binary tree. |
|
|
I'm using "Memory dissect" tool in Cheat Engine and created a structure representing a node of the tree that I'm trying to find it's root. I typed in the address of a random node I found in the process, then tried to follow the parent of each node (a pointer, located at 0x4) until I find the root (a node that has no parent).
Couldn't find any node that has no parent, instead I got into a loop:
The parent of node 0786FD00 is 0894ADB0 and the parent of node 0894ADB0 is 0786FD00.
Is it a tree with multiple roots? (never heard of such, only a guess)
Update: the solution is reading all possible root nodes (0786FD00 and 0894ADB0 in this case) using preorder method (described here: http://en.wikipedia.org/wiki/Tree_traversal) then choosing the node that returned the highest amount of nodes and searching a pointer for it. That pointer will always point to the root node of the tree. |
|