Professional Documents
Culture Documents
DMPT - Experiential Learning Assignment
DMPT - Experiential Learning Assignment
ASSIGNMENT
for i in range(N):
if (prefer[w][i] == m1):
return True
if (prefer[w][i] == m):
return False
def stableMarriage(prefer):
freeCount = N
m=0
if (mFree[m] == False):
break
m += 1
i=0
while i < N and mFree[m] == False:
w = prefer[m][i]
if (wPartner[w - N] == -1):
wPartner[w - N] = m
mFree[m] = True
freeCount -= 1
else:
m1 = wPartner[w - N]
wPartner[w - N] = m
mFree[m] = True
mFree[m1] = False
i += 1
for i in range(N):
# Driver Code
stableMarriage(prefer)
Q)Euclid s Algorithm
#include<iostream>
•
• #include<conio.h>
•
• #include<stdlib.h>
•
•
•
• using namespace std;
•
• int gcd(int u, int v)
•
•{
•
• return (v != 0) ? gcd(v, u % v) : u;
•
•}
•
•
•
• int main(void)
•
•{
•
• int num1, num2, result;
•
• cout << "Enter two numbers to find GCD using
Euclidean algorithm: ";
•
• cin >> num1 >> num2;
•
• result = gcd(num1, num2);
•
• if (gcd)
•
• cout << "\nThe GCD of " << num1 << " and " <<
num2 << " is: " << result
•
• << endl;
•
• else
•
• cout << "\nInvalid input!!!\n";
•
• return 0;
•
•}
•
Q)Piegonhole principle
#include<stdio.h>
int res = (x % m + m) % m;
printf("Modular multiplicative inverse is %d", res);
}
}
int gcdExtended(int a, int b, int* x, int* y)
{
if (a == 0)
{
*x = 0, *y = 1;
return b;
}
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
int main()
{
int a, m;
printf("Enter two numbers a nd m,such that multiplicative inverse
of(a modulo m)- ");
scanf("%d%d",&a,&m);
modInverse(a, m);
return 0;
}