When should I use Kruskal as opposed to Prim (and vice versa)?

Use Prim’s algorithm when you have a graph with lots of edges. For a graph with V vertices E edges, Kruskal’s algorithm runs in O(E log V) time and Prim’s algorithm can run in O(E + V log V) amortized time, if you use a Fibonacci Heap. Prim’s algorithm is significantly faster in the limit when you’ve got a really dense graph with many … Read more

When is it practical to use Depth-First Search (DFS) vs Breadth-First Search (BFS)? [closed]

That heavily depends on the structure of the search tree and the number and location of solutions (aka searched-for items). If you know a solution is not far from the root of the tree, a breadth first search (BFS) might be better. If the tree is very deep and solutions are rare, depth first search … Read more