You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

728 B

btreelevelcount

Instructions

Écrire une fonction, BTreeLevelCount, qui retourne le nombre de niveaux de l'arbre binaire. (la hauteur de l'arbre)

Fonction attendue

func BTreeLevelCount(root *TreeNode) int {

}

Utilisation

Voici un éventuel programme pour tester votre fonction :

package main

import (
	"fmt"

	piscine ".."
)

func main() {
	root := &piscine.TreeNode{Data: "4"}
	piscine.BTreeInsertData(root, "1")
	piscine.BTreeInsertData(root, "7")
	piscine.BTreeInsertData(root, "5")
	fmt.Println(piscine.BTreeLevelCount(root))
}

Et son résultat :

student@ubuntu:~/[[ROOT]]/test$ go build
student@ubuntu:~/[[ROOT]]/test$ ./test
3
student@ubuntu:~/[[ROOT]]/test$