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 / HeapSort.c
Created March 1, 2016 20:20
to sort a given array using heap sort method
#include <stdio.h>
#define max 30
void build_MaxHeap(int a[],int arraySize);
void max_Heapify(int a[],int i,int heapSize);
void heapSort(int a[],int arraySize);
void swap(int a[],int i,int largest);
int main()
{
@anubhavshrimal
anubhavshrimal / MergeSort.c
Last active April 10, 2016 06:46
perform merge sort operation based on divide and conquer algorithm
#include <stdio.h>
#include <stdlib.h>
#define max 30
void mergeSplit(int a[],int l,int n);
void mergeSort(int a[],int l,int mid,int n);
int main()
{
int n;
@anubhavshrimal
anubhavshrimal / QuickSortPivotFirst.c
Created March 1, 2016 20:19
quick sort an array using pivot as first element of the array
#include <stdio.h>
#include <stdlib.h>
#define max 10001
void quickSort(int a[],int l,int r,int *count);
int partition(int a[],int l,int r);
//main function definition
int main()
{
@anubhavshrimal
anubhavshrimal / QuickSortPivotLast.c
Created March 1, 2016 20:18
quick sort an array using pivot as last element
#include <stdio.h>
#include <stdlib.h>
#define max 10001
void quickSort(int a[],int l,int r);
int partition(int a[],int l,int r);
//main function definition
int main()
{
@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;
@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 / 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 / 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 / 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 / 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;