P

@prathameshp82

merge_sort.c

C
2 years ago
#include <stdio.h> #include <stdlib.h> #include <time.h> void merge(int array[], int low, int mid, int high) { int i,j,k; int n1=mid-low+1; int n2=high-mid; int left[n1];

DFS

C
2 years ago
// DFS implementation in C #include <stdio.h> #include <stdlib.h> struct node { int vertex; struct node* next; };

BFS in a graph

C
2 years ago
#include <stdio.h> #include <stdlib.h> struct node { int vertex; struct node *next; }; struct node *createnode(int val)

Implement BST

C
2 years ago
//Implement binary search tree #include <stdio.h> #include <stdlib.h> struct node { int data; struct node *left, *right; }; //Creation of a node with pointers pointing to left and right of the node

Tree Traversal

C
2 years ago
#include <stdio.h> #include <stdlib.h> // Definition of a binary tree node struct Node { int data; struct Node* left; struct Node* right; };

Quicksort

C
2 years ago
#include <stdio.h> void swap(int *a, int *b) { int temp=*a; *a=*b; *b=temp; } int partition(int arr[], int low, int high)

Bubblesort

C
2 years ago
#include <stdio.h> #include <stdbool.h> void swap(int *x, int *y) { int temp=*x; *x=*y; *y=temp; }

Insertsort

C
2 years ago
#include <stdio.h> void insertsort(int arr[], int size) { for(int n=1; n<size; n++) { int key=arr[n]; int j=n-1;

Selection sort

C
2 years ago
#include <stdio.h> void selection(int arr[], int n) { int i, j, small; for(i=0; i<n-1; i++) { small=i;

Doubly linked list

C
2 years ago
#include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node* next; struct node* prev; }node; node* start;

Circular linked list

C
2 years ago
#include <stdio.h> #include <stdlib.h> struct node { int data; struct node * next; }; struct node * start;

stack using linked lists

C
2 years ago
#include <stdio.h> #include <stdlib.h> struct node { int data; struct node*next; }; struct node*head=NULL;

queue using linked list

C
2 years ago
#include <stdio.h> #include <stdlib.h> // to create a node for list struct node { int data; struct node *next; };

Dequeue

C
2 years ago
#include <stdio.h> #define size 5 int deque[size]; int f = -1, r = -1; // insert_front function will insert the value from the front void insert_front(int x) { if((f==0 && r==size-1) || (f==r+1)) { printf("Overflow");

Tower of Hanoi using Recursion

C
2 years ago
#include <stdio.h> void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) { if (n == 1) { printf("\n Move disk 1 from rod %c to rod %c", from_rod, to_rod); return; } towerOfHanoi(n - 1, from_rod, aux_rod, to_rod);

Tower of Hanoi using Stacks

C
2 years ago
// C Program for Iterative Tower of Hanoi #include <stdio.h> #include <math.h> #include <stdlib.h> #include <limits.h> // A structure to create the stack struct Stack { unsigned capacity;

Implementation of circular queue

C
3 years ago
#include <stdio.h> #include <stdlib.h> #define max_size 10 typedef struct { int front, rear; int items[max_size]; }Queue;

Implementation of linear queue

C
3 years ago
#include <stdio.h> #include <stdlib.h> #define max_size 10 typedef struct { int front, rear; int items[max_size]; }Queue;