1. Finding the greatest number from the given n number of elements in an array.
2. For this, we will be having an array and we need to traverse through the whole array and thus find the maximum value out of the whole array.
3. Key assumption is that the numbers could be of any value applicable for integers and the array size would not be so big that it is not possible to calculate in a reasonable time.
4. For this, we need to traverse through the whole array linearly and thus keep track of the element which is maximum and thus at the last we will be having the element of maximum value. This would take O(n) time complexity to find.
5. The solution for the above problem is to linearly traverse the array and keep track of the current maximum value and while traversing if any element of greater value is found, we need to replace it will the current maximum value, Thus in this way we are keeping track of all the values without missing any value thus it is the correct solution.
max_element(a)
cur_max = 0
for I in a:
if I>cur_max:
cur_max = I
return cur_max
Thanks
Describe an algorithm for finding the maximum (Large) value infinite sequence of integer 1.1 /10 points:...