data_structures.binary_tree.basic_binary_tree ============================================= .. py:module:: data_structures.binary_tree.basic_binary_tree Classes ------- .. autoapisummary:: data_structures.binary_tree.basic_binary_tree.BinaryTree data_structures.binary_tree.basic_binary_tree.Node Module Contents --------------- .. py:class:: BinaryTree .. py:method:: __iter__() -> collections.abc.Iterator[int] .. py:method:: __len__() -> int .. py:method:: _depth(node: Node | None) -> int .. py:method:: depth() -> int Returns the depth of the tree >>> BinaryTree(Node(1)).depth() 1 >>> BinaryTree.small_tree().depth() 2 >>> BinaryTree.medium_tree().depth() 4 .. py:method:: is_full() -> bool Returns True if the tree is full >>> BinaryTree(Node(1)).is_full() True >>> BinaryTree.small_tree().is_full() True >>> BinaryTree.medium_tree().is_full() False .. py:method:: medium_tree() -> BinaryTree :classmethod: Return a medium binary tree with 3 nodes. >>> binary_tree = BinaryTree.medium_tree() >>> len(binary_tree) 7 >>> list(binary_tree) [1, 2, 3, 4, 5, 6, 7] .. py:method:: small_tree() -> BinaryTree :classmethod: Return a small binary tree with 3 nodes. >>> binary_tree = BinaryTree.small_tree() >>> len(binary_tree) 3 >>> list(binary_tree) [1, 2, 3] .. py:attribute:: root :type: Node .. py:class:: Node .. py:method:: __iter__() -> collections.abc.Iterator[int] .. py:method:: __len__() -> int .. py:method:: is_full() -> bool .. py:attribute:: data :type: int .. py:attribute:: left :type: Node | None :value: None .. py:attribute:: right :type: Node | None :value: None