subject

Alist of n distinct integers a_1, a_2, a_n is called a mountain list if the elements reading from left to right first increase and then decrease. the location of the peak is the value i where a_i is greatest. for example, the list 1, 2, 3, 7, 6 is a mountain list with a peak at 4. we also consider a list of increasing numbers to be a mountain list with a peak at n, and a list of decreasing numbers to be a mountain list with a peak at 1. give pseudocode for an algorithm based on linear search that takes as input a mountain list a_1, a_2, a_n and returns the location of the peak. show that your algorithm does no more than n - 1 comparisons on any input of size n. give an algorithm based on binary search that takes as input a mountain list a_1, a_2, a_n and returns the location of the peak. your algorithm should be able to find the peak in any list of size 16 with no more than 4 comparisons (in general, up to k comparisons for a list of size 2^k.) you should provide pseudocode and an english description of your algorithm, but you do not need to prove that it meets the requirements for the number of comparisons.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 02:30
How to apply the fly in effect to objects on a slide
Answers: 1
question
Computers and Technology, 24.06.2019 02:50
Be sure to answer all parts. synthesize the following compound from benzene. a. b. c. d. e. f. reaction [1] conditions: a b c d e f reaction [1] product: draw structure reaction [2] conditions: a b c d e f reaction [2] product: draw structure reaction [3] conditions: a b c d e f reaction [3] product:
Answers: 3
question
Computers and Technology, 24.06.2019 07:30
John recently worked on a project about various programming languages. he learned that though procedural language programs are useful, they have disadvantages too. what is a disadvantage of programs written in procedural languages? a. programs do not represent data complexity. b. programs take more time to execute. c. programs are prone to security threats. d. programs do not interface with multiple platforms.
Answers: 3
question
Computers and Technology, 24.06.2019 10:00
(, urgent need): how do i change my username
Answers: 1
You know the right answer?
Alist of n distinct integers a_1, a_2, a_n is called a mountain list if the elements reading from l...
Questions
question
SAT, 01.04.2021 19:10
question
Mathematics, 01.04.2021 19:10
question
Mathematics, 01.04.2021 19:10
question
Mathematics, 01.04.2021 19:10
question
Engineering, 01.04.2021 19:10
Questions on the website: 13722362