r/javahelp • u/Gantzz25 • Nov 07 '20
Codeless What are orientations of a (binary search) tree? Which is right and which is left?
I checked in multiple textbooks, and all of them refer to the right/left of the BST differently. One textbook would refer to the left side as the reader’s left while others refer to the left side of the tree as the reader’s right. Which of these two is more consistent with the majority of people?
21
u/kAlvaro Nov 07 '20
It's been a long time since college but I suspect it's completely irrelevant as long as you don't swap sides in the middle of the search. There isn't even a real plant involved, so you can't possibly look at it from the wrong side—since it's nothing but a naming convention to distinguish branches, you could also call them red and blue or A and B.
6
u/Gantzz25 Nov 07 '20
Oh I see. As long as I‘m consistent it doesn’t matter what arbitrary name I give each side. Thanks!
1
u/Raph0007 Nov 08 '20
There isn't even a real plant involved
You.. you wanna tell me that real trees don't grow from top to bottom? Idk I'm a software dev, I was never on the "outside"...
1
5
u/iamsadtbh Aspiring SWE Nov 07 '20
Just the way you (the reader) is looking at it. Right is right. Left is left.
2
7
u/AppliedBytes Nov 07 '20
the non standard standard is left is less than our equal to and right is greater than. that hussy makes it easier for the people maintaining your code.
8
u/Roachmeister Java Dev Nov 07 '20
that hussy
Autocorrect gone wild? I can't even figure out what you meant to say, but I'm pretty sure it wasn't this.
8
2
u/g-unit2 Nooblet Brewer Nov 08 '20
i have only ever seen it as the readers left and the readers right.
i learned in a university class from a professor. also if you refer to reputable websites like “GeeksForGeeks” they will say the same thing.
if you’re struggling for good sources of information about data structures that is a great website. they have in depth material of every data structure with examples of functional structues and implementation in c,c++,java, and python.
i would also highly recommend youtube as a source. there are a lot of brilliant people that will walk you through examples in code or on whiteboards.
to review my data structures i have referred to MIT’s open course of their algorithms and analysis class. they also cover fundamental data structures and examples of when they would be useful to implement.
•
u/AutoModerator Nov 07 '20
Please ensure that:
Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
You include any and all error messages in full
You ask clear questions
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.