Computers and Technology

Write a program to find a peak in an array of ints. Suppose the array is {-1, 0, 2, 5, 6, 8, 7}. The output should be "A peak is at array index 5 and the value is 8." This is because the value 8 is larger than its predecessor 6 and its successor 7 in the given array. Note that 8 occurs at index 5. (The array starts at index 0.) A number at index i in an array X is considered a peak if: X[i]>=X[i-1] and X[i]>=X[i+1]. If i is at the beginning of the array, then peak is if X[i]>=X[i+1]. If i is at end of array, then peak is if X[i]>=X[i-1].

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 25.06.2019 00:30, aleiahmartin
Which email writing etiquette should ariel follow to let people know that she received their message? a. reply to their messages immediately b. use formal language c. specify the email's intent in the subject field d. be direct when writing the reply
Answers: 1
image
Computers and Technology, 25.06.2019 15:00, jayzeptor
Need answer asap jesse would like to modify the table that he has inserted into a word document by making the first row a single header cell. which action should jesse do? 1. merge 2. split 3. resize 4. none of the above
Answers: 2
image
Computers and Technology, 25.06.2019 18:00, Vells2246
Peter wants to query to determine the names of the students who scored more than 95 in the internal assessment test
Answers: 2
image
Computers and Technology, 25.06.2019 19:00, bryceisabeast6206
Assume you're running a query on your orders in the past year. you want to see how many orders were placed after may. what type of query would you use to find this data? a. select b. range c. complex d. parameter
Answers: 1
Do you know the correct answer?
Write a program to find a peak in an array of ints. Suppose the array is {-1, 0, 2, 5, 6, 8, 7}. The...

Questions in other subjects:

Konu
Chemistry, 19.03.2021 01:00