sorts.tree_sort

Tree_sort algorithm.

Build a Binary Search Tree and then iterate thru it to get a sorted list.

Classes

Node

Functions

tree_sort(→ tuple[int, Ellipsis])

Module Contents

class sorts.tree_sort.Node
__iter__() collections.abc.Iterator[int]
__len__() int
insert(val: int) None
left: Node | None = None
right: Node | None = None
val: int
sorts.tree_sort.tree_sort(arr: list[int]) tuple[int, Ellipsis]
>>> tree_sort([])
()
>>> tree_sort((1,))
(1,)
>>> tree_sort((1, 2))
(1, 2)
>>> tree_sort([5, 2, 7])
(2, 5, 7)
>>> tree_sort((5, -4, 9, 2, 7))
(-4, 2, 5, 7, 9)
>>> tree_sort([5, 6, 1, -1, 4, 37, 2, 7])
(-1, 1, 2, 4, 5, 6, 7, 37)

# >>> tree_sort(range(10, -10, -1)) == tuple(sorted(range(10, -10, -1))) # True