DFS in C [Program+Algorithm]

In this tutorial, you will learn about Depth First Search in C with the algorithm and program examples. Most graph problems involve the traversal of a graph. Traversal of a graph means visiting each node and visiting exactly once. There are two types of traversal in graphs i.e. Depth First Search (DFS) and Breadth First Search (BFS). Also …

DFS in C [Program+Algorithm] Read More »

Program for Merge Sort in C

In this tutorial, you will get program for merge sort in C.   Merge sort runs in O (n log n) running time. It is a very efficient sorting data structure algorithm with near optimal number of comparisons. Recursive algorithm used for merge sort comes under the category of divide and conquer technique. An array of …

Program for Merge Sort in C Read More »

Program for AVL Tree in C

Here you will get program for AVL tree in C. An AVL (Adelson-Velskii and Landis) tree is a height balance tree. These trees are binary search trees in which the height of two siblings are not permitted to differ by more than one. i.e. [Height of the left subtree – Height of right subtree] <= 1. A …

Program for AVL Tree in C Read More »

C Program for Addition of two Sparse Matrices

#include<stdio.h> #include<stdlib.h> #define MAX 20 void printsparse(int b[MAX][3]); void readsparse(int b[MAX][3]); void addsparse(int b1[MAX][3],int b2[MAX][3],int b3[MAX][3]); void main() {     int b1[MAX][3],b2[MAX][3],b3[MAX][3];     readsparse(b1);     readsparse(b2);     addsparse(b1,b2,b3);     printsparse(b3); } void readsparse(int b[MAX][3]) {     int i,t,m,n;     printf(“nEnter no. of rows and columns:”);     scanf(“%d%d”,&m,&n);     printf(“No. of non-zero triples:”);     scanf(“%d”,&t);     …

C Program for Addition of two Sparse Matrices Read More »