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
Identify the causes of configuration problems. (choose all that apply)
jolli1 [7]

Answer: The computer does not meet minimum requirements of the software program because too much energy gets put in it

Explanation:

Good luck

4 0
3 years ago
Read 2 more answers
Router 1 is configured with static NAT. Addressing on the router and the web server are correctly configured, but there is no co
marin [14]

Answer:

The router NAT configuration has an incorrect inside local address.

Explanation:

The term Inside in a <em>Network Address Translation (NAT) </em>context refers to networks owned by an organisation that must be translated. When NAT is configured, hosts within this network have addresses in one space (known as the local address space). These hosts appear to those users outside the network as being in another space (known as the global address space).

The term Outside refers to those networks to which the stub network connects, and which are not under the control of an organisation. Also, hosts in outside networks can be subject to translation, and can thus have local and global addresses

7 0
2 years ago
What is computer and its features<br>​
dlinn [17]

Answer:

A computer is a machine that can be programmed to manipulate symbols.

Explanation:

Following are the features of PC (computer)

Processor  

speed  

reliability  

accuracy  

automation  

diligence  

consistency    

Random access memory (RAM)  

Operating system  

Graphics adapter and video RAM  

Monitor

3 0
3 years ago
Read 2 more answers
What term describes the process of transferring information from one computer to another
Flauer [41]

Syncing or maybe FTP or connection

5 0
3 years ago
Which of the following are pointers? Select all that are correct. hub node router transmission media switch port interconnector
Sphinxa [80]
Hub , switch port , transmission media , hope I helped
4 0
3 years ago
Read 2 more answers
Other questions:
  • Jason wants to open a program with the command prompt window. Which command should he type in the Run dialog box to open the com
    10·1 answer
  • Which of the following is a template definition?
    5·1 answer
  • You work in a customer call center. Martin is on the phone asking about the difference between solid-state drives (SSDs), hybrid
    6·1 answer
  • According to Holpp and Kelly's approaches to developing vision, the benchmarking approach is more internally focused, whereas th
    6·1 answer
  • Basic rule for java languague
    13·2 answers
  • Describe some ways that you personally use information technologies differently than you did just a few years ago
    11·1 answer
  • Managers looking for advice on properly dealing with obsolete technology hardware can: a) consult the e-Stewards program b) seek
    9·1 answer
  • Alexandria works for a non-profit company that asks for donations to help the homeless people in her community. Recently the dat
    12·1 answer
  • Match the job task to the occupation that would perform it. 1. Research the causes and treatments of diseases physical scientist
    7·1 answer
  • What are benefits of AI
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!