This file contains 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
var dateFuture; | |
var dateNow; | |
var updateInterval; | |
/** updat every second **/ | |
function updateCount(){ | |
dateNow = new Date(); //grab current date | |
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates | |
delete dateNow; | |
This file contains 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 stableMarriage(int prefer[ ][MAX], int rank[ ][MAX], int fiancee[ ], int n) | |
{ | |
int i, n, m, w, s, temp; | |
int next[MAX]; | |
for (i = 1; i <= n; i++) // initialisation | |
{ | |
next[i] = fiancee[i] = 0; rank[i][0] = n + 1; | |
} | |
for (m = 1; m <= n; m++) | |
{ |
This file contains 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 padding ( char ch, int n ){ | |
int i; | |
for ( i = 0; i < n; i++ ) | |
putchar ( ch ); | |
} | |
void structure ( struct node *root, int level ){ | |
int i; | |
This file contains 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 dijkstra(int short[ ], int adjM[ ] [SIZE], int previous[SIZE]) | |
{ | |
int i, k, mini, n = SIZE; | |
int visited[SIZE]; | |
for (i = 0; i < n; ++i) | |
{ | |
short[i] = INFINITY; | |
visited[i] = 0; /* the i-th element has not yet been visited */ | |
} | |
short[0] = 0; previous[0] = -1; // no previous vertex |
This file contains 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 floyd_warshall(int dist[ ] [SIZE], int P[ ][SIZE], int n) | |
{ // including array P to record paths | |
int i, j, k; | |
// initialise P to all -1s | |
for (k = 0; k < n; ++k) | |
for (i = 0; i < n; ++i) | |
for (j = 0; j < n; ++j) | |
{ | |
// check for path from i to k and k to j |
This file contains 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 prim (int weight[ ][SIZE]) | |
{ | |
int i, j, k, min, lowWeight[SIZE], closest[SIZE]; | |
for (i = 1; i < SIZE; ++i) | |
{ // initialise lowWeight to weights from vertex 0 | |
lowWeight[i] = weight[0][i]; closest[i] = 0; // vertex 0 is closest | |
} | |
for (i = 1; i < SIZE; ++i) | |
{ // find nearest adjacent vertex to the tree | |
k = 1; min = lowWeight[1]; |
This file contains 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 visit( int k, int *id, int val[ ], nodePtr adjList[ ] ) | |
{ | |
nodePtr t; | |
*id++; | |
val[k] = *id; | |
t = adjList[k]; | |
while (t != NULL) | |
{ | |
if (val[ t->v ] == 0) | |
visit(t->v, id, val, adjList); |
This file contains 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 visit( int k, int *id, int val[ ], nodePtr adjList[ ], Qptr q ) | |
{ | |
nodePtr t; | |
addQ(q, k); // add first to get started | |
while ( ! emptyQ(q) ) | |
{ | |
k = getQ(q); // get front of queue and delete | |
*id++; | |
val[k] = *id; // k is visited | |
t = adjList[k]; |
This file contains 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
int linearSearch(char *list[ ], char target[ ], int n) | |
{ | |
int i; | |
for (i = 0; i < n; i++) | |
{ | |
if (strcmp(target, list[i]) == 0) | |
{ | |
return i; | |
} | |
} // end for |
This file contains 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
int binarySearch(char *list[ ], char target[ ], int n) | |
{ | |
int start, end, middle; | |
start = 0; | |
end = n - 1; | |
while (start <= end) | |
{ | |
middle = (start + end) / 2; | |
if (strcmp(target, list[middle]) < 0) |
OlderNewer