Randomly Generated Trees

The Random_tree class creates a tree with pseudo-random integers. The size of the tree is fixed and the actions that can be performed on the tree include:

  • Erase a pseudo-randomly chosen node from the tree and replace it with a new randomly generated entry, and
  • To regenerate a new pseudo-randomly generated tree.

The one query returns a structure including the properties of the tree.

The two printing routines include:

  • The ability to list the nodes of the tree,
  • The ability to draw the tree, and
  • The ability to export the tree as an SVG.
  • 16384
    One side only:
    Height:         30      [65, 122]            93.07555332 +/- 6.818472916
    Average depth:  16.764  [40.9352, 73.3134]   56.99771881 +/- 4.183297441
    
    Alternating sides:
    Height:         29      [30, 63]             40.05068168 +/- 3.491405627  
    Average depth:  15.8669 [16.5543, 31.7723]   20.03246616 +/- 1.289730882
    
    8192
    One side only:  30      [53, 106]            77.07291290 +/- 6.156792184
    Height:         15.7756 [32.9548, 60.7571    46.86495893 +/- 3.607904558
    Average depth:  
    
    Alternating sides:
    Height:         27      [27, 61]             35.81657992 +/- 3.267420083
    Average depth:  14.8138 [14.8138, 25.998]    18.09591366 +/- 1.221032882
    
    
    4096
    One side only:
    Height:         26      [43, 87]             63.56975884 +/- 5.273577913
    Average depth:  14.0933 [23.6458, 50.8401]   38.30424016 +/- 3.096393569
    
    Alternating sides:
    Height:         22      [22, 51]             31.72507687 +/- 3.045365755
    Average depth:  12.9075 [13.0657, 24.1116]   16.19078375 +/- 1.155486354
    
    2048
    One side only:
    Height:         25      [34, 77]             51.79435124 +/- 4.586126315
    Average depth:  12.8804 [20.2886, 41.9248]   30.87827392 +/- 2.657512390
    
    Height:         20      [20, 45]             27.77609424 +/- 2.772164099
    Average depth:  11.3643 [11.3643, 21.4546]   14.32674465 +/- 1.078627756
    
    
    1024
    One side only:
    Height:         22      [26, 60]             41.56518886 +/- 3.892265742
    Average depth:  12.1172 [15.6836, 36.377]    24.42867759 +/- 2.220405150
    
    Height:         17      [17, 39]             24.06265211 +/- 2.527150931
    Average depth:  9.9502  [9.9502, 20.0361]    12.55379134 +/- 1.014942357
    
    
    
    512
    One side only:
    Height:         17      [21, 48]             32.73655902 +/- 3.276284460
    Average depth:  9.28125 [11.9531, 26.9199]   18.89302461 +/- 1.802743645
    
    Height:         13      [13, 35]             20.53176474 +/- 2.280411009
    Average depth:  8.45898 [8.45898, 16.1543]   10.82991884 +/- 0.9340540598