You are on page 1of 1

Design and analysis of algorithms

Mid-sem-1
Subjective part (Open book)

February 25, 2022

1. In the next few days more students are likely to come to IIT Indore campus. The Covid Task Force
(CTF) is very strict about social distancing in the mess and the rule “do gaz ki doori mask hai jaroori ”.
Suppose at any time there are n students in the mess. We have to help CTF to find a pair of students
having the minimum distance between any two students. One trivial solution is that calculate distance
(Euclidean distance)
 between every pair of students, and then find a pair having the minimum distance.
Since there are n2 pairs this approach will take Θ(n2 ) time. How can we find a pair having the minimum
distance more efficiently? Can we do it in O(n log n)? [20 Marks]
2. There are many sorting algorithms that are based on comparing the input elements. None of these
algorithms can not beat the O(n log n) time. Suppose an alien came and claim that he/she has a
comparison-based algorithm which beats the O(n log n) time. Prove that the alien is wrong, the alien’s
algorithm can not beat O(n log n). [10 marks]

3. Illustrate the operation of inserting 9 on the binary heap A = h14, 13, 8, 5, 11, 8, 7, 3, 0, 6, 2, 1i. [5 marks]
4. (a) Illustrate the operation of counting sort on A = h5, 0, 2, 0, 1, 2, 3, 2i. [5 marks]
(b) Prove that counting sort is stable. [5 marks]

You might also like