r""" A B / \ / \ B C Bl A / \ --> / / \ Bl Br UB Br C / UB UB = unbalanced node
(node: MyNode)
| 85 | |
| 86 | |
| 87 | def right_rotation(node: MyNode) -> MyNode: |
| 88 | r""" |
| 89 | A B |
| 90 | / \ / \ |
| 91 | B C Bl A |
| 92 | / \ --> / / \ |
| 93 | Bl Br UB Br C |
| 94 | / |
| 95 | UB |
| 96 | UB = unbalanced node |
| 97 | """ |
| 98 | print("left rotation node:", node.get_data()) |
| 99 | ret = node.get_left() |
| 100 | assert ret is not None |
| 101 | node.set_left(ret.get_right()) |
| 102 | ret.set_right(node) |
| 103 | h1 = my_max(get_height(node.get_right()), get_height(node.get_left())) + 1 |
| 104 | node.set_height(h1) |
| 105 | h2 = my_max(get_height(ret.get_right()), get_height(ret.get_left())) + 1 |
| 106 | ret.set_height(h2) |
| 107 | return ret |
| 108 | |
| 109 | |
| 110 | def left_rotation(node: MyNode) -> MyNode: |
no test coverage detected