This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user