Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
sheroz committed Sep 30, 2023
1 parent 65ced35 commit 161ff7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

Tree and parent-child relationship samples for learning purposes

- [Generic Tree](src/generic_tree.rs)
- [Binary Tree](src/binary_tree.rs)
- Traversal
- In-order
- Inverting
- Recursive
- Iterative
- [Binary Search Tree](src/binary_search_tree.rs)
- Search
- [Generic Tree](src/generic_tree.rs)

## Useful insights

Expand Down
8 changes: 4 additions & 4 deletions src/binary_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ impl BinaryTree {
}

// swap child nodes
let tmp = node.right.clone();
node.right = node.left.clone();
let tmp = node.right.take();
node.right = node.left.take();
node.left = tmp;
}

Expand All @@ -220,8 +220,8 @@ impl BinaryTree {
}

// swap child nodes
let tmp = node.right.clone();
node.right = node.left.clone();
let tmp = node.right.take();
node.right = node.left.take();
node.left = tmp;
}
}
Expand Down

0 comments on commit 161ff7d

Please sign in to comment.