Skip to content

Instantly share code, notes, and snippets.

View jitsceait's full-sized avatar

Sangar Jitendra jitsceait

View GitHub Profile
@jitsceait
jitsceait / level_order_tree.c
Last active August 29, 2015 14:00
Code for level order printing of tree
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
struct node{
int value;
struct node *left;
struct node *right;
};
typedef struct node Node;
@jitsceait
jitsceait / level_order_queue.c
Created May 4, 2014 02:17
Code for level order printing using queue
struct queue{
struct node *element;
struct queue *next;
};
typedef struct queue Queue;
void printLevel(Node * node){
Queue *q = NULL;
enqueue(&q, node);
@jitsceait
jitsceait / prune_tree.c
Last active August 29, 2015 14:00
Program to prune binary search tree
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
struct node{
int value;
struct node *left;
struct node *right;
};
typedef struct node Node;
@jitsceait
jitsceait / t9_dictionary.c
Last active August 29, 2015 14:00
This program implements T9 dictionary
#define MAX_NUMBER_LENGTH 3
const char hashTable[10][4] = {"", "",
"abc", "def",
"ghi", "jkl",
"mno", "pqrs",
"tuv", "wxyx"};
void printWords(int number[], int curr_digit, char output[]){
@jitsceait
jitsceait / bst_to_linked_list.c
Last active August 29, 2015 14:00
This program converts a BST to linked list
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
struct node{
int value;
struct node *left;
struct node *right;
};
typedef struct node Node;
@jitsceait
jitsceait / tree_to_list_using_queue.c
Last active August 29, 2015 14:00
This program converts a BST to Linked list using queue
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
struct node{
int value;
struct node *left;
struct node *right;
};
typedef struct node Node;
@jitsceait
jitsceait / kth_smallest.c
Last active August 29, 2015 14:00
This program finds Kth smallest element in an unsorted array
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void swap(int *a, int *b){
int temp = *a;
*a = *b;
*b = temp;
@jitsceait
jitsceait / add_linked_lists.c
Last active August 29, 2015 14:00
This program adds numbers represented by two linked lists
#include<stdlib.h>
#include<stdio.h>
typedef struct node{
int data;
struct node *next;
} Node;
/* This function is actually helper function which does all house keeping like
calculating lengths of lists,calling recursive implementation, creating extra
#include<stdlib.h>
#include<stdio.h>
#define max(a,b) (a>b) ? a:b
int longest_arithmetic_progression(int a[], int n){
int i,j,k;
int Table[n][n];
@jitsceait
jitsceait / poss_path.c
Last active August 29, 2015 14:00
Code snippet for recursive solution
int PossiblePaths(int i,int j, int m, int n){
if(i > m || j > n) return 0;
if(i == m && j == n) return 1;
return PossiblePaths(i+1,j, m,n)
+ PossiblePaths(i, j+1, m,n)
+ PossiblePaths(i+1, j+1,m,n);
}