Category Archives: Dynamic Programming

Bellman-Ford Algorithm in C and C++

Here you will learn about Bellman-Ford Algorithm in C and C++. Dijkstra and Bellman-Ford Algorithms used to find out single source shortest paths. i.e. there is a source node, from that node we have to find shortest distance to every other node. Dijkstra algorithm fails when graph has negative weight cycle. But Bellman-Ford Algorithm won’t fail… Read More »

Matrix Chain Multiplication in C and C++

Here you will learn about Matrix Chain Multiplication with example and also get a program that implements matrix chain multiplication in C and C++. Before going to main problem first remember some basis. We know that, to multiply two matrices it is condition that, number of columns in first matrix should be equal to number of… Read More »

Travelling Salesman Problem in C and C++

Here you will learn about Travelling Salesman Problem (TSP) with example and also get a program that implements Travelling Salesman Problem in C and C++. Let say there are some villages (1, 2, 3, 4, 5). To work with worst case let assume each villages connected with every other villages. And there is a Salesman living… Read More »