What do you want to save?
Add Code snippet
New code examples
-
Other 2021-10-11 15:10:12
python simple depth first search
# Using a Python dictionary to act as an adjacency list graph = { '5' : ['3','7'], '3' : ['2', '4'], '7' : ['8'], '2' : [], '4' : ['8'], '8' : [] } visited = set() # Set to keep track of visited nodes of graph. def dfs(visited, graph, node):... Add solution -
Java 2021-09-22 08:16:07
depth first traversal graph java
############### #The Algorithm (In English): # 1) Pick any node. # 2) If it is unvisited, mark it as visited and recur on all its # adjacent nodes. # 3) Repeat until all the nodes are visited, or the node to be # searched is found. # The grap... Add solution -
C++ 2021-09-17 01:21:01
create a dictionary cpp
// The equivalent to python dictionaries are maps in c++ map<int, char> mymap; // Enter required types and name mymap[1] = 'a'; mymap[4] = 'b'; cout << "my map is -" << mymap[1] << " " < <mymap[4... Add solution