Quick actions

cmd+k|ctrl+k

Navigation

Languages

BFS vs DFS Qs

Snippet info

Language

JavaScript

Visibility

public

Author

vinnysantos559

Created

2020-01-08T03:36:06Z

Updated

2020-01-08T03:40:48Z

//If you know a solution is not far from the root of the tree:
//BFS

//If the tree is very deep and solutions are rare: 
//BFS ( DFS can take long? )  (will revisit this one)

//If the tree is very wide:
//BFS, but if memory is an issue, DFS (will revisit this one)

//If solutions are frequent but located deep in the tree:
//DFS

//Determining whether a path exists between two nodes:
//DFS

//Finding the shortest path:
//BFS
INFO