I have to structure certain data and tree data structure suited the requirement.
I have to assign certain number to each node in such a manner that I can trace back the parent from its number. I am planning to use hashtable to store these numbers as keys, so there cannot be any duplicate value.
e.g.
parent - 000001
child1 - 000011
innerchild1 - 000111 (level 2, get 2 bits from right and we can reach parent)
innerchild2 - 000211
child2 - 000021
innerchild1 - 000121
innerchild2 - 000221
Depending on the level, I can mask certain bits and I can uniquely identify the parent. But if my tree grows wider(i.e. more parents, numbers will duplicate) How to overcome this problem?