data_structures.binary_tree.is_sum_tree ======================================= .. py:module:: data_structures.binary_tree.is_sum_tree .. autoapi-nested-parse:: Is a binary tree a sum tree where the value of every non-leaf node is equal to the sum of the values of its left and right subtrees? https://www.geeksforgeeks.org/check-if-a-given-binary-tree-is-sumtree Attributes ---------- .. autoapisummary:: data_structures.binary_tree.is_sum_tree.tree Classes ------- .. autoapisummary:: data_structures.binary_tree.is_sum_tree.BinaryTree data_structures.binary_tree.is_sum_tree.Node Module Contents --------------- .. py:class:: BinaryTree .. py:method:: __iter__() -> collections.abc.Iterator[int] >>> list(BinaryTree.build_a_tree()) [1, 2, 7, 11, 15, 29, 35, 40] .. py:method:: __len__() -> int >>> len(BinaryTree.build_a_tree()) 8 .. py:method:: __str__() -> str Returns a string representation of the inorder traversal of the binary tree. >>> str(list(BinaryTree.build_a_tree())) '[1, 2, 7, 11, 15, 29, 35, 40]' .. py:method:: build_a_sum_tree() -> BinaryTree :classmethod: Create a binary tree with the specified structure: 26 / \ 10 3 / \ \ 4 6 3 >>> list(BinaryTree.build_a_sum_tree()) [4, 10, 6, 26, 3, 3] .. py:method:: build_a_tree() -> BinaryTree :classmethod: Create a binary tree with the specified structure: 11 / \ 2 29 / \ / \ 1 7 15 40 \ 35 >>> list(BinaryTree.build_a_tree()) [1, 2, 7, 11, 15, 29, 35, 40] .. py:property:: is_sum_tree :type: bool >>> BinaryTree.build_a_tree().is_sum_tree False >>> BinaryTree.build_a_sum_tree().is_sum_tree True .. py:attribute:: root :type: Node .. py:class:: Node .. py:method:: __iter__() -> collections.abc.Iterator[int] >>> root = Node(2) >>> list(root) [2] >>> root.left = Node(1) >>> tuple(root) (1, 2) .. py:method:: __len__() -> int >>> root = Node(2) >>> len(root) 1 >>> root.left = Node(1) >>> len(root) 2 .. py:attribute:: data :type: int .. py:property:: is_sum_node :type: bool >>> root = Node(3) >>> root.is_sum_node True >>> root.left = Node(1) >>> root.is_sum_node False >>> root.right = Node(2) >>> root.is_sum_node True .. py:attribute:: left :type: Node | None :value: None .. py:attribute:: right :type: Node | None :value: None .. py:data:: tree