Skip to content

Instantly share code, notes, and snippets.

@shahzaib-sheikh
shahzaib-sheikh / tree.c
Created February 18, 2024 03:20
Tree Implementation in C
#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
int data;
struct Node *right;
struct Node *left;
int count;
} Node;
@shahzaib-sheikh
shahzaib-sheikh / timer.cpp
Created February 18, 2024 03:20
Timer on Arduino BCD implementation
#include <FiniteStateMachine.h>
#include <Button.h>
int input1[4] = {10, 13, 12, 11};
int input2[4] = {6, 9, 8, 7};
int input3[4] = {2, 5, 4, 3};
int input4[4] = {17, 14, 15, 16};
byte BCD[16][4] = {
{0, 0, 0, 0},
@shahzaib-sheikh
shahzaib-sheikh / StackLib.c
Created February 18, 2024 03:18
Stack implementation in C
#include <stdio.h>
#include <stdlib.h>
typedef struct StackNode
{
void *data;
struct StackNode *next;
} StackNode;
typedef struct Stack
@shahzaib-sheikh
shahzaib-sheikh / shell_sort.cpp
Created February 18, 2024 03:17
Shell sort implementation in C++
#include <conio.h>
#include <stdio.h>
#include <math.h>
void swap(int *a, int *b);
void print(int *arr, int lengthArr);
int main()
{
@shahzaib-sheikh
shahzaib-sheikh / set.c
Created February 18, 2024 03:17
Set implementation in C
#include <stdio.h>
#include <stdlib.h>
#include "OrderedPairLib.c"
typedef struct Set
{
LinkedList *orderedPairList;
} Set;
OrderedPair *getOrderedPair(Set *optr, int index)
@shahzaib-sheikh
shahzaib-sheikh / quick_sort.c
Created February 18, 2024 03:16
Quick Sort implementation in C
#include <stdio.h>
#include <stdlib.h>
void quickSort(int *arr, int startArr, int endArr);
int partionByPivot(int *arr, int startArr, int endArr);
void printArray(int *arr, int lengthArr);
void swap(int *a, int *b);
void main()
{
@shahzaib-sheikh
shahzaib-sheikh / queue.c
Created February 18, 2024 03:14
Queue implementation in C
#include <stdio.h>
#include <stdlib.h>
typedef struct QueueNode
{
void *data;
struct QueueNode *next;
} QueueNode;
typedef struct Queue
@shahzaib-sheikh
shahzaib-sheikh / ListLib.c
Created February 18, 2024 03:12
Ordered Pair implementation in C
#include <stdio.h>
#include <stdlib.h>
typedef struct ListNode{
void *data;
struct ListNode *next;
} ListNode;
typedef struct LinkedList {
@shahzaib-sheikh
shahzaib-sheikh / open_hashing.c
Created February 18, 2024 03:09
Open hashing implementation in C
#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
int data;
struct Node *next;
} Node;
typedef struct Queue
@shahzaib-sheikh
shahzaib-sheikh / merge_sort..c
Created February 18, 2024 03:08
Merge Sort implementation in C
#include <stdio.h>
#include <stdlib.h>
void mergeSort(int *arr, int lengthArr);
void merge(int *arr, int lengthArr, int *subA, int lengthSubA, int *subB, int lengthSubB);
void printArray(int *arr, int lengthArr);
void main()
{
int arr[15] = {11, 68, 2, 4, 5, 7, 8, 9, 1, 3, 4, 5, 6, 8, 10};
int lengthArr = (int)sizeof(arr) / sizeof(arr[0]);