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
Mazyrski [523]
3 years ago
13

The find_item functions uses binary search to recursively locate an item is the list, returning true if found, false otherwise.

Something is missing from this function. Can you spot what it is and fix it. Add debug lines where appropriate, to help narrow the problem.
Computers and Technology
1 answer:
bagirrra123 [75]3 years ago
7 0

Answer:

def find_item(listed, item):

   listed.sort()

   #Returns True if the item is in the list, False if not.

   if len(listed) == 0:

       return False

   middle = int(len(listed)/2)

   #Is the item in the first half of the list?

   if item < listed[middle]:

   #Call the function with the first half of the list

       return find_item(listed[:middle], item)

   

   #Is the item in the center of the list?

   if listed[middle] == item:

       return True

   else:

   #Call the function with the second half of the list

       return find_item(listed[middle+1:], item)

   return False

list_of_names = ["Parker", "Drew", "Cameron", "Logan", "Alex", "Chris", "Terry", "Jamie", "Jordan", "Taylor"]

print(find_item(list_of_names, "Alex")) # True

print(find_item(list_of_names, "Andrew")) # False

print(find_item(list_of_names, "Drew")) # True

print(find_item(list_of_names, "Jared")) # False

Explanation:

The defined python function is used to implement a binary search, the function is recursively called in the function statement, but for it to work on the list ( ie, search for an item in the list), the list must be sorted in ascending order (default).

You might be interested in
Microsoft word is an example of utility software? <br><br>A.true <br>B.false​
monitta

Answer:

false

Explanation:

Ms word is only an application software

7 0
2 years ago
Read 2 more answers
Your employer's right to electronically monitor you is an issue of ____.
Cloud [144]

Answer: Employee privacy

Explanation:

 Employers can electronically monitor property, computer and electronic devices under the their rights in the organization but there is issue of employee privacy. As, employee has the right to privacy in the organization or workplace.

In some organization phones and email address are provided by the company so that they can electronically monitor the employee properly. In this case, some employee feel that monitoring is the violation of their personal  and privacy rights.

8 0
2 years ago
________ use statistics to anticipate customers withdrawals. ________ use statistic to calculate probable life expectancy to hel
Fudgin [204]

Answer:

Banks

Insurance companies

Explanation:

3 0
2 years ago
Why is it important to identify cables and conductors?​
nlexa [21]

Answer:

While we almost never get to see most of the cables, they power everything so it only makes sense that you should know what the different types of cables and wires are, so that you can pick accordingly and have your equipment, devices and appliances powered properly.

It is also important to identify cables and conductors for safety purposes, such as emergencies linked with electricity.

8 0
2 years ago
Computer that process digital as well as analogue signals​
Nuetrik [128]

Answer:

The answer is hybrid computer coz it is the combination of both analog and digital computers

Explanation:

hope it helps

good day

5 0
3 years ago
Other questions:
  • The function below takes a single parameter number_list which is a list that can contain integers and floats. Complete the funct
    9·1 answer
  • Data is: a. Information endowed with relevance and purpose b. Set of specific objective facts or observations c. Some informatio
    10·1 answer
  • when you create workplace documents, it is most important to ensure that they are clear, professional, and a. short. b. informal
    7·1 answer
  • 1. Why is it important to compare features of a computer before making a purchase?
    13·2 answers
  • Which player type focuses on level progression?
    13·1 answer
  • Markup is best defined as
    11·1 answer
  • When using correct ergonomic technique be sure to
    6·2 answers
  • The acceleration of a body is 3 metre per second square what does it mean​
    11·2 answers
  • What are the steps to creating a blank database? Use the drop-down menus to complete them.
    9·1 answer
  • Data stored on physical storage devices must do what before the processor can access it? Be converted to binary Be written to th
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!