Question 30
Select the asymptotic worst-case time complexity of the following algorithm:
Algorithm
Input: $a_1, a_2, ..., a_n$, a sequence of numbers
$n$, the length of the sequence
$x$, a number
Output: ??
$i := 1$
while ($x \neq a_i$ and $i < n$)
$i := i + 1$
End-while
If ($x = a_i$) Return($i$)
Return(-1)
$\Theta(n^3)$
$\Theta(n^2)$
$\Theta(n)$
$\Theta(1)$
Question 31
If mergesort is called with input list (17, 5, 13, 9, 21, 7), then which two lists are sent to the merge
operation?