Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsertIntoBinaryTree ¶
func IsBinarySearchTree ¶
func ListOfDepths ¶
func ListOfDepths[T comparable](root *Node[T], list []*linkedlists.Node[T], depth int) []*linkedlists.Node[T]
Implement a function to check if a binary tree is balanced. For the purpose of this question, a balanced tree is defined to be a tree such that the heights of the two subtrees of any node never differ by more than one.
input tree:
(13)
output list:
[1]
input tree:
(25) /
(13)
\ (9)
output list:
[0] - [13] [1] - [9]->[25]
input tree:
(29) / (25) / \ / (21)
(13)
\ \ (9)
output list:
[0] - [13] [1] - [9]->[25] [2] - [21]->[29]
Types ¶
type Node ¶
type Node[T comparable] struct { // contains filtered or unexported fields }
func CreateBinaryTree ¶
func CreateNode ¶
func CreateNode[T comparable](data T, childNodes ...*Node[T]) *Node[T]
func TreeifySortedArray ¶
func TreeifySortedArray[T comparable](a []T, start int, end int) *Node[T]
func (*Node[T]) GetBalancedTreeHeight ¶
Implement a function to check if a binary tree is balanced. For the purpose of this question, a balanced tree is defined to be a tree such that the heights of the two subtrees of any node never differ by more than one.
type ParentedNode ¶
type ParentedNode[T comparable] struct { // contains filtered or unexported fields }
func CreateParentedNode ¶
func CreateParentedNode[T comparable](data T, childNodes ...*ParentedNode[T]) *ParentedNode[T]
func NextInOrderTraversal ¶
func NextInOrderTraversal[T comparable](node *ParentedNode[T]) *ParentedNode[T]
Click to show internal directories.
Click to hide internal directories.