kotlin-coding-challenges

Tree traversal

Nice to solve before

Queue

Instructions

Traverse tree using Breath-First traversal.

Implement breath-first traversal - visit every node on a level before going to a lower level.

breadth_first_traversal.svg

Examples

// ---------Tree------------
//
//           A
//         /   \
//        B     C
//
// --------------------------


val tree = BinarySearchTree<Char>()
tree.add('A')
tree.add('B')
tree.add('C')

tree.traverseBreathFirst() // listOf('A', 'B', 'C')