## BFS Program in C

What is BFS? Breadth-first search (BFS) is an algorithm for traversing or searching tree or graph data structure. It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a ‘search key'[1]), and explores all of the neighbor nodes at the present depth prior to moving on to the … Read more

## C Program to Implement Floyd Warshall Algorithm

The Floyd-Warshall algorithm in C is a graph algorithm that finds the shortest path between two vertices in a graph in a weighted graph with positive or negative edge weights but without negative cycles. The algorithm is named after the British mathematician Floyd Warshall. The algorithm is also known as the all-pairs shortest path algorithm. … Read more

## Postorder Traversal of a Binary Tree without using Recursion in C

This is a C Program to perform post order traversal. Time Complexity: O(n) Here is source code of the C Program to Perform Postorder Non-Recursive Traversal of a Given Binary Tree. The C program is successfully compiled and run on a Linux system. The program output is also shown below. // C program for iterative … Read more

## Postorder Traversal of a Binary Tree using Recursion in C

This is a C Program to perform post order traversal. Time Complexity: O(n) Here is source code of the C Program to Perform Postorder Recursive Traversal of a Given Binary Tree. The C program is successfully compiled and run on a Linux system. The program output is also shown below. #include <stdio.h>#include <stdlib.h> /* A binary … Read more

## Preorder Traversal of a Binary Tree without using Recursion in C

This is a C Program to perform pre order traversal. Time Complexity: O(n) Here is source code of the C Program to Perform Preorder Non-Recursive Traversal of a Given Binary Tree. The C program is successfully compiled and run on a Linux system. The program output is also shown below. #include <stdlib.h>#include <stdio.h>#include <stack> /* A … Read more

## C Program to Find Minimum Spanning Tree using Prim’s Algorithm

This is a C Program to find the minimum spanning tree of the given graph using Prims algorihtm. Prim’s algorithm is a greedy algorithm that finds a minimum spanning tree for a connected weighted undirected graph. It finds a subset of the edges that forms a tree that includes every vertex, where the total weight … Read more

## Preorder Traversal of a Binary Tree using Recursion in C

This is a C Program to perform pre order traversal. Time Complexity: O(n) Here is source code of the C Program to Perform Preorder Recursive Traversal of a Given Binary Tree. The C program is successfully compiled and run on a Linux system. The program output is also shown below. #include <stdio.h>#include <stdlib.h> /* A binary … Read more

## C Program to Implement Johnson’s Algorithm

This is a C Program to implement Johnson’s Algorithm. This code implements Johnson’s algorithm to solve the “all pairs shortest path” problem, ie. given an input graph with general edge weights (can be negative) with no negative cycles, find the shortest (u, w) path for all pairs of vertices (u, w). If the input graph … Read more

## C Program to Find K Closest Median Elements

This is a C Program to find k numbers cloest to median of S, S being a set of n numbers. Here is source code of the C Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers. The C program is successfully compiled and run on … Read more