Reputation: 137
I understand that binary tree allows only one node as its root. I am looking for data structure which allows two nodes as 1st level without root. Can we do accomplish this graph?
I have data like the following
EmpoyeeId SupervisorId DeptName 1000 -1 Business 2000 -1 Research 1001 1000 Accouns 1002 1000 Tax2 2001 2000 Computers 1003 1001 Corp Tax 2002 2001 Operating System 1008 1001 another Tax 1009 1001 big business Tax
Given above data , how do we model this? Which data structure i should use to get employee at nth level?
Upvotes: 0
Views: 50
Reputation: 13223
Having two binary trees is actually your structure.
Also you always can make virtual root node that will have no meaningful value but will point to two neighbours.
Upvotes: 2