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> | |
#include <conio.h> | |
#include <climits> | |
using namespace std; | |
#define INF INT_MAX | |
void FloydWarshall(int **dist,int n) | |
{ | |
int i, j, k; |
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
10000 | |
233 | |
201 | |
298 | |
348 | |
135 | |
183 | |
105 | |
245 | |
36 |
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
import numpy as np | |
from skimage import data,io | |
import matplotlib.pyplot as plt | |
def get(im, i, j): | |
if 0 <= i < im.shape[0] and 0 <= j < im.shape[1]: | |
return im[i, j] | |
return 0 | |
def GAP(im, i, 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
/* | |
The Memory function is aligned to 64 byte boundary between values so that | |
the contents of the Memory Function "F" are spaced far enough to correct | |
False Sharing. | |
Note the __attribute__ compiler directive for this purpose in the 'elem' struct | |
//so that we can index "F" as a normal 2D array whist the compiler takes care | |
//of indirect addressing and any extra offsetting required (Instead of explicit mention). | |
Function used to allocate Dynamic Memory: |
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 <stdlib.h> | |
#include <time.h> | |
#include <omp.h> | |
int knapsack(int, int); | |
int max(int, int); | |
int n; | |
int* weights; | |
int* values; | |
int W; |
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
5 | |
1 2 4 3 5 | |
10 5 41 30 52 | |
8 |
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 <stdlib.h> | |
int MFKnapsack(int, int); //Function returning the optimal value for a given n and W | |
void knapsack(int,int); //Function used to populate the Knapsack Memory Function | |
int max(int, int); | |
int n; | |
int* weights; | |
int* values; | |
int W; | |
int** F; |
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 <stdlib.h> | |
#include <time.h> | |
int knapsack(int, int); //Returns the required optimal value by creating part of the Memory Function | |
int max(int, int); | |
int n; | |
int* weights; //Array containing weights of all items | |
int* values; //Array containing value of all items | |
int W; //Capacity of KnapSack | |
int** F; //Memory Function |