Question: In python: 1. Fair traffic lights saved Design an algorithm for fair traffic lights that prioritize lanes that have the most traffic in order to

In python:In python: 1. Fair traffic lights saved Design an algorithm for fair

1. Fair traffic lights saved Design an algorithm for fair traffic lights that prioritize lanes that have the most traffic in order to clear a traffic jam. The lanes that have the most traffic are the ones that have more cars travelling in total in either, but opposite, direction. The traffic lights either have green light for traffic travelling north/south or east/west. The traffic light let drivers pass in a batch of 5 cars travelling either direction (i.e., maximum of 10 cars going each opposite direction simultaneously). When there are an equal number of cars travelling north/south and east/west, then the north/south lane has priority to clear traffic from the capital center. Example: Number of cars travelling north: 10 Number of cars travelling south: 10 Number of cars travelling east: 5 Number of cars travelling west: 10 Green light on N/S Green light on E/W Green light on N/S Green light on E/W No cars waiting, the traffic jam has been solved

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!