Advertisement
NLinker

RB tree insert 1..6 (debug log)

Jul 9th, 2017
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. λ> test
  2. >>> insert x t = T B [ins 1 E]
  3. E 1 E
  4. >>> insert x t = T B [ins 2 (T B E 1 E)]
  5.   [ins 2 E]
  6.   [balance B E 1 (T R E 2 E)]
  7.      => (T B E 1 (T R E 2 E))
  8. E 1 (T R E 2 E)
  9. >>> insert x t = T B [ins 3 (T B E 1 (T R E 2 E))]
  10.   [ins 3 (T R E 2 E)]
  11.     [ins 3 E]
  12.     [balance R E 2 (T R E 3 E)]
  13.        => (T R E 2 (T R E 3 E))
  14.   [balance B E 1 (T R E 2 (T R E 3 E))]
  15.      => (T R (T B E 1 E) 2 (T B E 3 E))
  16. (T B E 1 E) 2 (T B E 3 E)
  17. >>> insert x t = T B [ins 4 (T B (T B E 1 E) 2 (T B E 3 E))]
  18.   [ins 4 (T B E 3 E)]
  19.     [ins 4 E]
  20.     [balance B E 3 (T R E 4 E)]
  21.        => (T B E 3 (T R E 4 E))
  22.   [balance B (T B E 1 E) 2 (T B E 3 (T R E 4 E))]
  23.      => (T B (T B E 1 E) 2 (T B E 3 (T R E 4 E)))
  24. (T B E 1 E) 2 (T B E 3 (T R E 4 E))
  25. >>> insert x t = T B [ins 5 (T B (T B E 1 E) 2 (T B E 3 (T R E 4 E)))]
  26.   [ins 5 (T B E 3 (T R E 4 E))]
  27.     [ins 5 (T R E 4 E)]
  28.       [ins 5 E]
  29.       [balance R E 4 (T R E 5 E)]
  30.          => (T R E 4 (T R E 5 E))
  31.     [balance B E 3 (T R E 4 (T R E 5 E))]
  32.        => (T R (T B E 3 E) 4 (T B E 5 E))
  33.   [balance B (T B E 1 E) 2 (T R (T B E 3 E) 4 (T B E 5 E))]
  34.      => (T B (T B E 1 E) 2 (T R (T B E 3 E) 4 (T B E 5 E)))
  35. (T B E 1 E) 2 (T R (T B E 3 E) 4 (T B E 5 E))
  36. >>> insert x t = T B [ins 6 (T B (T B E 1 E) 2 (T R (T B E 3 E) 4 (T B E 5 E)))]
  37.   [ins 6 (T R (T B E 3 E) 4 (T B E 5 E))]
  38.     [ins 6 (T B E 5 E)]
  39.       [ins 6 E]
  40.       [balance B E 5 (T R E 6 E)]
  41.          => (T B E 5 (T R E 6 E))
  42.     [balance R (T B E 3 E) 4 (T B E 5 (T R E 6 E))]
  43.        => (T R (T B E 3 E) 4 (T B E 5 (T R E 6 E)))
  44.   [balance B (T B E 1 E) 2 (T R (T B E 3 E) 4 (T B E 5 (T R E 6 E)))]
  45.      => (T B (T B E 1 E) 2 (T R (T B E 3 E) 4 (T B E 5 (T R E 6 E))))
  46. (T B E 1 E) 2 (T R (T B E 3 E) 4 (T B E 5 (T R E 6 E)))
  47. >>> insert x t = T B [ins 7 (T B (T B E 1 E) 2 (T R (T B E 3 E) 4 (T B E 5 (T R E 6 E))))]
  48.   [ins 7 (T R (T B E 3 E) 4 (T B E 5 (T R E 6 E)))]
  49.     [ins 7 (T B E 5 (T R E 6 E))]
  50.       [ins 7 (T R E 6 E)]
  51.         [ins 7 E]
  52.         [balance R E 6 (T R E 7 E)]
  53.            => (T R E 6 (T R E 7 E))
  54.       [balance B E 5 (T R E 6 (T R E 7 E))]
  55.          => (T R (T B E 5 E) 6 (T B E 7 E))
  56.     [balance R (T B E 3 E) 4 (T R (T B E 5 E) 6 (T B E 7 E))]
  57.        => (T R (T B E 3 E) 4 (T R (T B E 5 E) 6 (T B E 7 E)))
  58.   [balance B (T B E 1 E) 2 (T R (T B E 3 E) 4 (T R (T B E 5 E) 6 (T B E 7 E)))]
  59.      => (T R (T B (T B E 1 E) 2 (T B E 3 E)) 4 (T B (T B E 5 E) 6 (T B E 7 E)))
  60. (T B (T B E 1 E) 2 (T B E 3 E)) 4 (T B (T B E 5 E) 6 (T B E 7 E))
  61. >>> final = T B (T B (T B E 1 E) 2 (T B E 3 E)) 4 (T B (T B E 5 E) 6 (T B E 7 E))
  62. λ>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement