MCPcopy
hub / github.com/joowani/binarytree / _generate_random_numbers

Function _generate_random_numbers

binarytree/__init__.py:1873–1884  ·  view source on GitHub ↗

Return random numbers for building binary trees. :param height: Height of the binary tree. :type height: int :return: Randomly generated node values. :rtype: [int]

(height: int)

Source from the content-addressed store, hash-verified

1871
1872
1873def _generate_random_numbers(height: int) -> List[int]:
1874 """Return random numbers for building binary trees.
1875
1876 :param height: Height of the binary tree.
1877 :type height: int
1878 :return: Randomly generated node values.
1879 :rtype: [int]
1880 """
1881 max_node_count = 2 ** (height + 1) - 1
1882 node_values = list(range(max_node_count))
1883 random.shuffle(node_values)
1884 return node_values
1885
1886
1887def _build_tree_string(

Callers 3

treeFunction · 0.85
bstFunction · 0.85
heapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected