Skip to content

Commit

Permalink
Fine tune
Browse files Browse the repository at this point in the history
  • Loading branch information
krahets committed Dec 27, 2022
1 parent 449258f commit f9cc3a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
10 changes: 5 additions & 5 deletions codes/python/include/binary_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
class TreeNode:
"""Definition for a binary tree node
"""
def __init__(self, val=None, left=None, right=None):
self.val = val # 结点值
self.height = 0 # 结点高度, avl 树会用到
self.left = left # 左子结点引用
def __init__(self, val=0, left=None, right=None):
self.val = val # 结点值
self.height = 0 # 结点高度
self.left = left # 左子结点引用
self.right = right # 右子结点引用

def __str__(self): # 直接print时会好看一点
def __str__(self):
val = self.val
left_node_val = self.left.val if self.left else None
right_node_val = self.right.val if self.right else None
Expand Down
7 changes: 0 additions & 7 deletions docs/chapter_tree/binary_tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ comments: true
self.val = val # 结点值
self.left = left # 左子结点指针
self.right = right # 右子结点指针

def __str__(self):
val = self.val
left_node_val = self.left.val if self.left else None
right_node_val = self.right.val if self.right else None
return "<TreeNode: {}, leftTreeNode: {}, rightTreeNode: {}>".format(val, left_node_val, right_node_val)

```

=== "Go"
Expand Down

0 comments on commit f9cc3a5

Please sign in to comment.