algorithm - Calculating height of tree provided condition on height of left tree and height of right tree -
suppose denote leftheight(u) , rightheight(u) heights of left , right subtrees of node u.
now if have constant c > 0 such nodes u in tree t, have
leftheight(u) ≤ rightheight(u) + c what can said height of such tree ? o(log n) or ?
also, if condition had been changed :
leftheight(u)−c ≤ rightheight(u) ≤ leftheight(u) + c how affect height of tree ?
to answer first pat of question, height not o(log n). consider tree n nodes degenerated a list by; every node u, left subtree empty , each node (except single leaf) has nonempty right subtree, in following sketch.
\ b \ c the inequality
leftheight(u) ≤ rightheight(u) + c holds every constant c, yet height of tree n.
Comments
Post a Comment