hsuthesis.k 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. \l trees.k
  2. `0:("Tree data cut-and-pasted from Aaron Hsu's Thesis (https://scholarworks.iu.edu/dspace/handle/2022/24749)"
  3. "is rendered with the algorithms here. Feel free to match against those rendered in the thesis.")
  4. / show tree x (given by DFS preorder parent vector) with labels y
  5. sh:{(tr;l):pad[p]t1[p:1+|/#'y]x;`0:"P:",`k@x;`0:(,""),/+(tr;ctl@y@l)}
  6. TL:"ABEFGLMNOPVZ"
  7. `0:"p.61"
  8. :D:0 1 2 1 2 3 2 1 2 3 3 2 3 3 2
  9. sh[p@ \D;$!#D]
  10. `0:"p.71"
  11. :D:0 1 2 3 1 2 3 3 4 1 2 3 4 5 6 5 5 6 3 4 5 6 5 5 6 3 4
  12. T:3 1 0 7 1 2 9 0 10 1 3 1 2 0 10 9 0 10 1 2 0 10 9 0 10 0 10
  13. K:1 0 0 0 0 1 0 1 0 1 1 0 2 1 0 0 1 0 0 2 1 0 0 1 0 1 0
  14. X:0 -5 0 -6 -7 0 -8 0 -5 -9 0 -10 0 0 -1 -11 0 -5 -12 0 0 -10 -8 0 -10 0 -12
  15. sh[p@ \D;,/'+(TL@T;$K)]
  16. `0:"p.73"
  17. :D:0 1 2 3 1 2 3 3 4 1 2 3 4 5 6 5 5 6 3 4 5 6 5 5 6 3 4
  18. sh[p@ \D;$!#D]
  19. `0:"p.79"
  20. D:0 1 2 3 1 2 3 3 4 1 2 3 4 5 6 5 5 6 3 4 5 6 5 5 6 3 4
  21. P:0 0 1 2 0 4 5 5 7 0 9 10 11 12 13 12 12 16 10 18 19 20 19 19 23 10 25
  22. `0:"depth:"
  23. sh[p@ \D;$!#D]
  24. `0:"parent:"
  25. sh[P;$P]
  26. `0:"p.80"
  27. P:0 0 1 2 0 4 5 5 7 0 9 10 11 12 13 12 12 16 10 18 19 20 19 19 23 10 25
  28. T:3 1 0 7 1 2 9 0 10 1 3 1 2 0 10 9 0 10 1 2 0 10 9 0 10 0 10
  29. K:1 0 0 0 0 1 0 1 0 1 1 0 2 1 0 0 1 0 0 2 1 0 0 1 0 1 0
  30. X:0 -5 0 -6 -7 0 -8 0 -5 -10 0 -11 0 0 -1 -12 0 -5 -14 0 0 -11 -8 0 -11 0 -14
  31. sh[p@ \D;TL@T]
  32. `0:"p.82"
  33. D:0 1 2 1 2 3 2 1 2 3 3 2 3 3 2
  34. sh[p@ \D;$!#D]
  35. `0:"p.93"
  36. P:0 0 1 2 0 4 5 5 7 0 9 10 11 12 13 12 12 16 10 18 19 20 19 19 23 10 25
  37. T:3 1 0 7 1 2 9 0 10 1 3 1 2 0 10 9 0 10 1 2 0 10 9 0 10 0 10
  38. sh[P;TL@T]
  39. `0:"p.100"
  40. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  41. D:0 1 2 3 4 5 4 5 6 7 6 6 7 4 5 6 5 6 7 8
  42. P:0 0 1 2 3 4 3 6 7 8 7 7 11 3 13 14 13 16 17 18
  43. T:3 1 3 2 0 10 3 2 0 10 9 0 10 2 0 10 3 2 0 10
  44. K:1 2 1 2 1 0 1 2 1 0 0 1 0 2 1 0 1 2 1 0
  45. N:0 -5 0 0 0 -2 0 0 0 -2 -6 0 -1 0 0 -2 0 0 0 -2
  46. I,:20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  47. D,:7 7 8 5 6 7 6 7 8 9 8 8 9 6 7
  48. P,:17 17 21 13 23 24 23 26 27 28 27 27 31 23 33
  49. T,:9 0 10 2 0 10 3 2 0 10 9 0 10 0 10
  50. K,:0 1 0 2 1 0 1 2 1 0 0 1 0 1 0
  51. N,:-6 0 -1 0 0 -2 0 0 0 -2 -6 0 -1 0 -1
  52. `0:"depth:"
  53. sh[p@ \D;TL@T]
  54. `0:"parent:"
  55. sh[P;TL@T]
  56. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
  57. P:0 0 1 35 3 4 3 36 7 8 7 7 11 3 13 14 13 37 17 18 17 17
  58. T:3 1 10 2 0 10 10 2 0 10 9 0 10 2 0 10 10 2 0 10 9 0
  59. K:1 2 1 2 1 0 1 2 1 0 0 1 0 2 1 0 1 2 1 0 0 1
  60. N:0 -5 35 0 0 -2 36 0 0 -2 -6 0 -1 0 0 -2 37 0 0 -2 -6 0
  61. R:0 0 0 35 35 35 35 36 36 36 36 36 36 35 35 35 35 37 37 37 37 37
  62. I,:22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
  63. P,:21 13 23 24 23 38 27 28 27 27 31 23 33 35 36 37 38
  64. T,:10 2 0 10 10 2 0 10 9 0 10 0 10 3 3 3 3
  65. K,:0 2 1 0 1 2 1 0 0 1 0 1 0 1 1 1 1
  66. N,:-1 0 0 -2 38 0 0 -2 -6 0 -1 0 -1 0 0 0 0
  67. R,:37 35 35 35 35 38 38 38 38 38 38 35 35 0 35 35 35
  68. `0:"resort parent vector"
  69. R:dfo[P]
  70. P:redo[ \P;R]
  71. sh[P;TL@T@<R]
  72. `0:"p.108"
  73. `0:"before:"
  74. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  75. P:0 0 1 15 3 3 5 6 15 8 15 10 11 10 10 15
  76. T:3 1 10 4 10 1 0 7 0 7 2 0 7 9 10 3
  77. K:0 1 1 0 0 0 0 0 0 0 2 0 0 1 0 1
  78. N:0 -5 15 0 -1 -6 0 -7 0 -8 0 0 -9 -10 -1 0
  79. R:0 0 0 15 15 15 15 15 15 15 15 15 15 15 15 0
  80. sh[P;TL@T]
  81. `0:"after:"
  82. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  83. P:0 0 1 2 19 4 4 6 7 8 19 10 11 19 13 14 15 14 14 19
  84. T:3 2 1 10 4 10 2 1 0 7 2 0 7 2 2 0 7 9 10 3
  85. K:0 -1 1 1 0 0 0 0 0 0 0 0 0 0 2 0 0 1 0 1
  86. N:0 -5 -5 19 0 -1 -6 -6 0 -7 0 0 -8 0 0 0 -9 -10 -1 0
  87. R:0 0 0 0 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 0
  88. sh[P;TL@T]
  89. `0:"p.110"
  90. P:0 0 1 15 3 3 5 6 15 8 15 10 11 10 10 15
  91. T:3 1 10 4 10 1 0 7 0 7 2 0 7 9 10 3
  92. sh[P;TL@T]
  93. /
  94. / ---- Not valid yet ----
  95. `0:"p.112"
  96. P:0 0 0 1 15 3 3 3 5 6 15 15 8 15 15 10 11 10 10 15
  97. T:3 1 1 10 4 10 1 1 0 7 0 0 7 2 2 0 7 9 10 3
  98. K:0 1 1 1 0 0 0 0 0 0 0 0 0 2 2 0 0 1 0 1
  99. N:0 -5 -5 15 0 -1 -6 -6 0 -7 0 0 -8 0 0 0 -9 -10 -1 0
  100. R:0 0 0 0 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 0
  101. `0:"resort parent vector"
  102. R:dfo[P]
  103. \
  104. `0:"p.113"
  105. P:0 0 0 2 19 4 4 4 7 8 19 19 11 19 19 14 15 14 14 19
  106. R:0 0 0 0 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 0
  107. I:2 11 14 7
  108. sh[P;$R]
  109. `0:"p.114"
  110. P:0 0 0 2 19 4 4 4 7 8 19 19 11 19 19 14 15 14 14 19
  111. sh[P;$!#P]
  112. P:0 0 1 2 19 4 4 6 7 8 19 10 11 19 13 14 15 14 14 19
  113. sh[P;$!#P]
  114. `0:"p.117"
  115. `0:"before:"
  116. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  117. P:0 0 1 2 20 4 4 6 7 20 9 10 10 10 9 14 15 20 17 18 20
  118. T:3 2 1 10 4 10 2 0 7 4 2 10 9 10 2 0 7 2 0 7 3
  119. K:0 -1 1 1 0 0 0 0 0 0 2 0 1 0 0 0 0 0 0 0 1
  120. N:0 -5 -5 20 0 -1 0 0 0 0 0 -2 -6 -1 0 0 -7 0 0 -8 0
  121. R:0 0 0 0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0
  122. sh[P;TL@T]
  123. `0:"after:"
  124. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  125. P:0 0 1 2 20 20 5 6 7 20 20 9 9 9 10 14 15 20 17 18 20
  126. T:3 2 1 10 10 4 2 0 7 2 4 10 9 10 2 0 7 2 0 7 3
  127. K:0 -1 1 1 0 0 0 0 0 2 0 0 1 0 0 0 0 0 0 0 1
  128. N:0 -5 -5 20 -1 -1 0 0 0 0 0 -2 -6 -1 0 0 -7 0 0 -8 0
  129. R:0 0 0 0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0
  130. sh[P;TL@T]
  131. `0:"p.118"
  132. P:0 0 1 2 20 4 4 6 7 20 9 10 10 10 9 14 15 20 17 18 20
  133. sh[P;$!#P]
  134. `0:"p.121"
  135. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  136. P:0 0 1 2 53 4 5 5 5 8 9 0 11 12 54 14 15 15 15 18
  137. T:3 2 1 10 2 2 10 9 2 0 9 2 1 10 2 2 10 9 2 0
  138. K:0 -1 1 1 0 2 0 1 3 3 0 -1 1 1 0 2 0 1 3 3
  139. N:0 -5 -5 53 0 0 -1 -6 0 0 -7 -8 -8 54 0 0 -1 -6 0 0
  140. R:0 0 0 0 53 53 53 53 53 53 53 0 0 0 54 54 54 54 54 54
  141. I,:20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  142. P,:19 18 21 0 23 24 55 26 27 27 27 30 31 30 33 30 35 0 37 38
  143. T,:9 0 9 2 1 10 2 2 10 9 2 0 9 0 9 0 9 2 1 10
  144. K,:0 3 0 -1 1 1 0 2 0 1 3 3 0 3 0 3 0 -1 1 1
  145. N,:-7 0 -7 -9 -9 55 0 0 -1 -6 0 0 -7 0 -7 0 -7 -10 -10 56
  146. R,:54 54 54 0 0 0 55 55 55 55 55 55 55 55 55 55 55 0 0 0
  147. I,:40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  148. P,:56 40 41 41 41 44 45 44 47 44 49 44 51 53 54 55 56
  149. T,:2 2 10 9 2 0 9 0 9 0 9 0 9 3 3 3 3
  150. K,:0 2 0 1 3 3 0 3 0 3 0 3 0 1 1 1 1
  151. N,:0 0 -1 -6 0 0 -7 0 -7 0 -7 0 -7 0 0 0 0
  152. R,:56 56 56 56 56 56 56 56 56 56 56 56 56 0 0 0 0
  153. `0:"resort parent vector"
  154. R:dfo[P]
  155. P:redo[ \P;R]
  156. sh[P;TL@T@<R]
  157. P:0 0 1 2 53 4 5 5 5 8 9 0 11 12 54 14 15 15 15 18 19 18 21 0
  158. P,:23 24 55 26 27 27 27 30 31 30 33 30 35 0 37 38 56 40 41
  159. P,:41 41 44 45 44 47 44 49 44 51 53 54 55 56
  160. `0:"resort parent vector"
  161. R:dfo[P]
  162. P:redo[ \P;R]
  163. sh[P;TL@T@<R]
  164. `0:"p.123"
  165. `0:"before:"
  166. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  167. P:0 0 1 2 24 4 5 6 6 6 24 10 11 12 13 13 12 16 16 16
  168. T:3 2 1 10 2 1 2 10 9 10 2 2 2 8 9 9 2 10 9 0
  169. K:0 -1 1 1 -1 0 2 0 1 0 0 2 1 2 2 1 2 0 1 0
  170. N:0 -5 -5 24 -6 -6 0 -2 -7 -1 0 0 0 0 -8 -9 0 -6 -10 0
  171. R:0 0 0 0 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
  172. I,:20 21 22 23 24
  173. P,:19 11 11 22 24
  174. T,:7 9 0 7 3
  175. K,:0 1 0 0 1
  176. N,:-11 -10 0 -12 0
  177. R,:24 24 24 24 0
  178. sh[P;TL@T]
  179. `0:"after:"
  180. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  181. P:0 0 0 0 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
  182. T:3 10 1 2 10 9 10 2 1 2 0 9 0 9 10 2 9 9 8
  183. K:0 1 1 -1 0 1 0 2 0 -1 0 1 0 1 0 2 1 2 2
  184. N:0 24 -5 -5 -1 -7 -2 0 -6 -6 0 -10 0 -10 -6 0 -9 -8 0
  185. R:0 0 0 0 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
  186. I,:19 20 21 22 23 24
  187. P,:24 12 24 24 10 24
  188. T,:2 7 2 2 7 3
  189. K,:1 0 2 0 0 1
  190. N,:0 -11 0 0 -12 0
  191. R,:24 24 24 24 24 0
  192. sh[P;TL@T]
  193. `0:"p.131"
  194. D:0 1 2 3 4 5 6 7 7 7 5 6 6 6 3 4 5 5 5 3 4 5 5 5 6 3 4 4 0 0 0 0 0 0 0 0 0
  195. sh[p@ \D;$!#D]
  196. `0:"p.137"
  197. I:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  198. P:0 0 0 0 44 44 44 4 44 44 44 44 45 45 12 45 45 45 45 45
  199. T:3 10 1 2 0 1 2 7 0 10 2 2 0 1 7 2 0 10 2 2
  200. K:0 1 1 -1 0 0 -1 0 0 1 1 0 0 0 0 -1 0 1 1 0
  201. N:1 44 -5 -5 0 -6 -6 -7 0 45 0 0 0 -8 -9 -8 0 46 0 0
  202. R:0 0 0 0 44 44 44 44 44 44 44 44 45 45 45 45 45 45 45 45
  203. I,:20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  204. P,:46 46 46 46 46 46 46 46 46 46 26 46 46 46 46 46
  205. T,:10 9 10 2 1 2 0 9 10 2 7 1 2 10 9 10
  206. K,:0 1 0 2 0 -1 0 1 0 2 0 0 -1 0 1 0
  207. N,:-6 -11 -8 0 -10 -10 0 -11 -10 0 -12 -8 -8 -8 -11 -8
  208. R,:46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46
  209. I,:36 37 38 39 40 41 42 43 44 45 46
  210. P,:46 46 46 46 46 46 46 46 44 45 46
  211. T,:2 1 2 10 9 10 2 2 3 3 3
  212. K,:2 0 -1 0 1 0 2 0 1 1 1
  213. N,:0 -6 -6 -6 -11 -6 0 0 1 1 3
  214. R,:46 46 46 46 46 46 46 46 0 44 45
  215. `0:"resort parent vector"
  216. R:dfo[P]
  217. P:redo[ \P;R]
  218. sh[P;TL@T@<R]
  219. `0:"p.184"
  220. P:0 0 1 2 0 4 5 5 7 0 9 10 11 12 13 12 12 16 10 18 19 20 19 19 23 10 25
  221. sh[P;$!#P]
  222. `0:"p.185"
  223. P:0 0 1 2 0 4 5 5 7 8 9 8 8 12 5 14
  224. sh[P;$!#P]