Documentation
¶
Index ¶
- func HasPathSum(root *Node[int], targetSum int) bool
- func InorderTraversal[T any](root *Node[T]) []T
- func IsBalanced[T any](root *Node[T]) bool
- func IsSameTree[T any](p *Node[T], q *Node[T], eq func(a, b T) bool) bool
- func IsSymmetric[T any](root *Node[T], eq func(a, b T) bool) bool
- func MaxAncestorDiff(root *Node[int]) int
- func MaxDepth[T any](root *Node[T]) int
- func MinDepth[T any](root *Node[T]) int
- func PostorderTraversal[T any](root *Node[T]) []T
- func PreorderTraversal[T any](root *Node[T]) []T
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasPathSum ¶
HasPathSum returns true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum.
func InorderTraversal ¶
InorderTraversal returns inorder traversal of its nodes' values.
func IsBalanced ¶
IsBalanced return true if given tree is balanced.
func MaxAncestorDiff ¶
func MinDepth ¶
MinDepth returns the min depth of tree. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
func PostorderTraversal ¶
PostorderTraversal returns postorder traversal of its nodes' values.
func PreorderTraversal ¶
PreorderTraversal returns preorder traversal of its nodes' values.
Types ¶
type Node ¶
func FromSortedArray ¶
FromSortedArray returns a binary search tree from given sorted array.
Click to show internal directories.
Click to hide internal directories.