Question: 3. (4 points) Consider the following algorithm to find the largest number in a given non-empty array, a, of size N. Give the exact,
3. (4 points) Consider the following algorithm to find the largest number in a given non-empty array, a, of size N. Give the exact, worst-case running time in terms of N, and the corresponding big-Theta value. Note: in this case, we are counting the times we make a comparison less than, greater then, or equals) using at least one array element, so specifically the condition in the if statement. int max = a[0]; for (int k = 1; k max) { max = a[k]; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
