Posts

Showing posts from September, 2017

C++ Program to Solve Knapsack Problem by krbutani

C++ Program to Solve Knapsack Problem by krbutani #include<stdio.h> #include<conio.h> float m,p[100],w[100],r[100]; void main() {                 clrscr();                 int n;                 void swap(int,int);                 float cal(int);                 printf("\n\t Enter Capacity of Bag : ");                 scanf("%f",&m);                 printf("\n\t Enter How Many Item Deatils : ");                 scanf("%d",&n);                 clrscr();                 printf("\n\t Enter the 3 Item Data : ");                 for(int i=0;i<n;i++)                 {                                 printf("\n\t Enter %dth Item Weight : ",i);                                 scanf("%f",&w[i]);                                 printf("\n\t Enter %dth Item Profit : ",i);                                 scanf("%f",&p[i]);                           

Kruskal's Algorithm

Kruskal's Algorithm #include <iostream.h> #include <conio.h> #include <stdio.h> enum logical {TRUE=1,FALSE=0} ; struct edge {                 int from,to ;                 float cost ;                 int tree_no ; };                 int nv,ne,k=0 ;                 struct edge e[20] ; void greedy_kruskal(); logical feasible(int pos); void main() {                 clrscr();                 int i ;                 float temp;                 scanf("%f",&temp);                 printf("\nNo. of vertices = ");                 scanf("%d",&nv);                 printf("\nNo. of edges = ");                 scanf("%d",&ne);                 printf("\nEnter end-vertices and cost for each edge ");                 for(i=1;i<=ne;i++)                 {                                 printf("\nEnter for edge: %d",i);                                 printf("

Job Seek Algorithm using C++

Job Seek Algorithm using c++ #include< stdio.h > #include< alloc.h > #include< process.h > #include< conio.h > struct job {                 int d,pro ;                 struct job *pre,*next; }; typedef struct job node; node *head,* jobc ; int f[100],front=0,rear=0; void main() {                  clrscr ( );                 int n;                 void insert( int,int );                 void display();                 void sort();                 void cal();                 int cal2();                 while( 1)                 {                                 printf ( "\n\tJob Algorithm \n\t 1. Insert \n\t 2. Display \n\t 3. Get Maximum Profit\n\t 4.Exit");                                 printf ( "\n\tEnter Your Choice : ");                                 scanf ( "% d",&n );                                 if( n==4)