subject

For this problem, we want to implement a binary search algorithm. In computer science, a binary search or half-interval search algorithm finds the position of a specified input value (the search "key") within a list sorted by key value. In each step, the algorithm compares the search key value with the key value of the middle element of the list. If the keys match, then a matching element has been found and its index, or position, is returned. Otherwise, if the search key is less than the middle element’s key, then the algorithm repeats its action on the sublist to the left of the middle element or, if the search key is greater, on the sublist to the right. If the remaining list to be searched is empty, then the key cannot be found in the list and a special "not found" indication is returned. A binary search halves the number of items to check with each iteration, so locating an item (or determining its absence) takes logarithmic time. A binary search is a dichotomic divide and conquer search algorithm. Develop a function called binary search that accepts two parameters, a sorted list of numbers and a number to search for. The function should implement the binary search Page 3 Exam 2 IENG 331 - Spring 20 algorithm. If the requested value is found in the provided list, its index should be returned, otherwise, a ValueError should be raised.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:50
Consider a slotted aloha system, where the time slot equals the fixed duration of each packet. assume that there are 4 stations a,b,c,d sharing the medium. (a) stations a,b,c,d receive one packet each from higher layers at times 1.3, 1.5, 2.6,5.7 respectively. show which transmissions take place when, according to the slottedaloha protocol; describe all transmissions until all four packets have been successful.when needed, each station has access to the following sequence of random number, provided by a random number generator and drawn uniformly between 0 and 1: (1) station a draws numbers: 0.31, 0.27, 0.78, 0.9, 0.9, 0.11, 0. (2) station b draws numbers: 0.45, 0.28, 0.11, 0.83, 0.37, 0.22, 0. (3)station c draws numbers: 0.1, 0.2, 0.3, 0.4, 0. (4) station d draws numbers: 0.36, 0.77, 0.9, 0.1, 0.1, 0.1, 0.1, 0. (b) in slotted aloha, a station transmits in each time slot with a given probability. what probabilities would you assign to each of the four stations so as to: (i) maximize the efficiency of the protocol? (ii) maximize fairness among the four stations? (c) will the efficiency increase or decrease if we modify slotted aloha as follows: (i) get rid of slots and allow stations to transmit immediately? (ii) implement carrier sensing? (iii) implement collision detection? (iv) implement collision avoidance?
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
What is the term for water wave that is created by an underwater earthquake
Answers: 1
question
Computers and Technology, 23.06.2019 15:20
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
question
Computers and Technology, 24.06.2019 10:10
Which view in a presentation program displays a split window showing the slide in the upper half and a blank space in the lower half?
Answers: 1
You know the right answer?
For this problem, we want to implement a binary search algorithm. In computer science, a binary sear...
Questions
question
History, 29.11.2020 09:10
question
Chemistry, 29.11.2020 09:10
question
Mathematics, 29.11.2020 09:10
question
Mathematics, 29.11.2020 09:10
question
Mathematics, 29.11.2020 09:10