Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand what you want to say ( each node at level i has n(i) children) then is very simple : The first number is the root fallowed by n(0) elements that are the root's children , then you put for all those n(0) nods all their n(1) nodes. If you have n(0) = 3 then for the first you put n(1) nods, after them you put all the n(1) nods if the second nod, and and after those the n(1) nods for the 3rd nod</p> <pre><code>1 -&gt; 2, 5, 3 ( 1 is the root, and has 2, 5, 3 as children) 2 -&gt; 4, 10 3 -&gt; 45, 35 5-&gt; 12, 31 n(0) = 3, n(1) = 2 , n(2) = 0 Then You should have: {1, 2, 5, 3, 4, 10, 45, 35, 12, 31} </code></pre> <p>For a good index you should keep another array with the father position and another with the first child index or if you realy want to have just one array you should do this:<br> For each element keep 3 things: the father index and the first child index. Because the child are one after another you will allways have access to all the children and you will allways have the father. ( I will put -1 for the root's father) Then you should have : </p> <pre><code>{1,-1, 3, 2, 0,12, 5, 0, x, 3, 0, x, 4, 3, x, ... } {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ... } -1 is the father of 1 and 3 is the start of his child 0 is the father of 1 and 12 is the start of his child ( 4 in this case) </code></pre> <p>If you want a "heap" structure you have to find the largest number of children Mx = ( max(n(i)), 1&lt;=i&lt;=N and do a heap with step MX, each element will have their children at pos*MX, pos*MX + 1, ..pos*MX + n(k), and the father at pos/MX, where the pos is the index of the node. <br> You will have a lot of free spaces but is a heap-like stuture<br> I hope it helps you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload