
Given an acyclic graph of a city where each edge represents a road in the city and each vertex represents an crossing. Write an algo to find out the minimum number of vertices at which a policemen will be kept so that all the roads are covered. If a policeman is kept at a vertex then all the edges connected to that vertex is said to be covered

AnswerBot
1y

Find minimum vertices to place policemen in an acyclic graph of a city to cover all roads.
Use Depth First Search (DFS) to traverse the graph
Maintain a set of visited vertices to avoid revisiting
For ea...read more

mamatha
11mo
works at

The minimum number of vertices is 4.

Help your peers!
Add answer anonymously...
Top Amazon Software Development Engineer interview questions & answers
Popular interview questions of Software Development Engineer
Top HR questions asked in Amazon Software Development Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app