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, 22.06.2019 09:50
17. implement the jvm dload instruction for the mic-2. it has a 1-byte index and pushes the local variable at this position onto the stack. then it pushes the next higher word onto the stack as well
Answers: 2
question
Computers and Technology, 23.06.2019 03:10
Acomputer has a two-level cache. suppose that 60% of the memory references hit on the first level cache, 35% hit on the second level, and 5% miss. the access times are 5 nsec, 15 nsec, and 60 nsec, respectively, where the times for the level 2 cache and memory start counting at the moment it is known that they are needed (e.g., a level 2 cache access does not even start until the level 1 cache miss occurs). what is the average access time?
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Write a function called checkfactor that takes two arrays of positive numbers, firstnumberrow and secondnumberrow. checkfactor checks if the first entry in firstnumberrow is divisible by the first entry in secondnumberrow, and performs the same operation on the next array elements until all entries have been checked. all the numbers are positive and the number of entries in the arrays are the same. the function should return the identified divisible numbers in two row arrays named firstdivisible and seconddivisible.restrictions: branches or loops should not be used. the code must use the internal mod and logical functions.hint: the mod function should be used to determine if two numbers are divisible. ex: for num1 and num2 if mod(num1,num2) is 0, then the two numbers are divisible.this is matlab
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Jace needs to answer a question on square roots to win a quiz. how can he use a spreadsheet to find the square root of 786? a. use the functions round and count b. create a table and chart c. use the function sqrt d. use the function now
Answers: 3
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
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
French, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Biology, 18.09.2020 15:01
question
English, 18.09.2020 15:01
question
English, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Spanish, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Geography, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
question
Mathematics, 18.09.2020 15:01
Questions on the website: 13722360