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

Method LevelOrder

structure/tree/rbtree.go:115–119  ·  view source on GitHub ↗

LevelOrder returns the level order traversal of the tree

()

Source from the content-addressed store, hash-verified

113
114// LevelOrder returns the level order traversal of the tree
115func (t *RB[T]) LevelOrder() []T {
116 traversal := make([]T, 0)
117 levelOrderHelper[T](t.Root, t._NIL, &traversal)
118 return traversal
119}
120
121// AccessNodesByLayer accesses nodes layer by layer (2-D array), instead of printing the results as 1-D array.
122func (t *RB[T]) AccessNodesByLayer() [][]T {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected