Function height of tree n

Height of the tree n

Format:

height of tree n

Input:

list n -

Output:

number - None

Properties that reference this function:

height of tree tree = Height of a tree tree and index 0 (height help)
height of tree (node (v, None, None)) = 1 (height of 1 node)
height of tree (node (v, (node (l, ll, lr)), None)) = (height of tree (node (l, ll, lr))) + 1 (height of left plus 1)
height of tree (node (v, None, (node (r, rl, rr)))) = (height of tree (node (r, rl, rr))) + 1 (height of right plus 1)

Conditional properties that reference this function:

  • if height of tree left > height of tree right, then height of tree (node (v, left, right)) = (height of tree left) + 1 (link)
  • if height of tree left < height of tree right, then height of tree (node (v, left, right)) = (height of tree right) + 1 (link)
  • if height of tree left = height of tree right, then height of tree (node (v, left, right)) = (height of tree left) + 1 (link)
  • if the following are true:
    • height of tree (node (lv, ll, lr)) > (height of tree right) + 1
    • height of tree ll > height of tree lr

    then result of balancing the tree (node (v, (node (lv, ll, lr)), right)) = result of rotating (node (v, (node (lv, ll, lr)), right)) clockwise

    (link)
  • if the following are true:
    • height of tree (node (lv, ll, lr)) > (height of tree right) + 1
    • height of tree ll < height of tree lr

    then result of balancing the tree (node (v, (node (lv, ll, lr)), right)) = result of rotating (node (v, (node (lv, ll, lr)), right)) twice

    (link)


Comments

Please log in to add comments