c - Flatten a Tree into an Array -
i looking best way place tree array
the idea follow principle : array implementation of trees i'am stuck on how know nodes children , nodes @ same level, because i'am not using binary tree.
i might have store ascii can't allow arrays of 256 pointers !
any idea welcome.
the purpose of this, send array (tree) gpu, instead of using structures.
well, here idea of converting tree array
.
take array of size max_val
, total number of nodes in tree. type of array should same of node 1 field. index value parent. store each node in way. store root node @ first position. 1
. child nodes of node stored subsequently field storing 1
(since root stored).
apply procedure on nodes , done. can tree, simple recursive call on each node.
hope helps. :) :)
Comments
Post a Comment