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.
 
 
 
 

1003 B

btreetransplant

Instructions

Afin de déplacer les sous-arbres dans l'arbre de recherche binaire, écrire une fonction, BTreeTransplant, qui remplace le sous-arbre commencé par node avec la node rplc dans l'arbre donné par root.

Fonction attendue

func BTreeTransplant(root, node, rplc *TreeNode) *TreeNode {

}

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")
	node := piscine.BTreeSearchItem(root, "1")
	replacement := &piscine.TreeNode{Data: "3"}
	root = piscine.BTreeTransplant(root, node, replacement)
	piscine.BTreeApplyInorder(root, fmt.Println)
}

Et son résultat :

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