Create tree data structures with breadth first search and depth first search algorithms
Write a function that will output breadth first search and depth first search order for a tree data structure. The tree shall only contain integers for it’s node. I expect the following:
(1) A PHP class that represents a tree data structure.
(2) A PHP function (BFS) that takes a tree as input and output the ordering of a breadth first search on the command line.
(3) A PHP function (DFS) that will output a depth first search on the same tree
(4) I should be able to run the class on the command line
- Ensure that your function can handle cycles
- Ensure that the nodes can only be integer
When you apply to this job, answer the following questions. IF YOU DO NOT ANSWER THESE QUESTIONS, YOU WILL NOT BE CONSIDERED.
(1) What is the complexity (O runtime) of BFS and DFS?
(2) What is the difference between a stack and queue data structure?
(3) How many hours will it take to do this job?