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 main() { | |
| int nbytes, ncases, i, j, k; | |
| char c, res; | |
| char ** msgs; | |
| scanf("%d", &ncases); | |
| msgs = malloc(ncases * sizeof(char *)); |
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 <stdbool.h> | |
| #define N_CITIES 4 | |
| typedef enum{A, B, C, D, None=-1}city; | |
| typedef struct { | |
| int start; |
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 <stdbool.h> | |
| #define N 5 | |
| typedef enum{BLACK, WHITE, START, END} tile; | |
| typedef enum{UNDISCOVERED, DISCOVERED, PROCESSED}graph_state; | |
| typedef struct { |
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> | |
| void qsort3(int *X, int L, int U) { | |
| int T, M, E, i, tmp; | |
| if (L < U) { | |
| T = X[L]; | |
| M = L; | |
| E = U; | |
| for (i = L+1; i < E; i++) { | |
| if (X[i] < T) { |
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
| def find_cycles(g, x, path, num_cycles): | |
| if x in path: | |
| num_cycles+=1 | |
| return num_cycles | |
| path.append(x) | |
| N = len(g[x]) | |
| for i in range(N): | |
| if g[x][i]: |
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
| # graph.py | |
| class Vertex: | |
| def __init__(self, x): | |
| self.x = x | |
| self.edges = {} | |
| def __str__(self): | |
| return "Vertex %d: %s" % (self.x, self.edges) |
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 <stdlib.h> | |
| #include <stdio.h> | |
| #include <stdbool.h> | |
| #define N 10 | |
| typedef struct { | |
| int y; | |
| int weight; | |
| struct Edge *next; /* next in adj list */ |
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
| class Node: | |
| def __init__(self, data): | |
| self.data = data | |
| self.lchild = None | |
| self.rchild = None | |
| def insert(self, key): | |
| if key < self.data: | |
| if self.lchild: | |
| self.lchild.insert(key) |
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> | |
| typedef struct Node { | |
| struct Node *prev; | |
| struct Node *next; | |
| int data; | |
| } Node; |
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> | |
| void qsort(int *X, int L, int U) { | |
| int T, M, i, tmp; | |
| if (L < U) { | |
| T = X[L]; | |
| M = L; | |
| for (i = L+1; i < U; i++) { | |
| if (X[i] < T) { | |
| M += 1; |