Breadth First Search Time : O(n) Space : O(n) 1234567891011121314151617181920212223242526class Node {public: string name; vector<Node *> children; Node(string str) { name = str; } vector<string> breadthFirstSearch(vector<string> *array) { queue<Node*> q; q.push(this); while(!q.empty()) { auto node = q.front(); q.pop(); array->push_back(node->name); for(auto& child : node->children) { q.push(child); } } return *array; } Node *addChild(string name) { Node *child = new Node(name); children.push_back(child); return this; }};