-
Notifications
You must be signed in to change notification settings - Fork 0
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
new branch with list and intermidiate solution of linked list #1
base: main
Are you sure you want to change the base?
Conversation
addNode.left = null; | ||
addNode.right = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's redundant initialisation
addNode.left = null; | |
addNode.right = null; |
if (value > thisNode.value) thisNode = thisNode.right; | ||
if (value <= thisNode.value) thisNode = thisNode.left; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use curly brackets for one-line if, please
if (value > thisNode.value) thisNode = thisNode.right; | |
if (value <= thisNode.value) thisNode = thisNode.left; | |
if (value > thisNode.value) { | |
thisNode = thisNode.right; | |
} | |
if (value <= thisNode.value) { | |
thisNode = thisNode.left; | |
} |
} | ||
if (value > thisNode.value) { | ||
thisNode.right = addNode; | ||
} else thisNode.left = addNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for else
root = addNode; | ||
} else { | ||
Node thisNode = root; | ||
while (thisNode.right != null && thisNode.left != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong loop logic, I guess it's better to check whether thisNode != null
return false; | ||
Node removeNode = root; | ||
while (removeNode.value != value) { | ||
if (value > removeNode.value) removeNode = removeNode.right; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
} | ||
|
||
// Should remove specified value from tree and return true | ||
// If value does not exist in this tree - return false | ||
public boolean remove(int value) { | ||
// TODO implement me | ||
return false; | ||
Node removeNode = root; | ||
while (removeNode.value != value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if removeNode == nul ??
Please, recheck loop condition
if (value > removeNode.value) removeNode = removeNode.right; | ||
else removeNode = removeNode.left; | ||
} | ||
if (removeNode.value != value) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can set code formatting in IntelijiIdea as google code style.
And then you can format code in right way
https://stackoverflow.com/questions/42979700/how-to-configure-google-java-code-formatter-in-intellij-idea-17
No description provided.