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
#include <stdio.h> | |
#include <stdlib.h> | |
#include "numbers.h" // https://gist.github.com/911872 | |
struct node { | |
int key; | |
struct node *l; | |
struct node *r; | |
}; |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include "numbers.h" // https://gist.github.com/911872 | |
struct Pair | |
{ | |
int left; | |
int right; | |
}; | |
struct Pairs |
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
#include <stdio.h> | |
#include "numbers.h" // https://gist.github.com/911872 | |
int main() | |
{ | |
struct numbers a; | |
struct numbers b; | |
/* | |
I feel like a tool, sort of. I spent more time than I should admit using | |
generateRandoms here, forgetting that mergesort can only merge two arrays |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "numbers.h" //https://gist.github.com/911872 | |
void insert(int,int); | |
int hremove(void); | |
int hEmpty(void); | |
void swapsies(int*, int, int); //anandkunal knows | |
int *indirectHeapSort(struct numbers*); //heapsort conflicts with stdlib |
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
#include <stdio.h> | |
#include "numbers.h" | |
void insertionSort(struct numbers*); | |
int main() | |
{ | |
struct numbers myNumbers = generateRandoms(1,10); | |
int i; | |
for (i = 0; i < myNumbers.size; 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
#include <stdio.h> | |
#include "numbers.h" // https://gist.github.com/911872 | |
void selectionSort(struct numbers*); | |
void numberSwap(struct numbers*, int, int ); | |
int main() | |
{ | |
struct numbers myNumbers = generateRandoms(2,200); | |
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
/* | |
heapSort example using priority queue from Sedgewick's Algorithms in C++ | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "numbers.h" // https://gist.github.com/911872 | |
void insert(int); | |
int hremove(void); |
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
#include <math.h> | |
#include <stdlib.h> | |
#include <time.h> | |
struct numbers { | |
unsigned int size; | |
int *values; | |
}; | |
struct Set { | |
const unsigned int size; | |
const int *values; |
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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <time.h> | |
/* | |
I wrote this as a sort of challenge, I wanted to pass random words into the K&R exercise | |
that generates a hash table of key value pairs to see how quickly the hashes stack up on | |
one another. I could have easily piped random words to the input, but that's not painful | |
at all... | |
*/ |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
int *range(int, int); | |
int *range(int start, int end) | |
{ | |
int size = (int) fabs(end-start)+1; | |
int *values = malloc(size * sizeof(int)); |