Browse Source

readme btreetransplant from quest 12

pull/222/head
lee 5 years ago
parent
commit
caa5aa613d
  1. 26
      subjects/btreetransplant.en.md
  2. 26
      subjects/btreetransplant.fr.md

26
subjects/btreetransplant.en.md

@ -2,7 +2,7 @@
### Instructions ### Instructions
In order to move subtrees around within the binary search tree, write a function, BTreeTransplant, which replaces the subtree started by node with the node called 'rplc' in the tree given by root. In order to move subtrees around within the binary search tree, write a function, `BTreeTransplant`, which replaces the subtree started by `node` with the node called `rplc` in the tree given by `root`.
This function must have the following signature. This function must have the following signature.
@ -23,29 +23,29 @@ package main
import ( import (
"fmt" "fmt"
student ".." piscine ".."
) )
func main() { func main() {
root := &student.TreeNode{Data: "4"} root := &piscine.TreeNode{Data: "4"}
student.BTreeInsertData(root, "1") piscine.BTreeInsertData(root, "1")
student.BTreeInsertData(root, "7") piscine.BTreeInsertData(root, "7")
student.BTreeInsertData(root, "5") piscine.BTreeInsertData(root, "5")
node := student.BTreeSearchItem(root, "1") node := piscine.BTreeSearchItem(root, "1")
replacement := &student.TreeNode{Data: "3"} replacement := &piscine.TreeNode{Data: "3"}
root = student.BTreeTransplant(root, node, replacement) root = piscine.BTreeTransplant(root, node, replacement)
student.BTreeApplyInorder(root, fmt.Println) piscine.BTreeApplyInorder(root, fmt.Println)
} }
``` ```
And its output : And its output :
```console ```console
student@ubuntu:~/student/btreetransplant$ go build student@ubuntu:~/student/test$ go build
student@ubuntu:~/student/btreetrandsplant$ ./btreetransplant student@ubuntu:~/student/test$ ./test
3 3
4 4
5 5
7 7
student@ubuntu:~/student/btreetrandsplant$ student@ubuntu:~/student/test$
``` ```

26
subjects/btreetransplant.fr.md

@ -2,7 +2,7 @@
### Instructions ### Instructions
In order to move subtrees around within the binary search tree, write a function, BTreeTransplant, which replaces the subtree started by node with the node called 'rplc' in the tree given by root. In order to move subtrees around within the binary search tree, write a function, `BTreeTransplant`, which replaces the subtree started by `node` with the node called `rplc` in the tree given by `root`.
This function must have the following signature. This function must have the following signature.
@ -23,29 +23,29 @@ package main
import ( import (
"fmt" "fmt"
student ".." piscine ".."
) )
func main() { func main() {
root := &student.TreeNode{Data: "4"} root := &piscine.TreeNode{Data: "4"}
student.BTreeInsertData(root, "1") piscine.BTreeInsertData(root, "1")
student.BTreeInsertData(root, "7") piscine.BTreeInsertData(root, "7")
student.BTreeInsertData(root, "5") piscine.BTreeInsertData(root, "5")
node := student.BTreeSearchItem(root, "1") node := piscine.BTreeSearchItem(root, "1")
replacement := &student.TreeNode{Data: "3"} replacement := &piscine.TreeNode{Data: "3"}
root = student.BTreeTransplant(root, node, replacement) root = piscine.BTreeTransplant(root, node, replacement)
student.BTreeApplyInorder(root, fmt.Println) piscine.BTreeApplyInorder(root, fmt.Println)
} }
``` ```
And its output : And its output :
```console ```console
student@ubuntu:~/student/btreetransplant$ go build student@ubuntu:~/student/test$ go build
student@ubuntu:~/student/btreetrandsplant$ ./btreetransplant student@ubuntu:~/student/test$ ./test
3 3
4 4
5 5
7 7
student@ubuntu:~/student/btreetrandsplant$ student@ubuntu:~/student/test$
``` ```

Loading…
Cancel
Save