MST (Kruskals Algorithm)

01 /* 02 MST(Kruskal’s) 03 */ 04 05 #include<iostream.h> 06 #include<stdlib.h> 07 08 #define MAXN 102 09 10 int P[MAXN], Rank[MAXN]; 11 12 int Node, edg, Cost; 13 14 struct edge { 15 int u, v; 16 int cost; 17 }; 18 19 edge Edge[MAXN*MAXN]; Read more

Prims Algorithm- MST

01 #include<iostream.h> 02 #include<queue> 03 #include<vector> 04 #define INF 100000 05 06 using namespace std; 07 08 struct edge { 09 vector<int>Adj; 10 vector<int>Cost; 11 }; 12 13 struct node{ 14 int x, y; 15 }; 16 17 edge Ed[100]; 18 int N, E; 19 int key[100]; Read more

Useful Algorithm Concepts

Recently, I found a nice article written by Kaiser Md. Nahiduzzaman, PhD student at UC.  The original article is available here: http://www.kaisernahid.com/files/Various.pdf. Here I quote part of it: Top Tip : Make sure you have a high level anti virus software like Read more

LIS

01 #include<stdio.h> 02 #define MAXN 100 03 04 int A[MAXN], N; 05 int L[MAXN], P[MAXN]; 06 07 void printPath(int x) { 08 if(P[x] == -1) { 09 printf(“%d”,x); 10 return; 11 } 12 printPath(P[x]); 13 printf(” %d”,x); 14 } 15 16 int doLIS() { 17 Read more