Given the following Node
struct and a slice of optional children nodes, implement a DepthFirstSearch
method on Node
that uses a depth-first search algorithm (navigating the tree from left to right) to return a slice of all the child node Name
attributes in the appropriate order.
type Node struct {
Name string
Children []*Node
}
For example, given the following tree:
A
/ | \
B C D
/ \ / \
E F G H
/ \ \
I J K
The resulting slice should be ["A", "B", "E", "F", "I", "J", "C", "D", "G", "K", "H"]
.
You may use the following test to exercise your solution.