What is the best data structure for tree-like data of fixed depth in C#? -
What is the optimal (simple, fast, fast) implementation of data structure like tree with three levels? I would like to use a dictionary or a shorthand, because all the values (nodes) have unique keys.
The first level is thought to be about 300 objects, about one tenth of each (probably more than 100, usually at least 10) items at the second level and approximately ten at the third level. Level two and three are closely connected, so they should probably be represented by an object. All relations 1: n
++ - L1 | ++ - L2 || + - L3 || + --... 1 to 10 L3 items for each L2 || + - L3. + - L2. + --... From 0 to 100, for every L1 usually < 10 L2 items | + - L2 + - L1 + - L1 + - ... about 300 L1 items + - L1
What is the level 2 objects with a 1 level object (a real tree ) Is better to make a dictionary or is it better to have 2 level objects in a single directory?
The objects are not very big, they only have some strings and numbers
or object representation is a wrong option and should I go for something completely?
Why not just create a TreeNode class?
class treeNode {personal string _name; Private int_smember Private Indus _uniqueId; Private listing & lt; TreeNode & gt; _childNodes; Public string name {get {return _name}}} Public int someNumber {get {return_someNumber;}} Public int uniqueId {get {return_uniqueId;}} Public listing & lt; TreeNode & gt; ChildNode ({return _childNodes;}} Public Zero TreeNode (string name, int number, int uniqueId) {_name = name; _someNumber = someNumber; _uniqueId = uniqueId; _childNodes = new list & lt; TreeNode & gt; (); } Public Zero AddNode (tree node node) {_childNodes.Add (node);} // Other code for removal, search, etc.}}
Comments
Post a Comment