Question 7. Describe an algorithm using pseudocode that takes in an array of N integers and returns the index of a local
Posted: Thu Jul 14, 2022 2:06 pm
need solution
Question 7. Describe an algorithm using pseudocode that takes in an array of N integers and returns the index of a local maximum. A local maximum is an element that is greater than or equal to (all) its immediate neighbor(s). Note that a local maximum may be at one end of the array, which would mean it only has to be greater than or equal to one neighbor. (Hint: Use a variation of binary search.) Example: {0,1,2,3,4,5,6,5,4,3,2,1,2} Both 6 (at index 6) and 2 (at index 12) are local maximums. Returning either one of these would be correct.
Question 7. Describe an algorithm using pseudocode that takes in an array of N integers and returns the index of a local maximum. A local maximum is an element that is greater than or equal to (all) its immediate neighbor(s). Note that a local maximum may be at one end of the array, which would mean it only has to be greater than or equal to one neighbor. (Hint: Use a variation of binary search.) Example: {0,1,2,3,4,5,6,5,4,3,2,1,2} Both 6 (at index 6) and 2 (at index 12) are local maximums. Returning either one of these would be correct.