mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
fix fake code error of traversal
This commit is contained in:
parent
dc1047df72
commit
e977158c8b
@ -223,7 +223,7 @@ end findMax
|
|||||||
inorder(root)
|
inorder(root)
|
||||||
Pre: root is the root node of the BST
|
Pre: root is the root node of the BST
|
||||||
Post: the nodes in the BST have been visited in inorder
|
Post: the nodes in the BST have been visited in inorder
|
||||||
if root = ø
|
if root != ø
|
||||||
inorder(root.left)
|
inorder(root.left)
|
||||||
yield root.value
|
yield root.value
|
||||||
inorder(root.right)
|
inorder(root.right)
|
||||||
@ -237,7 +237,7 @@ end inorder
|
|||||||
preorder(root)
|
preorder(root)
|
||||||
Pre: root is the root node of the BST
|
Pre: root is the root node of the BST
|
||||||
Post: the nodes in the BST have been visited in preorder
|
Post: the nodes in the BST have been visited in preorder
|
||||||
if root = ø
|
if root != ø
|
||||||
yield root.value
|
yield root.value
|
||||||
preorder(root.left)
|
preorder(root.left)
|
||||||
preorder(root.right)
|
preorder(root.right)
|
||||||
@ -251,7 +251,7 @@ end preorder
|
|||||||
postorder(root)
|
postorder(root)
|
||||||
Pre: root is the root node of the BST
|
Pre: root is the root node of the BST
|
||||||
Post: the nodes in the BST have been visited in postorder
|
Post: the nodes in the BST have been visited in postorder
|
||||||
if root = ø
|
if root != ø
|
||||||
postorder(root.left)
|
postorder(root.left)
|
||||||
postorder(root.right)
|
postorder(root.right)
|
||||||
yield root.value
|
yield root.value
|
||||||
|
@ -222,7 +222,7 @@ end findMax
|
|||||||
inorder(root)
|
inorder(root)
|
||||||
Pre: root is the root node of the BST
|
Pre: root is the root node of the BST
|
||||||
Post: the nodes in the BST have been visited in inorder
|
Post: the nodes in the BST have been visited in inorder
|
||||||
if root = ø
|
if root != ø
|
||||||
inorder(root.left)
|
inorder(root.left)
|
||||||
yield root.value
|
yield root.value
|
||||||
inorder(root.right)
|
inorder(root.right)
|
||||||
@ -236,7 +236,7 @@ end inorder
|
|||||||
preorder(root)
|
preorder(root)
|
||||||
Pre: root is the root node of the BST
|
Pre: root is the root node of the BST
|
||||||
Post: the nodes in the BST have been visited in preorder
|
Post: the nodes in the BST have been visited in preorder
|
||||||
if root = ø
|
if root != ø
|
||||||
yield root.value
|
yield root.value
|
||||||
preorder(root.left)
|
preorder(root.left)
|
||||||
preorder(root.right)
|
preorder(root.right)
|
||||||
@ -250,7 +250,7 @@ end preorder
|
|||||||
postorder(root)
|
postorder(root)
|
||||||
Pre: root is the root node of the BST
|
Pre: root is the root node of the BST
|
||||||
Post: the nodes in the BST have been visited in postorder
|
Post: the nodes in the BST have been visited in postorder
|
||||||
if root = ø
|
if root != ø
|
||||||
postorder(root.left)
|
postorder(root.left)
|
||||||
postorder(root.right)
|
postorder(root.right)
|
||||||
yield root.value
|
yield root.value
|
||||||
|
Loading…
Reference in New Issue
Block a user