Posts

Showing posts with the label Algorithm

Implementing Dijkstra’s Algorithm using Sedgewick's C++ Code

Image
Introduction Dijkstra's algorithm solves the shortest path problem for a graph with nonnegative edge weights, producing a shortest path tree. This algorithm is often used in routing and as a subroutine in other graph algorithms, the k-shortest paths algorithm, for example.

How to Permanently Remove Items in STL Containers

Image
remove - What is does and does not do Like all STL algorithms, remove receives a pair of iterators to identify the range of container elements over which it needs to operate, as shown in its declaration: [code language="cpp"] template< class ForwardIterator, class T > ForwardIterator remove( ForwardIterator first, ForwardIterator last, const T& value ); [/code]

Sorting Objects Using STL

Image
Here's an example of how using objects (hat-tip: Paul Wolfensberger )

Finding Minimal Spanning Trees using Kruskal's Algorithm in MFC / C++ / Boost libraries

Image
Kruskal's algorithm is used to find the minimal spanning tree for a network with a set of weighted links. This might be a telecoms network, or the layout for planning pipes and cables, or one of many other applications.