Skip to content

Instantly share code, notes, and snippets.

View fchristofrank's full-sized avatar
🏠
Open for Collaboration

Christo Frank F fchristofrank

🏠
Open for Collaboration
View GitHub Profile
@fchristofrank
fchristofrank / Fractional_knapsack
Last active July 20, 2020 04:14
Fractional_knapsack algorithm with python
def fractional_knapsack(VperW,W):
'''This function implements the fractional knapsack problem'''
i = 0
Value = 0
count = 0
# sort to reduce the time complexity. You need not find the max in the list
# at every iteration
VperW = sorted(VperW.items(),reverse =True)
while i<n and W != 0:
a = min(W,VperW[i][1][1])
@fchristofrank
fchristofrank / LINKED LIST- with insertion option
Created March 24, 2020 05:38
This is a simple implementation of a linked list in C programming.
# include <stdio.h>
# include <malloc.h>
typedef struct node
{
int data;
struct node * link;
}node;
node* linkedlist(int n)