Write a function named dfsTraversal
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 numberleft
- 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 DFS (depth-first) order.
NOTE: the left children should be visited before the right ones.
root
=