Skip to content

Commit

Permalink
Merge pull request #11 from sheroz/sheroz-patch
Browse files Browse the repository at this point in the history
refactored
  • Loading branch information
sheroz committed Sep 30, 2023
2 parents 65ced35 + 161ff7d commit 352f801
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 352f801

Please sign in to comment.