[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
How would you explain the insert method of a BST? I can't
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 19
Thread images: 2
File: bst.jpg (38 KB, 731x435) Image search: [Google]
bst.jpg
38 KB, 731x435
How would you explain the insert method of a BST?

I can't wrap my head around how they work
>>
>>53374661
That topic is too advanced for /g/, this is the hello world board
>>
>>53374661
Start at root. Go left if data is less, go right if data is more. Insert at the first null position you encounter.

What's so hard about that?
>>
>>53374713
What do you mean with "go"?
>>
>>53374661
search for it, where you give up -> insert

are you a retard?
>>
>>53374749
>are you a retard?
sort of, i dont understand how the fuck you traverse
>>
>>53374685
what is hello world?
>>
>>53374724
imagine you have a function called "do_the_thing"

you run do_the_thing with the value you've got, against the root node.

if the value you've got is less, you run do_the_thing with the value you've got against the node to the left.

if the value you've got is greater, you run do_the_thing with the value you've got against the node to the right.

the logic is really pretty simple. you just do_the_thing on each node, going left or right depending on the same rule each time, until you hit null.
>>
>>53374804
if key<node
go left
if key>node
go right
if key==node
found it
if node == empty
add it
>>
>>53374724
>What do you mean with "go"?
Oh my god.
>>
op here; nvm solved it now, this video explained it very good https://www.youtube.com/watch?v=OgJL8eh87PI
>>
>>53374869
>1.5 hours to explain BST operations
why
>>
>>53374834
Do you have to call zhu li to do it?
>>
>>53374878
Because he actually explains both the theory and practice instead of going full autist mode and just copy pasting
>>
>>53374661
import bst
>>
>>53374887
Full autist mode would be reading a book on the subject and actually implementing it yourself. Watching a 1.5 hour video and copying its code is fucking downs syndrome mode.
>>
>>53374910
>reading a dedicated BST book
>>
>>53374887
Do you really need a whole 1.5 hour long video to do that, though? Because I'm pretty sure anyone could do it themselves after a 20 minutes course briefly presenting common data structures.
>>
File: 1420500175412.jpg (438 KB, 900x2134) Image search: [Google]
1420500175412.jpg
438 KB, 900x2134
>>53375027
Thread replies: 19
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.