Imagine you have a strip of highway connecting n towns in a line. Each town is being evaluated as a possible location for building a cellular phone tower. Each cell tower will provide coverage to the town it’s built in, but no other towns. However, due to the way that cell towers interfere with one another, it’s not possible to build cell phone towers in two adjacent towns. Describe an algorithm that, given the populations of each of the towns, reports the maximum number of people you can provide cell phone coverage to, subject to the restriction that no two adjacent towns can each have cell towers in them. Use dynamic programming to dramatically speed up your solution over a na ̈ıve recursive algorithm.
Imagine you have a strip of highway connecting n towns in a line. Each town is being evaluated as a possible location for building a cellular phone tower. Each cell tower will provide coverage to the town it’s built in, but no other towns. However, due to the way that cell towers interfere with one another, it’s not possible to build cell phone towers in two adjacent towns.
Describe an
Trending now
This is a popular solution!
Step by step
Solved in 2 steps