mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-06 22:34:18 +08:00
Bug fixes and improvements (#1298)
* Fix is_empty() implementation in the stack and queue chapter * Update en/CONTRIBUTING.md * Remove "剩余" from the state definition of knapsack problem * Sync zh and zh-hant versions * Update the stylesheets of code tabs * Fix quick_sort.rb * Fix TS code * Update chapter_paperbook * Upload the manuscript of 0.1 section * Fix binary_tree_dfs.rb * Bug fixes * Update README * Update README * Update README * Update README.md * Update README * Sync zh and zh-hant versions * Bug fixes
This commit is contained in:
@ -8,13 +8,13 @@ require_relative '../utils/tree_node'
|
||||
require_relative '../utils/print_util'
|
||||
|
||||
### 前序遍历 ###
|
||||
def pre_oder(root)
|
||||
def pre_order(root)
|
||||
return if root.nil?
|
||||
|
||||
# 访问优先级:根节点 -> 左子树 -> 右子树
|
||||
$res << root.val
|
||||
pre_oder(root.left)
|
||||
pre_oder(root.right)
|
||||
pre_order(root.left)
|
||||
pre_order(root.right)
|
||||
end
|
||||
|
||||
### 中序遍历 ###
|
||||
@ -47,7 +47,7 @@ if __FILE__ == $0
|
||||
|
||||
# 前序遍历
|
||||
$res = []
|
||||
pre_oder(root)
|
||||
pre_order(root)
|
||||
puts "\n前序遍历的节点打印序列 = #{$res}"
|
||||
|
||||
# 中序遍历
|
||||
|
Reference in New Issue
Block a user