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<stdio.h> | |
#include<conio.h> | |
#include<stdlib.h> | |
#define null 0 | |
struct btree | |
{ | |
int data; | |
struct btree * left; | |
struct btree * right; | |
}; |
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
//Tower of Hanoi | |
//No of calls made for n disks is equal to pow(2,n) -1. | |
void hanoi(int n, char a, char c, char b) | |
{ | |
if(n==1) | |
{ | |
printf("\nShift disk 1 from %c to %c",a,c); | |
return ; | |
} |
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 q[10],e[10][10],n,order[10],count=1,front=0,rear=-1; | |
void bfs(int node) | |
{ | |
int i; | |
q[++rear]=node; | |
order[node]=count; | |
while(count!=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<conio.h> | |
#include<stdio.h> | |
int b[10][10]; | |
int binomial(int n, int k) | |
{ | |
int i,j; | |
for(i=0;i<=n;i++) | |
for(j=0;j<=(i<k?i:k);j++) | |
if(j==0 || j==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 w[10][10],n,ner[10],visit[10],dist[10],source; | |
void dijkstra() | |
{ | |
for(int i=1;i<n-1;i++) | |
{ | |
int min=1234,u=0; | |
for(int j=1;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<conio.h> | |
#include<stdio.h> | |
#include<stdlib.h> | |
int h[10],n; | |
void heap(int m); | |
void main() | |
{ | |
clrscr(); | |
int i,m; |
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"; |
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 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<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; | |
} | |