CSC 306 Midterm; Spring 2012.
Q1.
What are the asymptotic complexities of solving the following problems efficiently, give your answer in terms of Θ, Ω or O notation:
a.) Finding Min in an unsorted array.
b.) Finding a Key in a sorted array.
c.) Finding Max in a sorted array.
d.) Merging two sorted array into a larger sorted array.
e.) Pivoting in an unsorted array.
f.) Sorting an array using Radix sort. Explain. (2 pts) g.) Removing root from a Heap.
h.) Enqueue in a Heap-based-Priority-Queue.
i.) Sorting using Randomized Quicksort. Explain.
Q2.
What are the positions (in terms of index number) of (a-e):
(a-e carries 1 point, f carries 5 points) a.) Root in a heap.
b.) First leaf in a Heap.
c.) Last leaf in a Heap.
d.) Left child of node indexed at i in a Heap.
e.) Parent of Right Child indexed at i, in a Heap.
f.) What is minimum and maximum number of nodes in a Heap of height h.
Q3.
I have 6 identical balls in their appearance. 5 of them are exactly of same weight, sixth one (faulty) is different but I don’t know whether it is heavier or lighter. What is the minimum number of comparisons required to locate the faulty ball and tell whether it is light or heavy using a two pan scale (Daripalla). Give an algorithm for your answer.
How many comparisons would be required had I known from the beginning that the faulty ball is heavier? Explain.
Q4.
Argue that the tallest and the second tallest student in a class of 32 can be found in no more that 35 comparisons.