Assignment 1
Faculty: MZG
1. You are given a sorted array of 8000 unique integers and you need to search for the target
number 4561. [2.5+2.5]
a. What is the maximum number of comparisons needed in binary search in the worst case?
b. What is the maximum number of comparisons in quaternary search (i.e., splitting into 4
parts)?
2. Suppose you are working in a resource-constrained environment where memory is very
limited, and you must sort a huge dataset. You have the choice between QuickSort and Merge
Sort. Which one should you choose, and why? Consider both time and space complexities in
your answer. [2.5]
3. You have decided to implement Quick Sort using the first element of the array as the pivot to
sort a dataset. Will this pivot selection approach be efficient for an already sorted or nearly sorted
array? Explain your reasoning in detail. [2.5]
4. Sort the following functions in ascending order: [5]
f1 = n2logn, f2 = n4/5, f3 = nlogn
5. You have an array where the left subarray is in strictly decreasing order and the right subarray
is in strictly increasing order. Propose a modified version of your ternary search algorithm. [5]