btree: store strings via "data" struct
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-07-31 01:19:09 +02:00
parent 5fccf8c6ec
commit bb83664e87
3 changed files with 156 additions and 96 deletions
+15 -16
View File
@@ -7,30 +7,29 @@ import (
)
func main() {
// Example program
t := btree.NewBtree(3)
t.Insert(10)
t.Insert(20)
t.Insert(5)
t.Insert(6)
t.Insert(12)
t.Insert(30)
t.Insert(7)
t.Insert(17)
t.Insert("animal", "dog")
t.Insert("potato", "fries")
t.Insert("6", "number")
t.Insert("12", "number")
t.Insert("car", "ferrari")
t.Insert("7", "number")
t.Insert("plane", "airbus")
fmt.Print("Traversal of the constructed tree is")
t.Traverse()
k := 6
if t.Search(k) != nil {
fmt.Print("\nPresent")
} else {
if val, err := t.Search("6"); err != nil {
fmt.Print("\nNot Present")
} else {
fmt.Printf("\nPresent: value '%s'", val)
}
k = 15
if t.Search(k) != nil {
fmt.Print("\nPresent")
} else {
if val, err := t.Search("15"); err != nil {
fmt.Print("\nNot Present")
} else {
fmt.Printf("\nPresent: value '%s'", val)
}
}