subject

The binary search algorithm. an: increasing integers) procedure binary search (x: integer, a1,a2, i: = 1 {i is left endpoint of search interval } = n {j is right endpoint of search interval} while ij i#x > am then i : = m + 1 else j : = m if x = ai then location : = i else location : = 0 return location location is the subscript i of the term a equal to x, or 0ifx is not found) 26. change algorithm 3 so that the binary search procedure compares x toam at each stage of the algorithm, with the algorithm terminating if x = am, what advantage does this version of the algorithm have? 2. (20 points) exercise 26, p. 203. provide pseudocode and complexity for this algorithm. change algorithm 3, p. 195, so that the binary search procedure comparesr to am at each stage of the algorithm, with the algorithm terminating if am (a) write what an advantage has this version of the algorithm. (b) write a formula for a function which expresses the number of comparisons for the elements of a sorted sequence , an against the target z in the worst and the best cases. (c) classify the algorithm in the worst case using the big-o asymptotic notation.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:50
In this lab, you complete a prewritten c++ program for a carpenter who creates personalized house signs. the program is supposed to compute the price of any sign a customer orders, based on the following facts: the charge for all signs is a minimum of $35.00. the first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. if the sign is made of oak, add $20.00. no charge is added for pine. black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering. instructions ensure the file named housesign.cppis open in the code editor. you need to declare variables for the following, and initialize them where specified: a variable for the cost of the sign initialized to 0.00 (charge). a variable for the number of characters initialized to 8 (numchars). a variable for the color of the characters initialized to "gold" (color). a variable for the wood type initialized to "oak" (woodtype). write the rest of the program using assignment statements and ifstatements as appropriate. the output statements are written for you. execute the program by clicking the run button. your output should be: the charge for this sign is $82. this is the code, // housesign.cpp - this program calculates prices for custom made signs. #include #include using namespace std; int main() { // this is the work done in the housekeeping() function // declare and initialize variables here // charge for this sign // color of characters in sign // number of characters in sign // type of wood // this is the work done in the detailloop() function // write assignment and if statements here // this is the work done in the endofjob() function // output charge for this sign cout < < "the charge for this sign is $" < < charge < < endl; return(0); }
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Why would a programmer use the logical operator and in an if statement? a: when an action is to be taken that requires both conditions to be falseb: when an action is to be taken that requires both conditions to be truec: when an action is to be taken that requires the first condition to be falsed: when an action is to be taken that requires the second condition to be truei took the test and the answer is b.
Answers: 3
question
Computers and Technology, 22.06.2019 21:30
Elements such as fonts colors visual structure graphics and the interface of a web page should complement each other to ensure blank
Answers: 3
question
Computers and Technology, 23.06.2019 07:30
What is the original authority for copyright laws
Answers: 1
You know the right answer?
The binary search algorithm. an: increasing integers) procedure binary search (x: integer, a1,a2,...
Questions
question
Mathematics, 18.03.2021 02:20
question
Mathematics, 18.03.2021 02:20
question
Chemistry, 18.03.2021 02:20
question
English, 18.03.2021 02:20