Professional Documents
Culture Documents
HW#1
HW#1
HW#1
7. Binary Search algorithm costs _______________in the worst case while it costs __________ in the best
case.
9. For the following array, Merging Two Sorted List algorithm requires ________ element comparisons.
10. The order of growth of the function f(n)=2n×n is lower than the function g(n)= 2n×n2. Hence, f(n)=O(g(n)).
1
11. What is the time complexity for the following algorithm?
12. Big-Oh notation expresses the upper bound which describes the __________________ scenario.
14. Express the time complexity of the following function in terms of the Θ-notation.
18. What is the time complexity to find the smallest element in a three-dimensional array?
2
20. Given f(n) and g(n). Is f(n) = O(g(n))?
25. The least significant bit Radix sort algorithm is ___________ for both time and space complexities.
3
29. What is the time complexity of the following algorithm?
32. Consider Merging Two Sorted List algorithm. If we want to implement this algorithm for the array
A={1,3,4,5,6,8,9,0,2,7}, what is the value of x,y, and z.
33. What is the time complexity of the following algorithm?
35. Given the following functions, ____________________ is the best as it has the lowest time complexity.
4
37. For the following algorithm, the best-case time complexity is __________ while it is ______________ in
the worst case.
38. Express the time complexity of the following function in terms of the Θ-notation.
39. Given an array A={5,4,3,2,1}. The exact number of element comparisons using selection sort is
__________.
40. What is the time complexity of the following algorithm?
42. We study algorithms to choose the best time-space complexity to solve a particular problem in the most
____________ way possible.
43. Linear Search algorithm requires ____________ comparison(s) if the searching element is not found in
an array A of size n.
44. The average case time complexity of the Quicksort algorithm is _____________.
46. Given an array A={1,3,4,6,7,9,12,15}. What is the second element to be compared when searching for 0.
48. ______________________ works by repeatedly swapping the adjacent elements if they are in wrong
order.
49. Consider Merging Two Sorted List algorithm. The least number of comparisons occurs when the elements
of the smaller subarray are less than all entries in the larger subarray. For the array A={1,3,4,5,6,8,9,0,2,7},
are the elements of the smaller subarray less than all entries in the larger subarray.
5
50. The most significant bit Radix sort is ________________ time complexity.
53. The average case time complexity of the Selection sort is _________________.
54. The worst case time complexity of the Insertion sort is __________________.
57. The best-case time complexity of the Insertion sort algorithm is _______________.
58. The following figure shows that the cubic class algorithms require fewer operations than linear class
algorithms.
6
62. What is the time complexity of the following algorithm?
63. One limitation of Binary Search algorithm is that the array elements must be _________________.