This is a logical problem we used to ask in tech interviews.
The question is as follow:
You are given:
- The number of trees N.
- Their positions X and Y.
- The Alpha angle.
You are at the center of the forest.
Find a fast algorithm that gives the Beta angle for which, it is guaranteed the field of view contains the maximum amount of trees.
Explain your algorithm, then give and explain the complexity of the algorithm.
Here are some clarifications:
- The the forest is infinitely sized, therefore an infinitely far tree is still visible. (imagine you have an orthographic camera)
- Perfectly aligned trees do not hide each others.
- You have 30 minutes.
You can find the web application here: https://tanukisharp.github.io/TreesProblem