Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Node toBeRemoved = root;
- Node parent = null;
- boolean found = false;
- while (!found && toBeRemoved != null) {
- if (toBeRemoved.right == null) {
- found = true;
- } else {
- parent = toBeRemoved;
- toBeRemoved = toBeRemoved.right;
- }
- }
- if (found) {
- if(toBeRemoved.left == null) {
- parent.right = null;
- } else {
- parent.right = toBeRemoved.left;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement