ADA Week 5

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

18/07/2018 Design And Analysis Of Algorithms - - Unit 16 - Week 5 Quiz

[email protected]

Courses » Design And Analysis Of Algorithms

Announcements Course Ask a Question Progress Mentor

Unit 16 - Week 5
Quiz

Course
outline Week 5 Quiz
The due date for submitting this assignment has passed. Due on 2018-03-14, 23:59 IST.
How to access
the portal Submitted assignment

Week 1: All questions carry equal weightage. You may submit as many times as you like within the deadline.
Introduction Your final submission will be graded.

1) Suppose we want to extend the union-find data structure to support the operation Reset(c), 2 points
Week 1: Analysis
of algorithms which takes as input the name of a component c and then breaks up c into singleton components, like
MakeUnionFind(). For instance if c = 3 and c currently consists of {1,3,7}, then Reset(c) will produce
Week 1 Quiz three components called 1, 3 and 7 consisting of {1}, {3} and {7}, respectively.
Which of the following is correct about the cost of adding Reset(c) to the array and pointer
Week 2: implementations of union-find discussed in the lecture?
Searching and
sorting Array representation: O(n), Pointer representation: O(n)
Array representation: O(size(c)), Pointer representation: O(n)
Week 2 Quiz
Array representation: O(n), Pointer representation: O(size(c))
Week 2 Array representation: O(size(c)), Pointer representation: O(size(c))
Programming
Assignment No, the answer is incorrect.
Score: 0
Week 3: Graphs Feedback:
In the array representation we have the list Members[c] which allows us to update the contents of c in time
Week 3 Quiz O(size(c)). In the pointer representation there is no easy way to identify all elements that belong to
component c without scanning the entire set, so it takes time O(n)
Week 3
Accepted Answers:
Programming
Assignment Array representation: O(size(c)), Pointer representation: O(n)

2) Suppose we want to delete an arbitrary element from a max heap. (Assume we have 2 points
Week 4:
auxiliary arrays NodeToHeap[] and HeapToNode[] required for the update() operation.)
Weighted graphs
Consider the following strategies.
Week 4 Quiz
Strategy 1: Remove the element from the array, compress the array and reheapify.
Strategy 2: Update the value of this node to the current maximum value in the heap + 1, then
Week 4
Programming delete_max.
Assignment
Strategy 1 takes time O(n log n) and Strategy 2 takes time O(n)
Week 5: Data Strategy 1 takes time O(n) and Strategy 2 takes time O(n log n)
Structures: Strategy 1 takes time O(log n) and Strategy 2 takes time O(n)
Union-Find and
Heaps Strategy 1 takes time O(n) and Strategy 2 takes time O(log n)

No, the answer is incorrect.


Week 5: Divide Score: 0
and Conquer
Feedback:

https://onlinecourses.nptel.ac.in/noc18_cs20/unit?unit=144&assessment=145 1/3
18/07/2018 Design And Analysis Of Algorithms - - Unit 16 - Week 5 Quiz
Compressing the array and heapify both take time O(n), so Strategy 1 takes time O(n). Look up the max
Week 5 Quiz
value in a heap takes time O(1). Updating the node takes time O(log n), and so does delete_max(). So the
Quiz : Week 5 second strategy takes time O(log n)
Quiz Accepted Answers:
Strategy 1 takes time O(n) and Strategy 2 takes time O(log n)
Week 6: Data
Structures: 3) Suppose we want to support the operations predecessor and successor in a heap. Given a 2 points
Search Trees
value v in the heap, pred(v) tells us the next smaller value currently in the heap and succ(v) tells us the
next larger value currently in the heap.
Week 6: Greedy
Algorithms
In a min heap, pred(v) takes time O(n) and succ(v) takes O(log n) whereas in a max heap
pred(v) takes time O(log n) and succ(v) takes O(n).
Week 6 Quiz
In a min heap, pred(v) takes time O(log n) and succ(v) takes O(n)whereas in a max heap
Week 6 pred(v) takes time O(n) and succ(v) takes O(log n).
Programming In both min heaps and max heaps, both operations take time O(n).
Assignment In both min heaps and max heaps, both operations take time O(log n).

Week 7: Dynamic No, the answer is incorrect.


Programming Score: 0
Feedback:
Week 7 Quiz
In either case, there is no obvious way to compute pred(v) and suc(v) without scanning all elements, so
both cases take O(n).
Week 7
Programming Accepted Answers:
Assignment In both min heaps and max heaps, both operations take time O(n).

Week 8: Linear 4) Suppose we do merge sort with a three-way split: divide the array into 3 equal parts, sort 2 points
Programming each part and do a 3 way merge. What would the worst-case complexity of this version be?
and Network
Flows O(n2)
O(n2 log3n)
Week 8:
Intractability O(n log2n)

O(n (log2n)2)
Week 8 Quiz
No, the answer is incorrect.
Download Score: 0
Feedback:
TEXT
TRANSLATION The recurrence will yield O(n log3 n), but log3 n = log2 n / log2 3 = O(log2 n).

Accepted Answers:
O(n log2n)

5) In the closest pair of points problem, we have assumed that no two points have the same x 2 points
or y coordinate. Which of the following steps would become more complicated to justify without this
assumption.

Arguing that every d/2 side square in the d-band around the separator can have at most one
point.
Constructing SY from QY and RY in time O(n) the combine step.
Constructing QX and RX from PX in time O(n) in the divide step.
Constructing QY and RY from PY in time O(n) in the divide step.

No, the answer is incorrect.


Score: 0
Feedback:
All x-coordinates could be the same, in which case we may need O(n) time for each point in PY to assign
to QY or RY.

Accepted Answers:
Constructing QY and RY from PY in time O(n) in the divide step.

End
https://onlinecourses.nptel.ac.in/noc18_cs20/unit?unit=144&assessment=145 2/3
18/07/2018 Design And Analysis Of Algorithms - - Unit 16 - Week 5 Quiz

© 2014 NPTEL - Privacy & Terms - Honor Code - FAQs -


A project of In association with

Funded by

Powered by

https://onlinecourses.nptel.ac.in/noc18_cs20/unit?unit=144&assessment=145 3/3

You might also like