c# - Tree datastructure and Data -


i happen have database table holds possible combination of subject, verbs , complements possible.

that table looks junction table id columns mapping other tables (subject table, verbs table, complements table).

in program use tree structure represent junction table , each node therefore object id property (subjectid or verbid ...).

what fail understand though put actual data id maps to. though had 2 options:

  1. make data property of each node
  2. make data a node

in first case processing load combination table , create tree. , when need data goes it, load on demand. keep track of data position in tree, data has property points node belongs to.( hack evidently avoid having search whole tree (even if o(log(n)) operation). in addition,i dealing node in whole program since convenient way children of node.

in second case, if make actual data a node , have load data @ once before consuming it. besides, still need create copy of data if "node parent siblings" using same data.

is there clean way achieve trying do? listed below have

public class node<word>{      public word data { get; set; }      public guid id { get; set; }      ..... // other necessary tree stuff  }  public class word {     public node nodeitem { get; set; } } 

or

public class word : node{} 

i hope question clear enough. let me know if need more details , update question it. thank you.

searching in tree mentioning not o(logn) in case because tree not binary search tree. it's undirected graph , can need search either using bfs or dfs.

if imaging situation correctly on ui , have tree suppose in left panel of window , on right panel want show details of node.

if ui or situation

i not store data in tree , load on demand i.e. when user select node , have id of node ,fetch data id , display.

this way , can avoid possible loading of data may not require @ once .


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -