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
9mo
works at
The minimum number of vertices is 4.
Help your peers!
Add answer anonymously...
Amazon Software Development Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter