1
$\begingroup$

I am trying to enter into a data science job. I gave some internship interviews but have not had luck yet. Last week, I gave an interview where one of the panellists asked one hypothetical question:

“Imagine you have asked to write an algorithm to control traffic light system with a goal to keep road user happy. What approach would you take to design such algorithm”.

I was not able to give a good answer and lost the opportunity. I know about some approaches to designing algorithms such as dynamic programming, greedy method etc. However, none of them seems to be fit to the question asked by panellists. Since then I am curious about what approach can be used to design an algorithm to tackle the real-time problem.

Could anyone shed light on this question?

$\endgroup$
3
  • 1
    $\begingroup$ Your first thought should not be about greedy search or dynamic programming. Instead, you should start by clarifying requirements, both functional and non-functional. An example of a functional requirement would be how long users would be happy with waiting at a red light while cross-traffic has a green light - or how long if there was no cross traffic (I would be fine with waiting longer at a red light if I saw cross-traffic, not so much if I don't see anyone else but me). $\endgroup$ Dec 6, 2021 at 6:41
  • 1
    $\begingroup$ An example of a non-functional requirement would be if there are any legal constraints, e.g., on how long a red/yellow/green light must be on before it can be switched. A different question relates to the inputs: do we know if a car is waiting at a red light (e.g., via an induction loop), or not, and if yes, do we know how many there are? This should have an impact on the algorithm. The algorithm, in the end, should probably be a simple rule machine (which is why I voted to close here). This has the added advantage of being simple and easy to explain and implement. $\endgroup$ Dec 6, 2021 at 6:44
  • $\begingroup$ I'm by no means an expert, but queueing theory would seem to be appropriate, here, as you have a stochastic problem with people queueing up to get through the intersection. $\endgroup$ Dec 6, 2021 at 15:00

0

Browse other questions tagged or ask your own question.