Skip to content

Commit

Permalink
Added Data Structures Course Work
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhMaheshwari committed Aug 14, 2018
1 parent fc3a271 commit a79b143
Show file tree
Hide file tree
Showing 119 changed files with 763,196 additions and 3,566 deletions.
Binary file added ABA/aba_assignment.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions DIP/03.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Intensity Transform

# Contrast Streching and histogtram streching




<img src="./A1_resources/A1_resources/hist_equal2.jpg" />
Binary file added DIP/A1.pdf
Binary file not shown.
Binary file added DIP/A1_resources.zip
Binary file not shown.
7 changes: 7 additions & 0 deletions DIP/A1_resources/A1_resources/color_detect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import numpy as np
import cv2

cv2.imread('./rose.jpeg')


# def top_k_color(im,k):
Binary file added DIP/A1_resources/A1_resources/hist-match-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DIP/A1_resources/A1_resources/hist-match-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DIP/A1_resources/A1_resources/hist_equal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DIP/A1_resources/A1_resources/hist_equal2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DIP/A1_resources/A1_resources/lena.bmp
Binary file not shown.
Binary file added DIP/A1_resources/A1_resources/palm-leaf-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DIP/A1_resources/A1_resources/palm-leaf-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DIP/A1_resources/A1_resources/rose.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DS/23-ssspaths.ppt
Binary file not shown.
Binary file added DS/A2.zip
Binary file not shown.
253 changes: 253 additions & 0 deletions DS/AVL.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
#include <stdio.h>
#include <stdlib.h>

struct node{
struct node* left;
struct node* right;
int key;
int h;
};

int max(int a,int b)
{
return a>b?a:b;
}

int height(struct node* a)
{
if(a==NULL)
return 0;
else
return a->h;
}

struct node* clock(struct node* root)
{
struct node* child=root->left;
struct node* subtree=root->left->right;

root->left=subtree;
child->right=root;


root->h=max(height(root->left),height(root->right))+1;
child->h=max(height(child->left),height(child->right))+1;


return child;
}


struct node* aclock(struct node* root)
{
struct node* child=root->right;
struct node* subtree=root->right->left;

root->right=subtree;
child->left=root;

root->h=max(height(root->left),height(root->right))+1;
child->h=max(height(child->left),height(child->right))+1;

return child;
}


void print(struct node* root)
{
if(root==NULL)
return;

print(root->left);

printf("val::%d heigh:%d\n",root->key,height(root));

print(root->right);

}


//insert
struct node* insert(struct node* root,int t)
{

if(root==NULL)
{
struct node* newnode=(struct node*)malloc(sizeof(struct node));
newnode->right=NULL;
newnode->left=NULL;
newnode->key=t;
newnode->h=1;
return root=newnode;
}


if(root->key >= t)
root->left=insert(root->left,t);

else if(root->key < t)
root->right=insert(root->right,t);

// printf("check root:%d\n",root->key);
// print(root->left);
// print(root->right);

// printf("\n");

if(height(root->left) > height(root->right) + 1)
{

if(height(root->left->left) < height(root->left->right))
root->left=aclock(root->left);

root=clock(root);
}

else if(height(root->right) > height(root->left) + 1)
{
if(height(root->right->right) < height(root->right->left))
root->right=clock(root->right);

root=aclock(root);
}

root->h=max(height(root->left),height(root->right))+1;
// printf("height::%d\n",root->h);

return root;

}

struct node* delnode(struct node* root,struct node* head)
{
if(root->left==NULL)
{
head->key=root->key;


if(root->right!=NULL)
return root->right;
else
return NULL;
}

root->left=delnode(root->left,head);

if(height(root->left) > height(root->right) + 1)
{

if(height(root->left->left) < height(root->left->right))
root->left=aclock(root->left);

root=clock(root);
}

else if(height(root->right) > height(root->left) + 1)
{
if(height(root->right->right) < height(root->right->left))
root->right=clock(root->right);

root=aclock(root);
}

root->h=max(height(root->left),height(root->right))+1;
// printf("height::%d\n",root->h);



return root;

}

struct node* del(struct node* root,int val)
{
if(root==NULL)
{printf("Nothing to delete\n");return root;}

if(root->key > val)
root->left=del(root->left,val);
else if(root->key < val)
root->right=del(root->right,val);

else
{
printf("here\n");
if(root->left==NULL&&root->right==NULL)
return root=NULL;

else if(root->left==NULL)
root=root->right;

else if(root->right==NULL)
root=root->left;
else
root=delnode(root,root);

}



if(height(root->left) > height(root->right) + 1)
{

if(height(root->left->left) < height(root->left->right))
root->left=aclock(root->left);

root=clock(root);
}

else if(height(root->right) > height(root->left) + 1)
{
if(height(root->right->right) < height(root->right->left))
root->right=clock(root->right);

root=aclock(root);
}

root->h=max(height(root->left),height(root->right))+1;
// printf("height::%d\n",root->h);

return root;

}


//search

int main()
{
struct node* head = NULL;


int t=0;
while(t!=-1)
{
scanf("%d",&t);

if(t==-1)
break;

head=insert(head,t);

print(head);

}

t=0;
while(t!=-1)
{
scanf("%d",&t);

if(t==-1)
break;

head=del(head,t);

print(head);

}



return 0;
}
77 changes: 77 additions & 0 deletions DS/BIT.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int> II;
typedef vector< II > VII;
typedef vector<int> VI;
typedef vector< VI > VVI;
typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

const int N = int(1e5)+10;

VI G[N];
int BIT[N],A[N];

int sum(int x)
{
int ret=0;
while(x)
{
ret ^= BIT[x];
x -= x&(-x);
}
return ret;
}

void update(int x, int val) // add val to A[x]
{
while(x < N)
{
BIT[x] ^= val;
x += x&(-x);
}
}

int query(int l, int r)
{
return sum(r)^sum(l-1);
}

int main()
{
return 0;
}
Binary file added DS/LCA.ppt
Binary file not shown.
Binary file added DS/Resume.docx
Binary file not shown.
Binary file added DS/a.out
Binary file not shown.
Binary file added DS/attachments.zip
Binary file not shown.
Loading

0 comments on commit a79b143

Please sign in to comment.