DSA

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 »

What is Josephus Problem?

This is an interesting programming problem know in the literature as Josephus problem. The problem is given as: 1. Suppose there are n children standing in a queue. 2. Students are numbered from 1 to n in the clockwise direction. 3. Students choose a lucky number say m. They start counting in clockwise direction from …

What is Josephus Problem? Read More »