mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 02:13:15 +08:00
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort * Fixed doctest error due whitespace * reduce loop times for optimization * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -109,7 +109,7 @@ def right_rotation(node):
|
||||
|
||||
def left_rotation(node):
|
||||
"""
|
||||
a mirror symmetry rotation of the left_rotation
|
||||
a mirror symmetry rotation of the left_rotation
|
||||
"""
|
||||
print("right rotation node:", node.get_data())
|
||||
ret = node.get_right()
|
||||
|
@ -28,11 +28,11 @@ class RedBlackTree:
|
||||
right: Optional["RedBlackTree"] = None,
|
||||
) -> None:
|
||||
"""Initialize a new Red-Black Tree node with the given values:
|
||||
label: The value associated with this node
|
||||
color: 0 if black, 1 if red
|
||||
parent: The parent to this node
|
||||
left: This node's left child
|
||||
right: This node's right child
|
||||
label: The value associated with this node
|
||||
color: 0 if black, 1 if red
|
||||
parent: The parent to this node
|
||||
left: This node's left child
|
||||
right: This node's right child
|
||||
"""
|
||||
self.label = label
|
||||
self.parent = parent
|
||||
|
@ -118,7 +118,7 @@ def inorder(root: Node):
|
||||
return
|
||||
else:
|
||||
inorder(root.left)
|
||||
print(root.value, end=" ")
|
||||
print(root.value, end=",")
|
||||
inorder(root.right)
|
||||
|
||||
|
||||
@ -130,19 +130,19 @@ def interactTreap(root, args):
|
||||
|
||||
>>> root = interactTreap(None, "+1")
|
||||
>>> inorder(root)
|
||||
1
|
||||
1,
|
||||
>>> root = interactTreap(root, "+3 +5 +17 +19 +2 +16 +4 +0")
|
||||
>>> inorder(root)
|
||||
0 1 2 3 4 5 16 17 19
|
||||
0,1,2,3,4,5,16,17,19,
|
||||
>>> root = interactTreap(root, "+4 +4 +4")
|
||||
>>> inorder(root)
|
||||
0 1 2 3 4 4 4 4 5 16 17 19
|
||||
0,1,2,3,4,4,4,4,5,16,17,19,
|
||||
>>> root = interactTreap(root, "-0")
|
||||
>>> inorder(root)
|
||||
1 2 3 4 4 4 4 5 16 17 19
|
||||
1,2,3,4,4,4,4,5,16,17,19,
|
||||
>>> root = interactTreap(root, "-4")
|
||||
>>> inorder(root)
|
||||
1 2 3 5 16 17 19
|
||||
1,2,3,5,16,17,19,
|
||||
>>> root = interactTreap(root, "=0")
|
||||
Unknown command
|
||||
"""
|
||||
|
Reference in New Issue
Block a user