1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ilya [14]
3 years ago
7

Using the programming language of your choice, implement the Binary Search algorithm for a target value = 9 on the Array A: [9,

11, 70, 25, 20, 0, 36, 24]. What is the primary condition to implement a Binary Search Algorithm? Explain the growth rate of the algorithm
Computers and Technology
1 answer:
Alex73 [517]3 years ago
3 0

Answer:

myArray  = [9, 11, 70, 25, 20, 0, 36, 24]

myvalue = 20

def binary_search(mylist, value):

   sorted(mylist)  

   mid = mylist[round(len(mylist) / 2)]

   if value == mid:

       return mylist.index(mid)

   elif value < mid:

       for index, s_one in enumerate(mylist[ : (mylist.index(mid))]):

           if s_one == value:

               return index

   elif value < mid:

       for index, s_two in enumerate(mylist[(mylist.index(mid)) : ]):

           if s_two == value:

               return index

   else:

       return "searched value not in list/array"

result = binary_search( myArray, myvalue)

print(f"Index of the searched value {myvalue} is: {result}")

Explanation:

The programming language used above is python. It is used to implement a binary search in a list and finally returns the index of the searched value.

You might be interested in
If you write a toString method to display the contents of an object, object1, for a class, Class1, then the following two statem
kolezko [41]

Answer:

True

Explanation:

The two println methods are equivalent.

7 0
3 years ago
What did you include in your response? Check all that
tiny-mole [99]

Answer: it is 2 and 3 are the right answer's To the question i believe

4 0
3 years ago
A final class can't be extended.<br><br> *True<br><br> *False
postnew [5]

Answer:

The answer is True.

Explanation:

The final class cannot be extended because in java final keyword means "no modification". If it is applied to a variable or anything else then that value becomes a constant after that it cannot be modified.So in cases of class if final keyword is used it means that class cannot be extended.

8 0
3 years ago
The InfoBar is located below the ribbon and on top of a message. It is used for which purposes? Check all that apply. showing th
igor_vitrenko [27]

Answer:

showing the date and time of your response

displaying attachments

providing notice of a meeting request and response

indicating level of importance for the message

showing whether the message has been flagged

Explanation:

edg2021 said so

6 0
3 years ago
Read 2 more answers
There are how many GPS satellites orbiting the earth
exis [7]
The baseline satellite<span> constellation consists of 24 </span>satellites<span> positioned in six </span>earth-centered orbital planes with four operation satellites<span> and a spare </span>satellite<span> slot in each orbital plane.</span>
5 0
3 years ago
Other questions:
  • Luke is setting up a wireless network at home and is adding several devices to the network. During the setup of his printer, whi
    8·1 answer
  • What two different types of encryption can be used by ipsec during data transfer?​?
    5·1 answer
  • What kind of security features does Microsoft Security Analyzer promise?
    5·1 answer
  • What are the file sharing copyright laws in your area? Are they more strict or less strict than those in other areas of the worl
    9·1 answer
  • 19. Fair use applies to which of the following situations?
    14·1 answer
  • The process of preparing and setting up a software on a computer is called​
    15·1 answer
  • What are possible penalties if a designer is caught breaking copyright laws?
    13·1 answer
  • Computer science practical on VB.NET. program 1. program to find the square of a number. write the code achieve it​
    6·1 answer
  • Plz help
    5·1 answer
  • Answer pls pls pls pls ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!