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.
>>53375027