Skip to content

Instantly share code, notes, and snippets.

View sudhanshuptl's full-sized avatar
🦴
Focusing

Sudhanshu patel sudhanshuptl

🦴
Focusing
View GitHub Profile
@sudhanshuptl
sudhanshuptl / BinarySearchTree.py
Last active May 22, 2018 07:15
Complete Binary tree in python (using oops ). Also defined many different operations and algorithms for it.
__author__='Sudhanshu Patel'
'''
Binary search tree implementation
# goes left if key less than node.key else right
1. insetion
2. Preorder
3. postorder
4. inorder traversal
5. find max depth
6. print all leaf node
@sudhanshuptl
sudhanshuptl / Destructer
Last active May 24, 2018 10:56
Object Oriented programming Python , Examples
## Destructer delete object by itself when its reference is 0
from abc import ABC, ABCMeta, abstractclassmethod
'''
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared,
but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide
implementations for the abstract methods.
'''
@sudhanshuptl
sudhanshuptl / AbstractClassDemo.py
Created May 28, 2018 04:17
Abstract class in python
from abc import ABC, ABCMeta, abstractclassmethod
'''
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared,
but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide
implementations for the abstract methods.
'''
@sudhanshuptl
sudhanshuptl / OneWayLinkList.c
Last active May 30, 2018 03:09
One Way link list implementation C
@sudhanshuptl
sudhanshuptl / Array_based_heap.py
Created May 30, 2018 06:38
Array based Max Heap implementation in Python
__author__ == 'Sudhanshu Patel'
'''
1. Height should be h or h-1
2. max heap : parent node have hire value than all of its children
'''
class Heap_Array(object):
# Array Implementation of max Heap
# parent of a node is (i-1)/2 and child of a node is 2*i+1 and 2*i+2
@sudhanshuptl
sudhanshuptl / OneWayLinkList.py
Last active May 30, 2018 06:55
One way Link List : implementation in python
@sudhanshuptl
sudhanshuptl / fileParser_1.c
Last active May 31, 2018 07:10
Delimiter separated text file parsing in c
#include<stdio.h>
#include<string.h>
int main(){
FILE *fp; //file pointer
char line[30];
char *token;
//open file
@sudhanshuptl
sudhanshuptl / DelimiterDataParser.c
Created June 2, 2018 08:06
Custom Function for delimiter seperated data parsing in c
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
/*Global Variabls*/
char *GlobalPointer=NULL;
/* Prototypes */
char *ParseLine(char *arr, char *delimiter);
@sudhanshuptl
sudhanshuptl / Bubble_Sort.py
Last active June 11, 2018 12:31
Different Sorting Algorithms in Python
# Bubble sort in python
__author__ ='Sudhashu Patel'
class BubbleSort:
def __init__(self, ls=[5,3,6,2,4,7,4,3]):
self.ls = ls
self.length = len(self.ls)
def sort(self, reverse=False):
if reverse:
@sudhanshuptl
sudhanshuptl / MergeSort.c
Last active June 25, 2018 10:51
sorting Algorithms in c
#include<stdio.h>
#define SIZE 10
void print(int arr[]);
void mergeSort(int arr[],int base,int end);
void merge(int arr[],int base,int mid, int end);
int main(){
int arr[SIZE]={5,32,7,2,8,7,9,6,43,65};
print(arr);