This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void gen_primes() | |
{ | |
int i,j; | |
for(i=0;i<MAX;i++) primes[i] = 1; | |
for(i=2;i<=(int)sqrt(MAX);i++) | |
if (primes[i]) | |
for(j=i;j*i<MAX;j++) primes[i*j] = 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void InsertionSort(A) | |
for(j = 2;j<=n;j++) | |
{ | |
key = A[j]; | |
i = j -1; | |
while(i > 0 && A[i] > key) | |
{ | |
A[i+1] = A[i]; | |
i = i - 1 ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream.h>] | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<conio.h> | |
int count,comp, e[10][10],n,v[10],order[10]; | |
void dfs(int i) | |
{ | |
v[i]=comp; | |
for(int j=0;j<n;j++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream.h> | |
#include<stdio.h> | |
#include<conio.h> | |
void main() | |
{ | |
clrscr(); | |
int i,j,n,e[10][10],order[10]={0},ne=0; | |
cout<<"\n Enter the value of n (i.e.), no of vertices:\t"; | |
cin>>n; | |
cout<<"\n Enter the adjacency matrix:\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream.h> | |
#include<stdio.h> | |
#include<conio.h> | |
#include<stdlib.h> | |
#include<time.h> | |
int a[30000],n; | |
void selection_sort() | |
{ | |
int min,i,j; | |
for(i=0;i<n-1;i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream.h> | |
#include<stdio.h> | |
#include<conio.h> | |
int v[10],e[10][10],w[10][10],n,mincost; | |
void Prim() | |
{ | |
v[1]=1; | |
for(int i=1;i<=n;i++) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<math.h> | |
int x[20],n; | |
int place(int k ,int i){ | |
int j=1; | |
for(j=1;j<k;j++) | |
if(x[j]==i || abs(x[j]-i)==abs(j-k)) | |
return 0; | |
return 1; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream.h> | |
#include<stdio.h> | |
#include<conio.h> | |
int a[10],c[10]; | |
void merge(int , int , int ); | |
void mergesort(int, int); | |
void main() | |
{ | |
int n,i | |
; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream.h> | |
#include<conio.h> | |
#include<stdio.h> | |
int set[10],n,w[10][10],c[10][10],ne=1,mincost; | |
void kruskal() | |
{ | |
int i,j,k,start,end; | |
while(ne<n) | |
{ | |
int min=1234; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream.h> | |
#include<stdio.h> | |
#include<conio.h> | |
int w[10],p[10],v[10][10],s[10],wt,m,n,i,j; | |
void knapsack() | |
{ | |
cout<<"\n Enter the no of weights:\t";cin>>n;m=n; | |
cout<<"\n Enter the weights :\t"; | |
for(i=1;i<=n;i++) scanf("%d",&w[i]); | |
cout<<"\n Enter the price of these weights:\t"; |
NewerOlder