@@ -1188,35 +1188,6 @@ class Solution:
11881188 return head
11891189```
11901190
1191- ``` python
1192- class ListNode :
1193- def __init__ (self , x ):
1194- self .val = x
1195- self .next = None
1196-
1197- class nonrecurse (head ):
1198- if head is None or head.next is None :
1199- return head
1200- pre = None
1201- cur = head
1202- h = head
1203- while cur:
1204- h = cur
1205-
1206- temp = cur.next
1207- cur.next = pre
1208-
1209- pre = cur
1210- cur = temp
1211- return h
1212-
1213-
1214- ```
1215-
1216- 思路: http://blog.csdn.net/feliciafay/article/details/6841115
1217- 方法: http://www.xuebuyuan.com/2066385.html?mobile=1
1218-
1219-
12201191## 7 创建字典的方法
12211192
12221193### 1 直接创建
@@ -1503,6 +1474,47 @@ if __name__ == '__main__':
15031474
15041475深度遍历改变顺序就OK了
15051476
1477+ ``` python
1478+
1479+ # coding:utf-8
1480+ # 二叉树的遍历
1481+ # 简单的二叉树节点类
1482+ class Node (object ):
1483+ def __init__ (self ,value ,left ,right ):
1484+ self .value = value
1485+ self .left = left
1486+ self .right = right
1487+
1488+ # 中序遍历:遍历左子树,访问当前节点,遍历右子树
1489+
1490+ def mid_travelsal (root ):
1491+ if root.left is None :
1492+ mid_travelsal(root.left)
1493+ # 访问当前节点
1494+ print (root.value)
1495+ if root.right is not None :
1496+ mid_travelsal(root.right)
1497+
1498+ # 前序遍历:访问当前节点,遍历左子树,遍历右子树
1499+
1500+ def pre_travelsal (root ):
1501+ print (root.value)
1502+ if root.left is not None :
1503+ pre_travelsal(root.left)
1504+ if root.right is not None :
1505+ pre_travelsal(root.right)
1506+
1507+ # 后续遍历:遍历左子树,遍历右子树,访问当前节点
1508+
1509+ def post_trvelsal (root ):
1510+ if root.left is not None :
1511+ post_trvelsal(root.left)
1512+ if root.right is not None :
1513+ post_trvelsal(root.right)
1514+ print (root.value)
1515+
1516+ ```
1517+
15061518## 18 求最大树深
15071519
15081520``` python
@@ -1573,6 +1585,11 @@ while root:
15731585 root = root.next
15741586```
15751587
1588+ 思路: http://blog.csdn.net/feliciafay/article/details/6841115
1589+
1590+ 方法: http://www.xuebuyuan.com/2066385.html?mobile=1
1591+
1592+
15761593## 22 两个字符串是否是变位词
15771594
15781595``` python
0 commit comments