MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / LevelOrder

Method LevelOrder

structure/tree/bstree.go:106–110  ·  view source on GitHub ↗

LevelOrder returns the level order traversal of the tree

()

Source from the content-addressed store, hash-verified

104
105// LevelOrder returns the level order traversal of the tree
106func (t *BinarySearch[T]) LevelOrder() []T {
107 traversal := make([]T, 0)
108 levelOrderHelper[T](t.Root, t._NIL, &traversal)
109 return traversal
110}
111
112// AccessNodesByLayer accesses nodes layer by layer (2-D array), instead of printing the results as 1-D array.
113func (t *BinarySearch[T]) AccessNodesByLayer() [][]T {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected