Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.7k
feat: add tests for binary search trees#1769
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
feat: add tests for binary search trees#1769
Uh oh!
There was an error while loading.Please reload this page.
Conversation
2877788
toeb71e2e
Comparereturn found.value | ||
if (this.root) { | ||
const found = this.root.search(val) | ||
if (found !== 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.
Just a shorthand recommendation.
Checking forif(found) {
will check for not null and not undefined .
So no need to explicitly use if (found !== 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.
The search return value can only benull
or aNode
, hence the implicit check.
search(val){if(this.value===val){returnthis}elseif(val<this.value&&this.left!==null){returnthis.left.search(val)}elseif(val>this.value&&this.right!==null){returnthis.right.search(val)}returnnull}
1d252d7
intoTheAlgorithms:masterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Describe your change:
Checklist:
Example:
UserProfile.js
is allowed butuserprofile.js
,Userprofile.js
,user-Profile.js
,userProfile.js
are notFixes: #{$ISSUE_NO}
.