COMPUTER SCIENCE AND ENGINEERING
ALGORITHMS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Line 01 becomes target <-list[2]
|
|
Line 04 becomes IF (num < target)
|
|
Line 04 becomes if (num <= target)
|
|
Line 01 becomes list[0] <-target
|
Detailed explanation-1: -Expert-Verified Answer. All the numbers in the list are arranged in the ascending order such that the smallest number comes at the beginning and so on. Now, the number which occur at the last is the required largest number.
Detailed explanation-2: -We are given an integer array of size N or we can say number of elements is equal to N. We have to find the largest/ maximum element in an array. The time complexity to solve this is linear O(N) and space compexity is O(1).
Detailed explanation-3: -The kth largest element can be found with the help of the heap. Here, we have used max heap; we first convert the given array into a max-heap first, then replace the root with the last element, decrease the heap size by one and then convert it into a max-heap again. We follow the same steps k-1 times.
Detailed explanation-4: -log(max); var min = numbers. reduce((total, value, index, array) => if(index === 0) return array[0]; return total < value ? total : value; ); console. log(min);