Noc20-Cs27 Week 03 Assignment 01

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

02/07/2020 Design and analysis of algorithms - - Unit 9 - Week 3 Quiz

(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)

[email protected]

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » Design and analysis of algorithms (course)

Announcements (announcements) About the Course (https://swayam.gov.in/nd1_noc20_cs27/preview)

Ask a Question (forum) Progress (student/home) Mentor (student/mentor)

Unit 9 - Week 3 Quiz

Course
outline Week 3 Quiz
How does an The due date for submitting this assignment has passed. Due on 2020-02-19, 23:59 IST.
NPTEL online As per our records you have not submitted this assignment.
course work?
All questions carry equal weightage. You may submit as many times as you like within the deadline.
Week 1 : Your final submission will be graded.
Introduction
1) An undirected graph G on 30 vertices has 4 connected components. What is the minimum 2 points
number of edges in G?
Week 1 : Analysis
of algorithms 29
25
Week 1 Quiz
26

Week 2 : Depends on the sizes of the four connected components.


Searching and No, the answer is incorrect.
sorting Score: 0
Feedback:
Week 2 Quiz A minimal connected graph on n vertices is a tree, with n-1 edges. If each of the four components is a tree
and we join them with edges to form a single component, we would have to add 3 edges. The resulting
Week 2 graph would be a tree with 29 edges on 30 vertices. Hence, the four components originally had 26 edges.
Programming This is the same, regardless of how the graph is decomposed
Assignment Accepted Answers:
26
Week 3 : Graphs
2) Suppose we have a directed graph G = (V,E) with V = {1,2,…,n} and E is presented as an 2 points
adjacency list. For each vertex u in V, out(u) is a list [v1,v2,…,vk] such that (u,vi) in E for each i in {1,2,…,k.
Week 3 Quiz
For each u in V, we wish to compute a corresponding list in(u) = [v1,v2,…,vk'] such that (vi,u) in E for each i
Quiz : Week 3 in {1,2,…,k'.
Quiz
Let n be the number of vertices in V and m be the number of edges in E. How long would it take to
(assessment?
construct the lists in(u), u in V, from the lists out(u), u in V?
name=102)

O(m)

https://onlinecourses.nptel.ac.in/noc20_cs27/unit?unit=101&assessment=102 1/4
02/07/2020 Design and analysis of algorithms - - Unit 9 - Week 3 Quiz

Week 3 O(n + m)
Programming O(n2)
Assignment O(n2 + m)
No, the answer is incorrect.
Week 4 : Score: 0
Weighted graphs Feedback:
We can do it in O(n+m) as follows. Initialize in(u) to empty for each u in V (time O(n)). For each v in V, scan
Week 4 Quiz out(v) and for each j in out(v), add v to in(j) (time O(m) across all V).
Accepted Answers:
Week 4 O(n + m)
Programming
Assignment 3) Suppose we obtain the following DFS tree rooted at node D for an undirected graph Gr with 2 points
vertices {A,B,C,D,E,F,G,H}.
Week 5: Data
Structures:
Union-Find and
Heaps

Week 5 : Divide
and Conqure

Week 5 Quiz Which of the following cannot be an edge in the graph Gr?

Week 6: Data (D,E)


Structures: (D,H)
Search Trees
(A,G)

Week 6: Greedy (A,C)


Algorithms No, the answer is incorrect.
Score: 0
Week 6 Quiz Feedback:
In an undirected graph, all non-tree edges of a DFS tree must be along a path from an ancestor to a
descendant. (A,C) is an edge across different paths and hence not possible.
Week 6
Programming Accepted Answers:
Assignment (A,C)

4) We are interested in topological orderings of the following DAG that satisfy one or both of the 2 points
Week 7: Dynamic following constraints:
Programming
4 appears before 3
8 appears after 7
Week 7 Quiz
How many such orderings are there?
Week 7
Programming
Assignment

Week 8: Linear
Programming
and Network
Flows 18
16
Week 8:
6
Intractability
2
Week 8 Quiz No, the answer is incorrect.
Score: 0
Text Transcripts Feedback:

https://onlinecourses.nptel.ac.in/noc20_cs27/unit?unit=101&assessment=102 2/4
02/07/2020 Design and analysis of algorithms - - Unit 9 - Week 3 Quiz

Any topological sort is of the form 1, followed by a topological ordering of {2,3,4,5}, followed by 6, followed
Books by a topological ordering {7,8,9}.
Nodes {2,3,4,5} have (4 choose 2) = 6 topological orderings of which only one, 2-3-4-5 has 3 before 4. All
Download Videos
other orderings have 4 before 3: 2-4-3-5, 2-4-5-3, 4-2-3-5, 4-2-5-3, 4-5-2-3..
Nodes {7,8.9} have 3 topological orderings, 7-8-9, 8-7-9, 8-9-7, of which two have 8 before 7 and one has 8
after 7.
There are 6 × 3 = 18 total topological orderings of which 1 × 2 = 2 violates both conditions, so 16 satisfy
one condition or both.
Accepted Answers:
16

5) Finishing the interiors of a lecture hall consists of several steps, such as laying electrical 2 points
cables, installing audio-visual equipment, attaching the blackboard, etc. Suppose there are 10 steps,
labelled A, B, C, D, E, F, G, H, I, J. Each step takes a day to complete and we have the following
dependencies between steps.
A must happen before J
B must happen before D
B must happen before G
C must happen before B
D must happen before A
D must happen before E
E must happen before J
F must happen before C
G must happen before D
H must happen before F
H must happen before I
I must happen before B
I must happen before G

What is the minimun number of days required to complete the interiors?

9
8
7
6
No, the answer is incorrect.
Score: 0
Feedback:
Here is the corresponding dag, whose longest path, for instance H-F-C-B-G-D-A-J, has length 8.

Accepted Answers:
8

https://onlinecourses.nptel.ac.in/noc20_cs27/unit?unit=101&assessment=102 3/4
02/07/2020 Design and analysis of algorithms - - Unit 9 - Week 3 Quiz

https://onlinecourses.nptel.ac.in/noc20_cs27/unit?unit=101&assessment=102 4/4

You might also like