Skip to content

Instantly share code, notes, and snippets.

View shkesar's full-sized avatar

shubham shkesar

View GitHub Profile
@shkesar
shkesar / hashtable.c
Created September 22, 2016 08:37
Hash table done in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hashtable.h"
struct nlist *hashtab[HASHSIZE];
unsigned hash(char *s) {
unsigned hashval = 0;
@shkesar
shkesar / max_subarray.c
Created September 22, 2016 08:39
Maximum subarray problem
#include <stdio.h>
#include <limits.h>
#include <math.h>
int find_max_cross_array(int A[], int low, int mid, int high,
int *left, int *right) {
int max_left, max_right;
int sum = 0;
@shkesar
shkesar / insertion_sort.c
Created September 22, 2016 08:40
Insertion sort
#include <stdio.h>
#include <stdlib.h>
void display_array(int keys[], int len) {
for (int i = 0; i < len; i++) {
printf("%d ", keys[i]);
}
printf("\n");
}
@shkesar
shkesar / time.c
Created September 22, 2016 08:41
Time in C
#include <stdio.h>
#include <time.h>
int main()
{
time_t now = time(NULL);
struct tm *lt = localtime(&now);
printf("%d/%d/%d\n", lt->tm_mday, lt->tm_mon, 1900lt->tm_year);
return 0;
@shkesar
shkesar / rabin_karp.c
Created October 3, 2016 14:46
Rabin-Karp string matching algorithm
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define INVALID_OP -1
#define NOT_FOUND -2
typedef enum {TRUE = 0, FALSE} boolean;
#include <iostream>
// GLEW
#define GLEW_STATIC
#include <GL/glew.h>
// GLFW
#include <GLFW/glfw3.h>
// GLEW
#define GLEW_STATIC
#include <GL/glew.h>
// GLFW
#include <GLFW/glfw3.h>
#include <stdio.h>
int main()
{
// GLEW
#define GLEW_STATIC
#include <GL/glew.h>
// GLFW#include <stdio.h>
#include <stdlib.h>
#define HEAPSIZE 1000
struct heap_t {
int *S;
<!DOCTYPE html>
<html>
<head>
<style>
/*div {
position: absolute;
width: 150px;
height: 150px;
border-radius: 100px;
background-color: red;
@shkesar
shkesar / library.c
Created January 24, 2017 12:05
Library
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#define MAX 100
#define EXIT_CHOICE 10
#define USERS_FILE "users.txt"
#define BOOKS_FILE "books.txt"