Python Week 10 Programming Assignment Solutions 2021

 

Week 10 Programming Assignment 1

Due on 2021-04-01, 23:59 IST
Consider a directed graph. It can be represented by an adjacency matrix. The nodes are numbered 1 to n. If there is an edge from node i to node j, there will be a 1 in the (i-1,j-1) position in the adjacency matrix. There are no self loops in the graph. For a node, the number of head ends adjacent to a node is called the indegree of the node and the number of tail ends adjacent to a node is its outdegree. Print 'yes'  and the node number if  in the given graph there is a node with indegree 2, else print 'no'. Adjacency matrix is given as a line of zeros and ones in row major order i.e, row 1 will be given as input first then the row 2 so on. There will be only one edge with indegree 2.

Input format :
Line 1 - Number of nodes
Line 2 - Adjacency matrix in row major order

Output format : if the condition is satisfied then yes node_number else no

Example 
input:
4
0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 0
output
no



Week 10 Programming Assignment 2

Due on 2021-04-01, 23:59 IST

Consider a directed graph. It can be represented by an adjacency matrix. The nodes are numbered 1 to n. If there is an edge from node i to node j, there will be a 1 in the (i-1,j-1) position in the adjacency matrix. There are no self loops in the graph. For a node, the number of head ends adjacent to a node is called the indegree of the node and the number of tail ends adjacent to a node is its outdegree. Print 'yes'  and the node number if  in the given graph there is a node with outdegree 2, else print 'no'. Adjacency matrix is given as a line of zeros and ones in row major order i.e, row 1 will be given as input first then row 2 so on. There will be only one edge with outdegree 2.


Input format :

Line 1 - Number of nodes

Line 2 - Adjacency matrix in row major order


Output format : if the condition is satisfied then yes node_number else no


Example 

input:

4 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0

output

yes 2






Week 10 Programming Assignment 3

Due on 2021-04-01, 23:59 IST
Consider a directed graph. It can be represented by an adjacency matrix. The nodes are numbered 1 to n. If there is an edge from node i to node j, there will be a 1 in the (i-1,j-1) position in the adjacency matrix. There are no self loops in the graph. print yes if the given graph is a complete graph (connection from one node to all other node) else print no



Post a Comment (0)
Previous Post Next Post