Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions bst.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,10 @@ def _rotate_right(self):
if self.left is not None:
self.left.parent = self
pivot.left = pivot.right
if pivot.left is not None:
pivot.left.parent = pivot
pivot.right = self.right
if pivot.right is not None:
pivot.right.parent = pivot
self.right, pivot.parent = pivot, self
self.right = pivot

def _rotate_left(self):
"""Perform a single left tree rotation."""
Expand All @@ -292,12 +290,10 @@ def _rotate_left(self):
if self.right is not None:
self.right.parent = self
pivot.right = pivot.left
if pivot.right is not None:
pivot.right.parent = pivot
pivot.left = self.left
if pivot.left is not None:
pivot.left.parent = pivot
self.left, pivot.parent = pivot, self
self.left = pivot

def _self_balance(self):
"""Balance the subtree from given node."""
Expand Down