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<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> | |
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<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
//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<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
#include<stdio.h> | |
#include<conio.h> | |
#include<ctype.h> | |
void main() | |
{ static int a[5]; | |
int i,n,top=-1,op1,op2,noperator=0,noperand=0; | |
char ch[10]; | |
clrscr(); | |
printf("\n Enter the string\n"); | |
gets(ch); |
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<ctype.h> | |
void main() | |
{ | |
int i,j=-1,top=-1; | |
clrscr(); | |
char in[30], po[30],stack[20]; | |
printf("\n Enter the infix expression "); | |
gets(in); |
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 quicksort(int l, int u) | |
{ int i, m; | |
if (l >= u) return; | |
swap(l, randint(l, u)); | |
m = l; | |
for (i = l+1; i <= u; i++) | |
if (x[i] < x[l]) | |
swap(++m, i); | |
swap(l, m); | |
quicksort(l, m-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
Change(d,k,n) | |
c[0] = 0 | |
for p = 1 to n do | |
min = INFINITY | |
for i = 1 to k do | |
if(d[i] <= p) do | |
if( 1 + c[p - d[i]] < min) then | |
min = 1 + c[p - d[i]] | |
coin = i | |
c[p] = min |