Algorithms

Producer Consumer Problem in C++

Today I’m going to solve a most common problem which is known as the consumer producer problem. In this context we have a shared buffer which the producers produce and the consumers consume. The consumers and producers are threads which will simultaneously produce and consume. There are some conditions to be met where consumers have …

Producer Consumer Problem in C++ Read More »

Dijkstra Algorithm (Shortest Path Algorithm ) Java Code

Dijkstra Algorithm is used find the shortest path in a directed graphs. Following is a java implementation of the Dijkstra Algorithm. class Dijkstra { public static void main(String[] args) { int length = 300;//length of the 2-D array int adjMatrix[][] = new int[length][length]; CreateMatrix cm = new CreateMatrix(); cm.createMatrix(length); adjMatrix = cm.readMatrix(adjMatrix); Dijkstra dk = …

Dijkstra Algorithm (Shortest Path Algorithm ) Java Code Read More »