Skip to content
Open
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
119 changes: 119 additions & 0 deletions 1830133_exp_2_1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<stdbool.h>

bool prime_alpha(int n)
{
for(int i=n;i>1;i--)
{
if(n%i==0) return false;
}
return true;
}

bool prime_beta(int n)
{
if (n <= 1) return false;
if (n <= 3) return true;

if (n%2 == 0 || n%3 == 0) return false;

for (int i=5; i*i<=n; i=i+6)
if (n%i == 0 || n%(i+2) == 0)
return false;

return true;
}

int power(int x, unsigned int y, int p)
{
int res = 1;
x = x % p;

while (y > 0)
{
if (y & 1)
res = (res*x) % p;

y = y>>1;
x = (x*x) % p;
}
return res;
}

bool miillerTest(int d, int n)
{
int a = 2 + rand() % (n - 4);
int x = power(a, d, n);

if (x == 1 || x == n-1)
return true;

while (d != n-1)
{
x = (x * x) % n;
d *= 2;

if (x == 1) return false;
if (x == n-1) return true;
}

return false;
}
bool prime_gamma(int n)
{
if (n <= 1 || n == 4) return false;
if (n <= 3) return true;

int d = n - 1;
while (d % 2 == 0)
d /= 2;

int k= 30;
for (int i = 0; i < k; i++)
if (!miillerTest(d, n))
return false;

return true;
}

double time_alpha(int a)
{
clock_t start,end;
start=clock();
prime_alpha(a);
end=clock();
double time=(((double)(end-start))/CLOCKS_PER_SEC);
return time;
}
double time_beta(int a)
{
clock_t start,end;
start=clock();
prime_beta(a);
end=clock();
double time=(((double)(end-start))/CLOCKS_PER_SEC);
return time;
}

double time_gamma(int a)
{
clock_t start,end;
start=clock();
prime_beta(a);
end=clock();
double time=(((double)(end-start))/CLOCKS_PER_SEC);
return time;
}

int main()
{
int num[10]={71,173,281,409,541,659,801,941,1069,1223};
for (int i=1;i<10;i++)
{
printf("\n algo_1 :%f",time_alpha(num[i]));
printf(" algo_2 :%f",time_beta(num[i]));
printf(" algo_3:%f",time_gamma(num[i]));
}
}
42 changes: 42 additions & 0 deletions Prime_number_algo-2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include<stdio.h>
#include<time.h>
int isPrime(int n, int i)
{
if(i == 1)
return 1;
else
{
if(n%i == 0)
return 0;
else
isPrime(n, i-1);
}
}

int main()
{
int num, prime;
clock_t start,end;

printf("Enter a positive number to check if Prime: ");
scanf("%d", &num);
start=clock();
isPrime(num, num/2);
end=clock();
prime = isPrime(num, num/2);
if(prime == 1)
{
printf("\n%d is a prime number", num);
}
else
{
printf("\n%d is a Composite number", num);
}

double time_taken=(((double)(end-start))/CLOCKS_PER_SEC);

printf("\nThis program takes %f seconds to execute \n",time_taken);
return 0;
}


10 changes: 10 additions & 0 deletions SGC-Maersk.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (iPad; CPU OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/127.0.6533.77 Mobile/15E148 Safari/604.1" version="24.7.6">
<diagram name="Page-1" id="pQ-K65we4det4AXoAWtI">
<mxGraphModel>
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
</root>
</mxGraphModel>
</diagram>
</mxfile>
29 changes: 29 additions & 0 deletions anshul2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<HTML>
<HEAD>
<TITLE>####SKILLS DESCRIPTION####</TITLE>
</HEAD>
<style>
body {
background-image: url('kk.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>
<B><I><U><P ALIGN="CENTER"><FONT SIZE="7" FACE="ARIAL" COLOR="#000000">SKILLS DESCRIPTION
</FONT></P></U><I><B>
<DD><U><FONT SIZE="5" COLOR="#000000">Coding with "C"</FONT></U></DD>
<P>C is a higher level language, we were have having C programming as a subject in the 2nd Semester, and I have secured "A" Grade in C programming language. as "C" is the very basic format of language it also motivated me to go and wxplore other languages like java,python etc.
<DD><U><FONT SIZE="5" COLOR="#000000">DSA with "C"</FONT></U></DD>
<IMG SRC="dsa.jpg"ALT="profile picture"WIDTH=180 HIGHTG=130>
<P>Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language. Search − Algorithm to search an item in a data structure. Sort − Algorithm to sort items in a certain order. Insert − Algorithm to insert item in a data structure. we were having DSA with "C" as a subject in our 3rd Semester, and I have secured "A" Grade in it.</P>
<DD><U><FONT SIZE="5" COLOR="#000000">Coding with "C++"</FONT></U></DD>
<IMG SRC="c++.jpg"ALT="profile picture"WIDTH=110 HIGHTG=40>
<P>C++ is a general-purpose programming language , we were have "Object Oriented Programming with C++" as a Subject in our 4th Semester, and I have secured "A" Grade in it. it was a simple Language,learning it was very intresting.it is an extension of the C programming language, or "C with Classes".
<DD><U><FONT SIZE="5" COLOR="#000000">Coding with "basic-python"</FONT></U></DD>
<IMG SRC="p.jpg"ALT="profile picture"WIDTH=130 HIGHTG=130>
<P>Python is an interpreted, high-level, general-purpose programming language. i have done a course of python with udemy, also i have done training under Eduvance on "python and ML", where we used basics of python</P>
<DD><U><FONT SIZE="5" COLOR="#000000">ML and IBM Watson</FONT></U></DD>
<IMG SRC="ibm.jpg"ALT="profile picture"WIDTH=150 HIGHTG=150>
<IMG SRC="oo.jpg"ALT="profile picture"WIDTH=130 HIGHTG=130>
<P>Machine learning is the study of computer algorithms that improve automatically through experience. It is seen as a subset of artificial intelligence.Watson is a question-answering computer system capable of answering questions posed in natural language, developed in IBM's DeepQA project by a research team led by principal investigator David Ferrucci.I have successfully completed training under this course this is very intresting topic. I have also done 2 minor and 1 major project with ML. I have also used Watson for Machine Learning</P>
105 changes: 105 additions & 0 deletions lab2_first.CPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include<iostream>
#include<time.h>
#include<math.h>
using namespace std;
void gcd(int m, int n)
{
while (n > 0)

{

int r = m % n;

m = n;

n = r;

}

cout<<"GCD ="<<m;

}
void conc(int m, int n)
{
int i,c;

c=m>=n?n:m;

for(i=c;i>=1;i--)
{
if(m%i==0 && n%i==0)
{
printf ("conc = %d \n",i);
break;
}
}

}
void middle(int a, int b)
{
int i,c,ans=1,m=0,n=0,k=0;

c=a>=b?b:a;

for(i=2;i<=c;i++)
{
n=0;
m=0;
if(a%i==0)
{
m=1;
a=a/i;
}
if(b%i==0)
{
n=1;
b=b/i;
}
if(n==1 && m==1)
{
ans=ans*i;
}
if(n==1 || m==1)
{
i--;
}
}
printf("The middle is:%d \n",ans);

}
int main()
{
int m, n,i;

for( i=0;i<6;i++)
{
cout<<"Enter-two integer numbers: ";
cin>>m>>n;

clock_t start,end;

start=clock();
gcd(m,n);
end=clock();

double time_taken=(((double)(end-start))/CLOCKS_PER_SEC);

cout<<"This program takes "<<time_taken<<" seconds to execute"<<endl;
start=clock();
conc(m,n);
end=clock();

time_taken=(((double)(end-start))/CLOCKS_PER_SEC);

cout<<"This program takes "<<time_taken<<" seconds to execute"<<endl;
start=clock();
middle(m,n);
end=clock();

time_taken=(((double)(end-start))/CLOCKS_PER_SEC);

cout<<"This program takes "<<time_taken<<" seconds to execute"<<endl;
}

return 0;
}