Skip to content

Instantly share code, notes, and snippets.

View vgoel30's full-sized avatar
😺

Varun Goel vgoel30

😺
  • Microsoft
  • Redmond
View GitHub Profile
@vgoel30
vgoel30 / heap.c
Created July 7, 2016 14:52
Min Heap in C
#include <stdio.h>
#include <stdlib.h>
#define HEAP_SIZE 10
//building a min-heap
typedef struct heap{
int data[HEAP_SIZE + 1]; //the body of the heap
int total_elements; //the current number of elements in the heap
}heap;
@vgoel30
vgoel30 / linked_list.c
Last active July 7, 2016 15:05
Linked List in C
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int data;
struct node *next;
} node;
void insert_node(node **head, int x){
node *new_node = malloc(sizeof(node));
@vgoel30
vgoel30 / binary_search_tree.c
Created July 7, 2016 14:45
Implementation of a binary search tree in C
//STANDARD BST IMPLEMENTATION
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node *parent;
struct node *left;
struct node *right;
}node;
@vgoel30
vgoel30 / quicksort.c
Last active July 9, 2016 05:30
Quick Sort in C
#include <stdio.h>
//swap two values in an integer array
void swap(int arr[], int index_one, int index_two){
int temp = arr[index_one];
arr[index_one] = arr[index_two];
arr[index_two] = temp;
}
//partition the array using a given pivot