Skip to content
This repository was archived by the owner on Nov 1, 2018. It is now read-only.
Open

PR 2 #84

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions double ended queue/doubleend.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include<stdio.h>
#include<stdlib.h>
int i,n,r=-1,f=0;
void insert(int *);
void delete(int *);
void display(int *);
int main()
{
int *a,o;
printf("\ndouble ended queue");

printf("\nenter the size of array");
scanf("%d",&n);

a=(int*)calloc(n,sizeof(int));

printf("\nselect your choice\n");
int f=1;
while(f==1)
{
printf("1)insert\n");
printf("2)delete\n");
printf("3)exit");
scanf("%d",&o);
switch(o)
{
case 1:{
insert(a);
break;
}
case 2:{
delete(a);
break;
}
case 3:{
f=0;
}

}//switch
}//while
}//main

void insert(int *a)
{
int o;
printf("where you want to insert");
printf("1)starting");
printf("2)end");
scanf("%d",&o);
switch(o)
{
case 2:{
printf("enter the element");
scanf("%d",&a[++r]);
}
case 1:{
if(r==n-1)
{
printf("overflow");
}
else
{
printf("enter the element");
for(i=r;i>=0;i--)
{
a[i+1]=a[i];
}
scanf("%d",&a[0]);
}
}
}
}

void delete(int *a)
{
int o;
printf("where you want to delete");
printf("1)starting");
printf("2)end");
scanf("%d",&o);
switch(o)
{
case 2:{
r--;
}
case 1:{
if(r==0)
{
printf("underflow");
}
else
{
for(i=0;i<=r;i++)
{
a[i]=a[i+1];
}

}}
}
}

void display(int *a)
{
for(i=f;i<=r;i++)
{
printf("%d",a[i]);
}
}


Binary file added fast transpose/bin/Debug/fast transpose.exe
Binary file not shown.
43 changes: 43 additions & 0 deletions fast transpose/fast transpose.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="fast transpose" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/fast transpose" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/fast transpose" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="main.c">
<Option compilerVar="CC" />
</Unit>
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
10 changes: 10 additions & 0 deletions fast transpose/fast transpose.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1071" topLine="33" />
</Cursor>
</File>
</CodeBlocks_layout_file>
52 changes: 52 additions & 0 deletions fast transpose/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <stdio.h>
#include <stdlib.h>

struct smarray
{
int r,c,v;
};
int main()
{
int i,r,c,t,pb=0;
struct smarray *a,*b;
int *rowstart,*rowsize;

printf("\n enter r");
scanf("%d",&r);
printf("\n enter c");
scanf("%d",&c);
printf("\n enter t");
scanf("%d",&t);
a=(struct smarray*)malloc(t*sizeof(struct smarray));
b=(struct smarray*)malloc(t*sizeof(struct smarray));
rowstart=(int*)malloc(c*sizeof(int));
rowsize=(int*)calloc(c,sizeof(int));
printf("\n enter array elements");
for(i=0;i<t;i++)
{
scanf("%d%d%d",&a[i].r,&a[i].c,&a[i].v);
}
for(i=0;i<t;i++)
{
rowsize[a[i].c]++;
}
rowstart[0]=0;
for(i=1;i<c;i++)
{
rowstart[i]=rowsize[i-1]+rowstart[i-1];
}
for(i=0;i<t;i++)
{
pb=rowstart[a[i].c];
b[pb].r=a[i].c;
b[pb].c=a[i].r;
b[pb].v=a[i].v;
rowstart[a[i].c]++;
}
printf("\n after transpose");
for(i=0;i<t;i++)
{
printf("\n %d %d %d",b[i].r,b[i].c,b[i].v);
}

}
Binary file added fast transpose/obj/Debug/main.o
Binary file not shown.
1 change: 1 addition & 0 deletions python/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("hello world")
42 changes: 42 additions & 0 deletions static hashing/shashing.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *a,temp,count=0,i;

a=(int*)malloc(sizeof(int)*10);
for(i=0;i<10;i++)
{
a[i]=-1;
}
while(count!=10)
{
printf("\n enter the element you want to insert");
scanf("\n%d",&temp);
i=temp%10;
if(a[i]==-1)
{
a[i]=temp;
count++;
}
else
{
while(a[i]!=-1)
{
i=++i%10;
}
a[i]=temp;
count++;
}
}
if(count==10)
{
printf("\n stack overflow\n");
}

for(i=0;i<10;i++)
{
printf("\n%d",a[i]);
}
}