If you have an array of 100 sorted elements, and you search for a value that does not exist in the array using a binary search, approximately how many comparisons will have to be done?
a)7


b)100


c)50

Answers

Answer 1

Answer:

50

Explanation:

as binary search will search the array by dividing it into two halves till it find the value.


Related Questions

In this exercise, you will get some practice with the __add__ method by implementing it for a class called ContactBook. This class represents a collection of names and phone numbers. ContactBook stores its information as a dictionary, where the key is a name and the value is a phone number or group of phone numbers. The keys and values in this dictionary are stored as strings. When printed, a ContactBook might look like this:

Answers

Answer:

class ContactBook():

   def __init__(self):

       self.contacts ={}

   def __repr__(self):

       return str(self.contacts)

   def add_contact(self,name,number):

       self.contacts[name] = number

   def __add__(self, other):

       new_contact = ContactBook()

       other_contact = other.contacts.keys()

       for name,num in self.contacts.items():

           if name in other_contact:

               new_contact.add_contact(name,num or other_contact[name])

           else:

               new_contact.add_contact(name,num)

       for name,num in other.contacts.items():

           if name not in self.contacts:

               new_contact.add_contact(name, num)

       return new_contact-

cb1 = ContactBook()

cb2 = ContactBook()

cb1.add_contact('Jonathan','444-555-6666')

cb1.add_contact('Puneet','333-555-7777')

cb2.add_contact('Jonathan','222-555-8888')

cb2.add_contact('Lisa','111-555-9999')

print(cb1)

print(cb2)

cb3 = cb1+cb2

print(cb3)

Explanation:

The ContactBook class holds the contact details of an instance of the class. The class has three magic methods the '__repr__', '__init__', and the '__add__' which is the focus of the code. The add magic method in the class adds the contact book (dictionary) of two added object instance and returns a new class with the contact details of both operand instances which is denoted as self and other.

You have booted a new computer (purchased from a manufacture) to PowerShell prior to the computer starting the Out-of-Box Experience. From PowerShell, you run the Set-ExecutionPolicy Unrestricted cmdlet. What is the function of this cmdlet?

Answers

Answer:

It allows Windows to run script files.

Explanation:

A cmdlet is an abbreviation for command-let and it is a special type of lightweight command that is typically used with the Microsoft Windows PowerShell script for the automatic performance of a single-specific function on a computer system.

In this scenario, you have booted a new computer (purchased from a manufacture) to PowerShell prior to the computer starting the Out-of-Box Experience. From PowerShell, you run the Set-ExecutionPolicy Unrestricted cmdlet. Thus, the function of this cmdlet is to allow Windows run script files known as scripts which have been typed into the command line.

Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies.
If input is 0 or less, output is 'No Change'
For Example: Input: 45
Output:
1 Quarter
2 Dimes
input_val = int(input())
if input_val <= 0:
print('No change')
else:
num_dollars == input_val // 100
input_val %= 100
num_quarters == input_val // 25
input_val %= 25
num_dimes == input_val // 10
input_val %= 10
num_nickels == input_val // 5
input_val %= 5
num_pennies == input_val
if num_dollars > 1:
print('%d dollars' % num_dollars)
elif num_dollars ==1:
print('%d dollar' % num_dollars)
if num_quarters > 1:
print('%d quarters' % num_quarters)
elif num_quarters ==1:
print('%d quarter' % num_quarters)
if num_dimes >1:
print('%d dimes' % num_dimes)
elif num_dimes ==1:
print('%d dime' % num_dimes)
if num_nickels >1:
print('%d nickels' % num_nickels)
elif num_nickels ==1:
print('%d nickel' % num_nickels)
if num_pennies >1:
print('%d pennies' % num_pennies)
elif num_pennies ==1:
print('%d penny' % num_pennies)

Answers

Answer:

b ,/knlk

Explanation:

Question # 2 Multiple Choice The _____ method returns an integer between the two provided numbers. It can take the value of either of the provided numbers. seed randint random range

Answers

Answer:

randint

Explanation:

Answer:

randint

Explanation:

ed 2021

-(-13) P binary using signed. 2's complement representation
Perform the arithmetic operations (+42) + (-13) and (-42)
negative .
Consider the balloon​

Answers

Answer:

00011101

00011101

Explanation:

Given the following arithmetic operations

a)   (+42) + (-13)

b)   (-42) - (-13)

From (a):

We need to convert +42 into binary, so we get = 00101010

Now for +13, when it is converted into binary, we get = 00001101

But, here, the 13 is negative. So, here is what we will do, we will have to take the two compliment of the binary. After doing that, we get = 111110011

+ 42     →     00101010

- 13      →     1 1 1 10011

+29             000 11101  

Thus, the arithmetic operation after we use 2's complement is 00011101

b)

Here both 42 and 13 are negative. Using two complement representation

-42 is first converted to binary as 00101010, Then → 11010101 + 1 = 11010110

-13 is converted to binary as 00001101 → 11110010 = 11110011

In between, a negative sign exists, so we take another 2's complement.

i.e.

11110011 → 00001100 + 1 = 00001101

- 42 →     1 1 01 0110

+13  →     00001 101

-29         1 1 1 00011

since there is no carry, we take two's complements for the result as:

1 1 1 00011 →00011100 + 1 = 00011101

Consider the following method, which is intended to return an array of integers that contains the elements of the parameter arr arranged in reverse order. For example array containing (-5, 3, 2, 7) then a new array (-5, 3, 2, 7) contains should be returned and the parameter are should be left unchanged .

public static int[] reverse(int) arr)
Intl new new intarr.length);
for (int k = 0; K arr.length: )
* Bissing statement / return newer;

Write down the statements that can be used to replace / Missing statement so that the method works as intended?

Answers

Code:

public static int[] reverse(int [] arr){

Int [] newArr = new int[arr.length];

for (int k = 0; k<arr.length;k++){

/*Missing statement */

}

return newArr;

Answer:

Replace the comment with:

newArr[k] = arr[arr.length-k];

Explanation:

Required

Complete the code

In the given code:

The first line of the given code defines the method

public static int[] reverse(int [] arr){

The next line declares array newArr withe same length as array arr

Int [] newArr = new int[arr.length];

The next line iterates through the elements of array arr

for (int k = 0; k<arr.length;k++){

The /* Missing statement */ is then replaced with:

newArr[k] = arr[arr.length-k];

The above statement gets the elements of array arr in reversed order.

This is so because, as the iteration iterates through array arr in ascending order, arr.length-k gets the element in reversed order

Write a program using python 3 that asks the user how many integers they would like to enter. You can assume that this initial input will be an integer >= 1. The program will then prompt the user to enter that many integers. After all the numbers have been entered, the program should display the largest and smallest of those numbers (no, you cannot use lists but you can use loops, if statements, comparison & logical operators). Your code should work correctly no matter what integers the user enters. When you run your program it should match the following format:

How many integers would you like to enter?
4
Please enter 4 integers.
-4
105
2
-7
min: -7
max: 105

Answers

I've included my code in the picture below. Best of luck.

Other Questions
Why did the Catholic Church send people to the Americas?Mark this and returnSave and ExitNextPrevious Activity What is the value of x A car accelerates uniformly from rest and reaches a speed of 9.9 m/s in 11.4 s. The diameter of a tire is 86.9 cm. Find the number of revolutions the tire makes during this motion, assuming no slipping. Answer in units of rev. Which sentence from the passage supports theinference that some scientists have challengedNewton's universal theory of gravity?O 1. "Nearly three centuries would pass before theworld would host a comparable scientificgenius." (Paragraph 1)2. "Newton's view of gravity might be called thegreat equalizer." (Paragraph 3)3. "Regardless of physical composition, everythingexerts as well as feels the force of gravity."(Paragraph 3)4. "This success gave Newton's theory unequivocalsupport until the early part of the twentiethcentury." (Paragraph 4) Does acid rain make new substances? Construct an argument that uses data from this investigation as evidence for your claim. 1.2.Prove the following the trigonometric identity step-by-step1.2.1 sin theta/sin theta+cos theta=tan theta/1+tan theta 4At what trophic level do decomposers obtain their energy? Which sentence from the passage has an example of personification? Germany and Britain were competing for the best Navy. Britain builds "The Dreadnought battleship, and Germany answers by building one as well. + Militarism O Alliances o Imperialism O Nationalism (please help) Write your opinion of the following foods. Use correct forms of the following adjectives in your sentences. Select the correct text in the passage.Which word provides the best context clue for the meaning of the word immeasurable?The impact of a kind gesture is immeasurable. Even a single smile can have an endless effect. A won a race at the local fair by running 10.5 miles in exactly 2 hours. At this constant rate, how long does it take the same dog to run the 21 mile state fair race? Use ratio reasoning to solve. * 1 point Doug had a total of $75 to buy 3 pictures for his room. He paid the same amount for each picture and had $27 left over. How much money did Doug pay for eachpicture? I NEED HELP PLZThe setting of a story can have a tremendous impact on the plot. Describe one way that a storys setting can affect the events of a story. Provide an example. 34. 40% of the students in a class like apples for breakfast. If 20 students like apples, how many students are in the class? There are 946 milliliters in a quart. There are 2 pints in a quartHow many milliliters are in a pint? Given that D( x ) = 2 x , select all of the following that are true statements. D( x ) is a direct variation. D( x ) is a function. D( x ) is a rule for the set of points (5, 10), (6, 12) and (-2, -4).x is the dependent variable.D(6) = 3 Someone you look up to? And why? How did the industrial revolution help countries build vast empires? Write a ratio and a percent for the shaded area. 3/10, 27%1/2, 50%1/3, 33.33%3/10, 30%PLEASE HELP ME IVE BEEN STUCK BECAUSE I THOUGHT THAT 12/60 WAS 1/5 SIMPLIFIED??