use algorithm with me!
step 1 patter : Binary tree, Linked list,Stack, Queue and Binary step 2 leetcode part Q&A
-
step 1
-
Binary tree
-
Linked list
-
Stack and queue
-
Binary
-
-
step 2
- leetcode question
go get github.com/CaiNiaoHui/algorithm_module
import (
tree "github.com/CaiNiaoHui/algorithm_module/binary_tree/package"
)
-
create tree
tree := &_package.TreeNode{Value: 0, Left: nil, Right: nil}
-
Preorder traversal
_package.Preorder_recursion(tree)
-
Non-recursive preorder traversal
result := _package.Preorder_non_recursive(tree)
-
Midorder traversal
_package.Inorder_recursion(tree)
-
Non-recursive Midorder traversal
result = _package.Inorder_non_recursive(tree)
-
Postorder traversal
_package.Postorder_recursion(tree)
-
Non-recursive Postorder traversal
result = _package.Postorder_non_recursive(tree)
-
dfs traversal tree (up to down)
result = _package.Dfs_upTodown(tree)
-
dfs divide and conquer traversing the tree (down to up)
result = _package.Dfs_downToUp(tree)
-
bfs sequence traversal
result1 := _package.Bfs_levelOrder(tree)
-
Merge sort
result = _package.MergeSort(arr)
-
Quick sort
_ = _package.QuickSort(arr1)
-
tree Maximum depth
depth := _package.MaxDepth(tree)
-
detect balanced binary tree
depth = _package.IsBalaced(tree)
-
travel max path
maxpath := _package.MaxPathSum(tree)
-
bfs sequence traversal (up to down)
result1 = _package.Bfs_Traverse(tree)
-
bfs sequence traversal (down to up)
result1 = _package.Bfs_Traverse_reverse(tree)
-
bfs sequence traversal ('Z' glyph traversal)
result1 = _package.Bfs_Traverse_Z(tree)
-
Judging the binary search tree
tr := _package.Is_BST(tree)