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 08:10
Ihave a music player on my phone. i can buy songs, add them to playlists and play them. obviously it would be redundant to store each song in each playlist; each playlist is just a list of pointers to the songs. for this lab you will simulate this behavior. your program will need to have options to: add songs to the system library (you will store the text of the first line of the song, rather than the audio) add playlists add songs to a playlist list playlists play a playlist list all of the songs in the library with a count of how many times each song has been played remove a song from a playlist remove a playlist remove a song from the library (and thus from all playlists that contain it) note that we will not be checking many error cases. in real programming this would be bad, you should usually try to recognize and respond to as many types of errors as you can. in the context of class we are trying to acquaint you with as many concepts as possible, so for the sake of educational efficiency we will not be checking most errors in this lab, you may assume that your user provides correct input. you may add all appropriate error testing if you wish, but we will not be testing for it.
Answers: 2
question
Computers and Technology, 22.06.2019 10:00
You need a reliable network for about twenty-five computers that will be distributed across a large building. it is important that the network be relatively cheap. which topology should you use?
Answers: 1
question
Computers and Technology, 22.06.2019 14:20
Cengagenowv2 is a comprehensive online learning tool. using cengagenowv2, you may access all of the following except: 2. each time you log in, cengagenowv2 automatically performs a system check and informs you if your computer does not meet the cengagenowv2 system requirements. 3. which tab/page allows you to easily track your assignment scores, number of submissions, time spent, as well as the ability view assign
Answers: 3
question
Computers and Technology, 22.06.2019 14:20
Consider a byte-addressable computer with 16mb of main memory, a cache capable of storing a total of 64kb of data and block size of 32 bytes. (a) how many bits in the memory address? (b) how many blocks are in the cache? (c) specify the format of the memory address, including names and sizes, when the cache is: 1. direct-mapped 2. 4-way set associative 3. fully associative
Answers: 2
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
English, 22.06.2019 05:50
question
Biology, 22.06.2019 05:50
Questions on the website: 13722361