title: What is fast, compact representation of tree structures that prevents cache misses?
body: <p>Graphical applications often represent images as flat arrays, instead of bidimensional arrays. If I'm not mistaken, this is done because flat arrays are much faster as they're compact and avoid cache misses. Example:</p>
  
  <pre><code>dimensional_array = [[1,2],[3,4],[4,5]]
  four = dimensional_array[1,1]
  
  flat_array = [1,2,3,4,5,6]
  four = flat_array[1 + 2*1]
  </code></pre>
  
  <p>Is there a similar (or not) representation of free-form trees that allows for the same kind of performance gain?</p>
  
  <pre><code>free_form_tree = [[1,2,3],4,5,[[6,7],8]]
  </code></pre>