@@ -58,9 +58,9 @@ def _is_bst(root, min_value=float('-inf'), max_value=float('inf')):
58
58
59
59
60
60
def _is_symmetric (root ):
61
- """Check if the binary tree is symmetric
61
+ """Check if the binary tree is symmetric.
62
62
63
- :param root: Root node of the binary tree
63
+ :param root: Root node of the binary tree.
64
64
:type root: binarytree.Node | None
65
65
:return: True if the binary tree is symmetric, False otherwise.
66
66
:rtype: bool
@@ -323,7 +323,7 @@ class Node(object):
323
323
current node and its descendants.
324
324
325
325
:param value: Node value (must be a number).
326
- :type value: int | float
326
+ :type value: int | float | numbers.Number
327
327
:param left: Left child node (default: None).
328
328
:type left: binarytree.Node | None
329
329
:param right: Right child node (default: None).
@@ -1128,7 +1128,9 @@ def is_bst(self):
1128
1128
def is_symmetric (self ):
1129
1129
"""Check if the binary tree is symmetric.
1130
1130
1131
- * Left subtree is a mirror of the right subtree around the center
1131
+ A binary tree is symmetric if it meets the following criteria:
1132
+
1133
+ * Left subtree is a mirror of the right subtree about the root node.
1132
1134
1133
1135
:return: True if the binary tree is a symmetric, False otherwise.
1134
1136
:rtype: bool
@@ -1138,13 +1140,15 @@ def is_symmetric(self):
1138
1140
.. doctest::
1139
1141
1140
1142
>>> from binarytree import Node
1143
+ >>>
1141
1144
>>> root = Node(1)
1142
1145
>>> root.left = Node(2)
1143
1146
>>> root.right = Node(2)
1144
1147
>>> root.left.left = Node(3)
1145
1148
>>> root.left.right = Node(4)
1146
1149
>>> root.right.left = Node(4)
1147
1150
>>> root.right.right = Node(3)
1151
+ >>>
1148
1152
>>> print(root)
1149
1153
<BLANKLINE>
1150
1154
__1__
0 commit comments