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
Zoom meeting ID:987 6858 5587 Password:196133
Llana [10]
I might join I’m not sure tho is there gonna be a lot of ppl?
3 0
3 years ago
Read 2 more answers
_____ refers to displaying information for the user's view.
Fantom [35]
It is A outputting (if you want I can show what it says in the dictionary)
7 0
3 years ago
Read 2 more answers
Some files appear dimmed in one of the default folders on your computer. What would be the best course of action? A. Leave the f
Zielflug [23.3K]
If some files appear dimmed in one of the default folders on your computer, the best course of action would be to A. leave the files as they are.
These files are probably either hidden or system files, which are never meant to be deleted or moved.
8 0
3 years ago
Your unit has an upcoming training event. What form is used to record and maintain document numbers for ammunition documents?
aleksklad [387]

Ammunition documents which caries bullet, fuses extra should be numbered properly.

<u>Explanation:</u>

A document number or page number should be well organized and he or she coordinates with assistant trainers who have involved it.

Since it is a training event. The trainer has to have a checklist and make as fill with page number and make sure page numbers are strictly followed during the training session. If any page number is misplaced through the training session it will be embracing the situation for trainer and student or staff who get the training.

8 0
3 years ago
25 POINTS!! NEED HELP ASAP!! Which of the following can be a problem for people with certain kinds of epilepsy?
olga_2 [115]
There is your answer:
Flashing images
5 0
2 years ago
Other questions:
  • You want to register the domain name ABCcompany.org, but the registration service is not allowing you to do that. What's the mos
    10·1 answer
  • c++ design a class named myinteger which models integers. interesting properties of the value can be determined. include these m
    14·1 answer
  • Jason is computer professional who has access to sensitive information. He shares this information with another organization in
    8·1 answer
  • In addition to training on the products and on company policy, it does not make sense to be prepared to speak about your company
    6·2 answers
  • What is a sign of the brick and mortar and the virtual world meeting together?
    14·1 answer
  • This project is to mimic a meeting request system by checking the requesting party’s validity, and the number of people attendin
    15·1 answer
  • Which of the following that can be use to access session variables in PHP?
    14·1 answer
  • Which expression is equivalent to 3x + 3x + 3x?<br><br> From Performance Matters
    11·2 answers
  • Each bolt diameter in the standard system can have one of two thread pitches, or UNE.​
    10·1 answer
  • Area Triangolo Rettangolo in c++
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!