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

Design and analysis of algorithms - - Unit 17 - ... https://onlinecourses.nptel.ac.in/noc18_cs37/uni...

reviewer3@nptel.iitm.ac.in ▼

Courses » Design and analysis of algorithms

Announcements Course Ask a Question Progress Mentor FAQ

Unit 17 - Week
5 Quiz

Course
outline
Week 5 Quiz
The due date for submitting this assignment has passed.
How to access As per our records you have not submitted this Due on 2018-10-03, 23:59 IST.
the portal assignment.

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

Week 1: 1) Suppose we want to extend the union-find data structure to support the operation 2 points
Analysis of Reset(c), which takes as input the name of a component c and then breaks up c into singleton
algorithms components, like MakeUnionFind(). For instance if c = 3 and c currently consists of {1,3,7}, then
Reset(c) will produce three components called 1, 3 and 7 consisting of {1}, {3} and {7}, respectively.
Week 1 Quiz
Which of the following is correct about the cost of adding Reset(c) to the array and pointer
implementations of union-find discussed in the lecture?
Week 2:
Searching and
sorting Array representation: O(size(c)), Pointer representation: O(size(c))

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(n), Pointer representation: O(n)
Programming
Assignment No, the answer is incorrect.
Score: 0
Week 3: Graphs
Feedback:
Week 3 Quiz In the array representation we have the list
Members[c] which allows us to update the contents of c in time
Week 3 O(size(c)). In the pointer representation there is no easy
Programming way to identify all elements that belong to component c
Assignment without scanning the entire set, so it takes time O(n)
Accepted Answers:
Week 4:
Weighted graphs Array representation: O(size(c)), Pointer representation: O(n)

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

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


A project of In association with

Funded by

1 of 3 Friday 09 November 2018 01:11 PM


Design and analysis of algorithms - - Unit 17 - ... https://onlinecourses.nptel.ac.in/noc18_cs37/uni...

No, the answer is incorrect.


Powered by
Week 5: Divide
Score: 0
and Conquer
Feedback:
Week 5 Quiz All x-coordinates could be the same, in which case we may need O(n) time for each point in PY to assign it
to QY or RY.
Quiz : Week 5
Quiz Accepted Answers:
Constructing QY and RY from PY in time O(n) in the divide step.
Week 6: Data
Structures: 3) Suppose we want to delete an arbitrary element from a max heap. (Assume we have 2 points
Search Trees auxiliary arrays NodeToHeap[] and HeapToNode[] required for the update() operation.)
Consider the following strategies.
Week 6: Greedy
Algorithms 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 6 Quiz delete_max.

Week 7: Strategy 1 takes time O(n) and Strategy 2 takes time O(log n)
Dynamic
Programming Strategy 1 takes time O(log n) and Strategy 2 takes time O(n)

Strategy 1 takes time O(n) and Strategy 2 takes time O(n log n)
Week 7 Quiz
Strategy 1 takes time O(n log n) and Strategy 2 takes time O(n)
Week 7
Programming No, the answer is incorrect.
Assignment Score: 0
Feedback:
Week 8: Linear
Compressing the array and heapify both take time O(n), so Strategy 1 takes time O(n). Look up the max
Programming
and Network value in a heap takes time O(1). Updating the node takes time O(log n), and so does delete_max(). So the
Flows second strategy takes time O(log n).
Accepted Answers:
Week 8: Strategy 1 takes time O(n) and Strategy 2 takes time O(log n)
Intractability
4) Suppose we want to support the operations predecessor and successor in a heap. Given 2 points
Week 8 Quiz a 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.
TEXT
TRANSLATION In both min heaps and max heaps, both operations take time O(n).

In both min heaps and max heaps, both operations take time O(log n).

In a min heap, pred(v) takes time O(log n) and succ(v) takes O(n) whereas in a max heap
pred(v) takes time O(n) and succ(v) takes O(log n).

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).

No, the answer is incorrect.


Score: 0
Feedback:
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).
Accepted Answers:
In both min heaps and max heaps, both operations take time O(n).

5) Suppose we do merge sort with a five-way split: divide the array into 5 equal parts, sort 2 points
each part and do a 5 way merge. What would the worst-case complexity of this version be?

O(n2)

O(n2 log5n)

O(n log2n)

O(n (log2n)2)

2 of 3 Friday 09 November 2018 01:11 PM


Design and analysis of algorithms - - Unit 17 - ... https://onlinecourses.nptel.ac.in/noc18_cs37/uni...

No, the answer is incorrect.


Score: 0
Feedback:
The recurrence will yield O(n log5 n), but log5 n = log2 n / log2 5 = O(log2 n).
Accepted Answers:
O(n log2n)

End

3 of 3 Friday 09 November 2018 01:11 PM

You might also like