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
Type the correct answer in the box. Spell the word correctly.
Liono4ka [1.6K]

Translators convert code written in a high-level language to the machine language.

4 0
3 years ago
Read 2 more answers
My mom works from home selling her craft work online to people all over the world. She can do this from home because we have acc
8_murik_8 [283]
I would go with A) The Internet 


I hope that turns out well for you. Good luck! (:
6 0
3 years ago
Can someone please help i have no idea what’s going on in this code
Valentin [98]

Explanation:

The first 3 lines of code tell the user to input a 5 digit number (ex. 72,910) or a 1 digit number (ex. 3). The next 5 lines of code determine if it is a 5/1 digit number or not. If it is, it prints "Success!". The rest of the code just tells that if it's not a 5/1 digit number, and if it's not, it gives errors and tells the user to try again.

Hope this helps!

3 0
3 years ago
Given the following list of numbers, explain how a linear search would be conducted
Ray Of Light [21]

Given the way computers go about completing a linear search for an array of numbers, we can confirm that it would take about six steps to complete the search.

<h3>How do computers perform a linear search?</h3>

When given an array of numbers to search through the linear search method, the computer will follow a logical approach. It will begin at the leftmost number, in this case, the number 7, and then compare each number in the array to the number 52, one by one. When the number finally matches the parameter it is searching for, it will return the answer.

Since in this series of numbers, 52 is the fifth number, the computer will go through the 5 initial steps of comparing each number, and then complete the search with the sixth step which would be returning the index of 52.

Therefore, we can confirm that it would take about six steps for the computer to complete the search using a linear search.

To learn more about linear searches visit:

brainly.com/question/15178888?referrer=searchResults

4 0
2 years ago
does anyone know how to access restricted websites by securly? im not trying to access anything weird they literally blocked spo
Aleksandr [31]

Answer:

Unblock websites using a VPN. Using a VPN is the easiest and most reliable way to get around content blocks and unlock the URL you want. …

Unblock websites using Tor. …

Unblock websites using a web proxy. …

Unblock websites using a proxy extension.

Explanation:

Have you tried those? Otherwise the next thing is to log in and unblock it, but you dont have the log in....

7 0
2 years ago
Other questions:
  • Elena is used to kissing her friends on both cheeks as a form of greeting in her native country. She notices that her new friend
    6·1 answer
  • What is Least effective at preventing a computer virus
    10·1 answer
  • HURRY UP NEED HELP!!! What are examples of curricular education? Check all that apply.
    9·2 answers
  • What is virtual reality?
    10·1 answer
  • Which of the following is not a location where text can be entered​
    15·1 answer
  • When writing code, how can printing be useful?
    15·1 answer
  • Refer to the image on the right. Then, using the drop-down menu, identify the correct printer type. A: inexpensive home printer
    10·1 answer
  • What software application is most appropriate to use to create multimedia presentations?
    6·2 answers
  • A network device that is used to connect multiple devices together without segmenting a network is a __________.
    10·1 answer
  • Ask the user for five-coordinate pairs. Store each pair as a tuple, and store all the pairs in a list. Print the slope between a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!