Files
hello-algo/ru/codes/go/chapter_tree/binary_tree_test.go
Yudong Jin 772183705e Add ru version (#1865)
* Add Russian docs site baseline

* Add Russian localized codebase

* Polish Russian code wording

* Update ru code translation.

* Update code translation and chapter covers.

* Fix pythontutor extraction.

* Add README and landing page.

* placeholder of profiles

* Use figures of English version

* Remove chapter paperbook
2026-03-28 04:24:07 +08:00

42 lines
979 B
Go

// File: binary_tree_test.go
// Created Time: 2022-11-25
// Author: Reanon (793584285@qq.com)
package chapter_tree
import (
"fmt"
"testing"
. "github.com/krahets/hello-algo/pkg"
)
func TestBinaryTree(t *testing.T) {
/* Инициализация двоичного дерева */
// Инициализация узла
n1 := NewTreeNode(1)
n2 := NewTreeNode(2)
n3 := NewTreeNode(3)
n4 := NewTreeNode(4)
n5 := NewTreeNode(5)
// Построить связи между узлами (указатели)
n1.Left = n2
n1.Right = n3
n2.Left = n4
n2.Right = n5
fmt.Println("Инициализация двоичного дерева")
PrintTree(n1)
/* Вставка и удаление узлов */
// Вставка узла
p := NewTreeNode(0)
n1.Left = p
p.Left = n2
fmt.Println("После вставки узла P")
PrintTree(n1)
// Удаление узла
n1.Left = n2
fmt.Println("После удаления узла P")
PrintTree(n1)
}