# 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 …

## Longest Path Algorithm (Java Code)

The longest path algorithm is used to find the maximum length of a given graph. The maximum length may be measured by the maximum number of edges or the sum of the weights in a weighted graph. Following is a sample java code to find the Longest Path. It has two classes. CreateMatrix.java class to …

## 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 = …