Skip to content

Fix typo in Rust tree traversal #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions contents/tree_traversal/code/rust/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn dfs_recursive(n: &Node) {

fn dfs_recursive_postorder(n: &Node) {
for child in &n.children {
dfs_recursive(child);
dfs_recursive_postorder(child);
}

println!("{}", n.value);
Expand Down Expand Up @@ -69,15 +69,16 @@ fn create_tree(num_row: u64, num_child: u64) -> Node {
}

fn main() {
let root = create_tree(3,2);
let root = create_tree(2, 3);
println!("Recursive DFS:");
dfs_recursive(&root);
println!("Stack DFS:");
dfs_stack(&root);
println!("Queue BFS:");
bfs_queue(&root);
println!("Recursive PostOrder DFS: ");
println!("Recursive post-order DFS:");
dfs_recursive_postorder(&root);
println!("Recursive DFS BTree:");
dfs_recursive_inorder_btree(&root);
println!("Recursive in-order DFS BTree:");
let root_binary = create_tree(3, 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just have one tree.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to test the in-order, you need a binary tree. The other tree is ternary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep the other tree binary too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Julia code and chapter show examples with ternary, though. Not a big deal to me, but I'm not actually reviewing the code, just answering one question :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right it, should match the julia code.

dfs_recursive_inorder_btree(&root_binary);
}