Skip to content

Instantly share code, notes, and snippets.

View anubhavshrimal's full-sized avatar
🎯
Focusing

Anubhav Shrimal anubhavshrimal

🎯
Focusing
View GitHub Profile
@anubhavshrimal
anubhavshrimal / AVL_Tree.c
Created March 1, 2016 19:24
performs basic operations on an AVL Tree such as insertion, deletion and inOrder traversal
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
typedef struct node
{
int data,height;
struct node *left,*right;
}node;
@anubhavshrimal
anubhavshrimal / BinarySearchTreeBasicOperations.c
Created March 1, 2016 19:27
performs operations such as searching, deletion and inOrder traversal on a Binary Search Tree
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
typedef struct node
{
int data;
struct node *left;
struct node *right;
}node;
@anubhavshrimal
anubhavshrimal / GraphBFS.c
Created March 1, 2016 19:31
Performs Breadth First Search in a Graph
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define max 10
//a structure to represent node of an adjacency list
typedef struct AdjListNode
{
int dest;
struct AdjListNode* next;
}AdjListNode;
@anubhavshrimal
anubhavshrimal / CountingInversion.c
Created March 1, 2016 19:35
program to count number of inversions in an integer array using divide and conquer algorithm and merge sort as a sub routine
#include <stdio.h>
#include <stdlib.h>
#define max 100001
void countInv(long long int a[],long long int l,long long int n,long long int *count);
void countSplit(long long int a[],long long int l,int long mid,long long int n,long long int *count);
int main()
{
long long int count=0,size,a[max],i;
printf("Enter array size: "); //input array size
@anubhavshrimal
anubhavshrimal / Graph.c
Created March 1, 2016 19:37
Program for Graph Data Structure; adds nodes and edges and prints the adjacency list of graph formed
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
//a structure to represent node of an adjacency list
typedef struct AdjListNode
{
int dest;
struct AdjListNode* next;
}AdjListNode;
@anubhavshrimal
anubhavshrimal / InfixToPostfix.c
Created March 1, 2016 19:39
Converts a simple infix expression string into postfix expression by using stack
#include <stdio.h>
#include <stdlib.h>
struct node
{
int num;
struct node *link;
}*top;
int check(char c);
@anubhavshrimal
anubhavshrimal / InfixToPrefix.c
Created March 1, 2016 19:59
convert an infix expression to prefix expression
#include <stdio.h>
#include <stdlib.h>
struct node
{
int num;
struct node *link;
}*top;
int check(char c);
@anubhavshrimal
anubhavshrimal / LinkedListOperations.c
Created March 1, 2016 20:09
performs basic operations over a linked list such as insert_end, insert_beg, insert at specified pos, delete from beginning, delete from end, delete value from specified pos,delete by value, sorting
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <conio.h>
struct node
{
int info;
struct node *link;
}*header;
@anubhavshrimal
anubhavshrimal / TowerOfHanoi.c
Created March 1, 2016 20:12
shows us the number of steps required to complete tower of hanoi problem
#include <stdio.h>
int count=0;
void step(int n,char a,char b,char c)
{
if(n==1)
{
count++;
printf("%c->%c\n",a,c);
}
@anubhavshrimal
anubhavshrimal / TreeTraversals.c
Created March 1, 2016 20:15
to show all the paths from a root, height of the tree, level order traversal, spiral order traversal, inorder traversal
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
char data;
struct node *left;
struct node *right;
}s;