Skip to content

Instantly share code, notes, and snippets.

View satyaki07's full-sized avatar
🏠
Working from home

Satyaki Bose satyaki07

🏠
Working from home
View GitHub Profile
@satyaki07
satyaki07 / 0-1knapsack.c
Created September 9, 2017 07:27
A Dynamic Programming based solution to the 0-1 Knapsack problem.
#include<stdio.h>
#include<stdlib.h>
//Returns the maximum of two integers
int max(int a,int b){
if(a > b)
return a;
else
return b;
@satyaki07
satyaki07 / FractionalKnapsack.c
Created September 6, 2017 14:35
An greedy approach to solve the fractional knapsack problem.
#include<stdio.h>
#include<stdlib.h>
//Each item has a weight, value and a value/weight ratio.
struct item{
float weight;
float value;
float ratio;
}item[9],temp;
@satyaki07
satyaki07 / matrixchaindp.c
Created August 30, 2017 07:14
Algorithm to get the minimum no. of multiplications for matrix chain multiplication in dynamic programming approach.
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int matrixChainMul(int arr[],int n){
int m[n][n];
int i,j,L,k,q;
for(i=1;i<n;i++)
m[i][i] = 0;