Está en la página 1de 2

ALGORITHM SOLVING PROBLEMS

1. The complexity of Binary search algorithm is a) O(n) b) O(log ) c) O(n2) d) O(n log n) Answer: B 2. The memory address of fifth element of an array can be calculated by the formula a) LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array b) LOC(Array[5])=Base(Array[5])+(5-lower bound), where w is the number of words per memory cell for the array c) LOC(Array[5])=Base(Array[4])+(5-Upper bound), where w is the number of words per memory cell for the array d) None of above Answer:A 3. What is the worst-case time for heapsort to sort an array of n elements? a) O(log n) b) O(n) c) O(n log n) d) O(n) Answer: C 4. From fastest to slowest, the correct order for the following algorithms is a) Linear search, Binary search, Bubble Sort, Selection Sort, nding the maximum element of an unsorted array, nding the maximum element of a sorted array. b) nding the maximum element of an unsorted array, nding the maximum element of a sorted array, Linear search, Binary search, Selection Sort, Bubble Sort. c) nding the maximum element of a sorted array, Binary search,Linear search, nding the maximum element of an unsorted array,Selection Sort, Bubble Sort. d) Bubble Sort, Selection Sort, Binary search, Linear search, nding the maximum element of a sorted array, nding the maximum element of an unsorted array. Answer: C

5. Consider OddCounter, a Counter-like ADT which counts only odd numbers (that is, 1, 3, 5, 7, . . . ). The axiom describing its unique behavior, assuming get(new()) = 1, is: a) get(inc(c)) = get(c) + 2. b) get(inc(c)) = get(c) - 2. c) get(inc(c)) = 2 get(c) + 1. d) get(inc(c)) = 2 get(c) 1 Answer: A

También podría gustarte