I tried creating my own binary tree with Golang.. I approached it a little different.. I first created an interface called Btree and then create two struct's Empty and Node which fulfill the Btree interface. It worked well and is immutable. type Btree interface { display(func(...interface{}) (int, error)) add(int) Btree find(int) Btree isEmpty() bool filter(func(int) bool) Btree mapB(func(int) int) Btree } type Empty struct{} type Node struct { data int left Btree right Btree } func createEmptyBtree() Btree { return Empty{} } ... Love the vids BTW.
The Remove function at line 104, the arg for value must be the MAX value right? We need to remove the largest value of the sub tree, not the input value anymore ... your sample tree cover your code 🙄
I am trying to write out problem 117 on Leet code "" Populating Next Right Pointers in Each Node II " in full and I want to pass values [1,2,3,4,5,null,7]. to my function BUT I am new to golang cannot hard code those values into my node to pass ,,,,,,, could you please help me?
hello, thanks for the tutorial. i was following your exemple and i noticed that if i delete 5 instead of 6 i get the following result: 0 1 2 4 4 6. Can you tell me if it is right or is it a bug?
@@victoracraniruivo5016 thx, i found the same problem when i was thinking about the solution (i couldnt understand why the original code works, without removing the temp val)
📝Get your *FREE Golang Cheat Sheet* -
golangdojo.com/cheatsheet
I tried creating my own binary tree with Golang.. I approached it a little different.. I first created an interface called Btree and then create two struct's Empty and Node which fulfill the Btree interface. It worked well and is immutable.
type Btree interface {
display(func(...interface{}) (int, error))
add(int) Btree
find(int) Btree
isEmpty() bool
filter(func(int) bool) Btree
mapB(func(int) int) Btree
}
type Empty struct{}
type Node struct {
data int
left Btree
right Btree
}
func createEmptyBtree() Btree {
return Empty{}
}
...
Love the vids BTW.
Pretty clear explanation, and very good narration
Keep it up!
I just finished the linked list 🤞
The Remove function at line 104, the arg for value must be the MAX value right? We need to remove the largest value of the sub tree, not the input value anymore ... your sample tree cover your code 🙄
thank you sir
awesome thank you !
You’re welcome!
Perhaps, you may consider doing a video about AVL trees?
Great suggestion. Perhaps after the Web App series!
What software/animation you use to explain the concepts in your videos ??
Powerpoint and Premier Pro :)
Well actually simple binary shearch tree not work in O(log n), but self balance bst like avl rb ... work in O(log n)
Can you make it generic and support custom data types?
Subscribed!
Welcome!
I am trying to write out problem 117 on Leet code "" Populating Next Right Pointers in Each Node II " in full and I want to pass values
[1,2,3,4,5,null,7]. to my function BUT I am new to golang cannot hard code those values into my node to pass ,,,,,,, could you please help me?
Could you make a video on red-black tree? I heard it s a common question in FAANG companies
Hopefully I will get to it soon!
I cannot access your git repo
i would avoid recursion.
Recursion is evil but your videos are very entertaining and fun to watch. Thank you for making them
hello, thanks for the tutorial. i was following your exemple and i noticed that if i delete 5 instead of 6 i get the following result:
0 1 2 4 4 6. Can you tell me if it is right or is it a bug?
i just figure out the problem. the line to remove the node should be
root.left = b.removeByNode(root.left, temp.value)
@@victoracraniruivo5016 Thanks!!
@@victoracraniruivo5016 thx, i found the same problem when i was thinking about the solution (i couldnt understand why the original code works, without removing the temp val)