72.bfsTraversal

Write a function named bfsTraversal that receives one parameter as input:

  • an object describing the root node of a tree graph. Each node has the following properties:

    • value - the value in this node, which is a number
    • left - the left child of this node - which is an object with the same structure. This property is optional, because not all nodes will have a left child.
    • right - the right child of this node - which is an object with the same structure. This property is optional, because not all nodes will have a right child.

The function should return an Array of numbers corresponding to the values of the tree in BFS (breadth-first) order.

NOTE: the left children should be visited before the right ones.

Example 1

Input

root

=

Output