7 kyu
Binary Tree Search (not BST)
203 of 1,435KacperKorban
Loading description...
Binary Trees
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This comment has been hidden.
Hi. Please use markdown tags to format your code or it's not usable. Refer to the documentation about this and more: https://docs.codewars.com/training/troubleshooting/#post-discourse
In general,
None should equal ...
means your code returns nothing (your function ends without areturn
statement).C# Translation
It is not the 7-th level kata. It requires knowledges of trees, which makes it the 5-th or 6-th level kata.
COBOL translation, please review carefully.
Approved
This comment has been hidden.
LC translation
This translation changes the description.
It has been approved by someone. Does the latest fork need to be approved too?
No. Just reject that. Those changes have been edited in directly.
Ok :) I can't reject it yet because author is active.
Owww .. yes, that was why we edited in the changes directly - couldn't approve the latest fork either for the same reason of course.
Sorry. ( I should have done it right in the initial translation .. I really fscked that up though, that needed fixing now. :O )
No problem ;)
Latest fork rejected :)
Thanks!
in Python, I am seeing this as not meeting the definition of a binary tree. Child nodes on the left and right have lower values than the parent. Left child must be less than, parent child must be greater than.
read the title again:
=> you're searching in a binary tree, not searching in a BST. ;)
https://www.educative.io/edpresso/binary-trees-in-python
Easy to find sources where this topic and issue is confused. Especially for a 7 kyu. Not sure who voted it as such but I would call it a 6.
Not to mention Read the comment that is provided in the default: """Determines if a value is in a binary search tree. """ Ok, please at least fix that
True, there's a mistake in solution set up comment, I'll leave a message to the translator for him to change it.
holy shit x/ That comment (in the initial solution) is outright wrong... x//
I corrected it (and corrected the tests and the description on the way)
Thanks. Now I have a merge conflict. :/
Python Translation Kumited.
Approved :)
For the C version, doing the attempt, I get an error message like :
It means your code does not return the correct answer, not a kata issue.
I'm fully aware of the meaning of an error. The error message is extremely non-helpful, which is why I raised the issue.
I'm quite sure trashy_incel will fix it now that it's been pointed out.
Ok, I understand now the problem is the non-helpful message, you might be clearer when posting an issue.
@SunMaster : sorry, I never received the notification. I changed the error message to be closer to english than to computer language ;-) However, I'm too lazy to draw the trees in case of failure : this is too much work for a one-liner 7-kyu 🤷
C translation (author inactive)
Thanks :)
Shouldn't
#include <stddef.h>
be added to initial code?i always put all the headers necessary to run the initial code without warnings, and leave the other ones for the codewarrior to figure out. but you can add it if you want to
Yeah, I was about to delete my message after testing it, but you've been faster than me ^^
The actual/expected values are flipped in the sample tests in C++.
fixed
This comment has been hidden.
Fortran Translation Kumited - please accept :D
Thanks for approving :D
IMHO
nullptr
would be a better choice for denoting the null pointer in C++.Changed to nullptr, Thanks :)
Needs random tests
Added some, Thanks :)
I think all
rNum 100
andgenT 0
calls may be optimized by compiler and executed only once because functions are pure by definition and unsafe is unsafe for a reason.I think that it should work now, Thanks :)
It might have been easier to let
Test.QuickCheck
do the work, but I'll readily admit it took me some time before I understood how that worked.For Cut the cake I did essentially the same as you ( though without the unsafe thingy ); later I wrote my own
Arbitrary
instances ( often, that's not even necessary ), and random testing would be as simple aswithout ever specifying
randomTree
.I can find an example kata if you like, or write some code for this one that would take advantage of
QuickCheck
. Just yell. If and when you know how to do it, it's really quite easy.It would be great, if you could write a sample code for this one, so I can learn how to do it using
QuickCheck
.Alright, have a look at this kumite.
Thanks :)
Should be good now :)
And using it in other kata as well I see. :] Looks a lot cleaner!
You forgot to remove the empty
where
at the end ofgen
. I'm surprised that compiles actually. :PHaven't noticed the
where
, Thanks :)Apparently in the actual tests the binary tree is like this:
I think you should clarify that this is a binary tree, not a binary search tree.
Clarified, Thanks :)
Complete tests expect
import BinaryTreeSearch
but initial code ismodule SearchATree where
Fixed, Thanks :)
O_o