Distributed Systems Assignment 5 Solution

$30.00 $24.00

In this Assignment, you will write parallel codes using mpi [100 marks] programming. In the earlier assignment, you have setup mpi on the system and made sure that it is working. Language Constraint: ​C/C++ Include a bash script to run each of the code in your submission. Name them q1.sh, q2.sh, q3.sh, q4.sh Q 1)…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

In this Assignment, you will write parallel codes using mpi

[100 marks]

programming. In the earlier assignment, you have setup mpi on the

system and made sure that it is working.

Language Constraint: C/C++

Include a bash script to run each of the code in your submission.

Name them q1.sh, q2.sh, q3.sh, q4.sh

Q 1) Parallel QuickSort.

[25 marks]

Given an array of numbers, your task is to return the array in sorted

order by implementing parallel quick sort.

Input Format:

-> bash q1.sh `num_process` `num_elements` `elements separated

by spaces`

Output Format :

-> `elements in sorted order`

Q 2) Stable Marriage Problem

[25 marks]

Let men and women each be array of n processes. Each man ranks

the women from 0 to n-1 and each woman ranks the men from 0 to

n-1. A pairing is a one-to-one correspondence of men and women. A

pairing is stable if, for two men m1 and m2 and their paired women

w1 and w2, both of the following conditions are satisfied:

  • m1 ranks w1 higher than w2 or w2 ranks m2 higher than m1; and

  • m2 ranks w2 higher than w1 or w1 ranks m1 higher than m2.

Expressed differently, a pairing is unstable if a man and woman would both prefer each other to their current pair. A solution to the stable marriage problem is a set of n pairings, all of which are stable. Write a distributed program to solve the stable marriage problem. The processes should communicate using asynchronous message passing . The men should send proposal and the women should listen. A woman has to accept the first proposal she gets, because a better one might not come along; however, she can dump the first man if she later gets a better proposal. Write the program using MPI. Log the trace of events (pairing, breaking), as they happen, in a text file named as Log.txt .

The number of slave processes will be 2n.

Input Format :

-> bash q1.sh `num_processes`

First line of input contains the integer n, denoting the number of men and women. The following 2n lines are the preferences of each

person. The first n lines corresponds to the preferences of men and

the second n lines corresponds to preferences of women.

Output Format:

Output n sorted lines (sorted wrt indices of men) with each line

denoting the matched pair. The first element of the pair corresponds

to the index of men and the second element to the matched women.

Sample:

Input:

-> bash q2.sh `num_processes`

4

3120

1023

0123

0123

0123

0123

0123

0123

Output ( Men Women):

0 3

1 1

2 0

3 4

Q 3) Single-Source Shortest Path

[25 marks]

Given a weighted graph and the node number of source, find the shortest

distance of all nodes from the source.

Input Format:

-> bash q3.sh `num_processes`

First line of input will be number of nodes(n), number of edges(m) and

node number of source, followed by m subsequent lines each having two

nodes between which edge is present.

Output Format:

Print node number and its shortest distance from the source for each node

in graph.

Q 4) Vertex Coloring

[25 marks]

Given an undirected graph G, assign a color to every vertex such that no

two adjacent vertices have the same color.

Total number of colors should not exceed d + 1 where d is the maximum

degree of the graph.

Write an MPI program to find the optimal coloring to given graph G. The

processes should communicate using asynchronous message passing .

Input Format :

-> bash q4 `num_processes`

First line of input contains two integers n and m. This is followed by m lines

where each

line is for an edge between 2 nodes in G.

Output Format:

Output the number of colors used in the first line followed by T (number of color) lines printing the color of nodes from 0 to T – 1.

Note:Your output may be different but ensure that it follows the mentioned Constraints.

Sample:

Input:

  • 7

0 1

0 2

1 3

2 3

3 4

3 5

4 5

Output:

3

0

1

1

0

1

2

Note:​​Submitting a serial code for any problem instead of a parallel code will result in negative marking (-10).

Note: Strict actions would be taken against anyone found involved in any kind of plagiarism either from the internet or from other students.

Distributed Systems Assignment 5 Solution
$30.00 $24.00