COMPUTER SCIENCE AND ENGINEERING
ALGORITHMS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
1
|
|
2
|
|
3
|
|
4
|
Detailed explanation-1: -This means that as the number of values in a dataset increases, the performance time of the algorithm (the number of comparisons) increases as a function of the base-2 logarithm of the number of values. Example: Binary searching a list of 64 elements takes at MOST log2(64) = 6 comparisons to complete.
Detailed explanation-2: -T F The maximum number of comparisons performed by the linear search on an. array of N elements is N/2 (assuming the search values are consistently found).
Detailed explanation-3: -At the most, linear search algorithm takes n comparisons. In terms of implementation, linear search algorithm takes 2n+1 comparisons ( n to check if target element is found and n+1 comparisons to check if end of list is reached) in the worst case.
Detailed explanation-4: -Time complexity for linear search is denoted by O(n) as every element in the array is compared only once. In linear search, best-case complexity is O(1) where the element is found at the first index. Worst-case complexity is O(n) where the element is found at the last index or element is not present in the array.