I am trying Find the phone numbers of all managers whose direct report hierarchy live in more than 1 city in O(n) time complexity. Below is my approach which is using with Time Complexity O(M*N) where M is the number of managers and N is the Number of employess. Can someone please help me with O(N) solution for this problem.
Tag: graph-theory
How to implement Breadth First Search and Depth First Search for a SimpleWeightedGraph in Java
I need to implement Breadth First Search and Depth First Search for a SimpleWeightedGraph which contains String Vertices in Java Code below is my SimpleWeightedGraph where i implemented the following: declared SimpleWeightedGraph created vertices added vertices to the graph created default weighted edges, added edges and set Weights got and printed the shortest path from vertex “a” to vertex “e”
Implementing Dijkstra’s algorithm in Java
I’ve done a fair bit of reading around this, and know that discussions regarding this algorithm in Java have been semi-frequent. My issue with implementing Dijkstra’s algorithm in Java is simply that I’m not sure how to prepare my data. I have a set of coordinates within an array, and a set of 1s and 0s in a matrix that