Use Dijkstra’s to find a Minimum Spanning Tree?

The answer is no. To see why, let’s first articulate the question like so: Q: For a connected, undirected, weighted graph G = (V, E, w) with only nonnegative edge weights, does the predecessor subgraph produced by Dijkstra’s Algorithm form a minimum spanning tree of G? (Note that undirected graphs are a special class of … Read more

‘Head First’ Style Data Structures & Algorithms Book? [closed]

The Algorithm Design Manual by Steve Skiena isn’t exactly a barrel of laughs, but it’s relatively light on the deeper mathematics and contains lots of what he calls “War Stories”, which are illustrative examples from real world situations where algorithm work really paid off (or, sometimes, totally failed). He’s also got his audio and video … Read more

What is the difference between breadth first searching and level order traversal?

For a ‘proper’ tree (see below), it’s the same thing, at least by most definitions. Like Wikipedia, for example: Breadth-first See also: Breadth-first search Trees can also be traversed in level-order, … … a breadth-first (level-order) traversal … Well, at least level-order traversal is the same as breadth-first traversal. There are many reasons to traverse … Read more

How to serialize a graph structure?

How do you represent your graph in memory? Basically you have two (good) options: an adjacency list representation an adjacency matrix representation in which the adjacency list representation is best used for a sparse graph, and a matrix representation for the dense graphs. If you used suchs representations then you could serialize those representations instead. … Read more