MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / dfs

Method dfs

FindEventualSafeStates.java:15–28  ·  view source on GitHub ↗
(int node, int[][] graph, HashMap<Integer,Boolean> map)

Source from the content-addressed store, hash-verified

13 return res;
14 }
15 public boolean dfs(int node, int[][] graph, HashMap<Integer,Boolean> map){
16 if(map.containsKey(node)){
17 return map.get(node);
18 }
19
20 map.put(node,false);
21 for(int neighbour : graph[node]){
22 if(!dfs(neighbour, graph, map)){
23 return false;
24 }
25 }
26 map.put(node,true);
27 return true;
28 }
29}

Callers 1

eventualSafeNodesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected