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
A web application that is designed as a single piece of software with multiple features that are fully integrated into the main
Nookie1986 [14]

Answer:

c. Service oriented architecture (SOA)

Explanation:

In a service oriented architecture (SOA), a component of an application provides services to other components of the application or other applications majorly via a communications protocol over a network. In other words, SOA is a programming or software development technique in which services communicate with each other across different platforms.  

One key principle of SOA is to design an application (which in itself is a piece of software with multiple features) that is independent of any product, service, vendor or technology but can be integrated into other applications. SOA makes use of loose coupling -  a technique in which a client service remains independent of another service that requires it.

In contrast, a monolithic architecture aims at developing a software that is self-contained, independent and not to be integrated into other applications.

On another hand, Software as a service (SaaS), though a bit similar to SOA, is a model in which an application is made available to customers basically through a network. Users basically access the application via a browser.

Therefore, the best option is

C. Service oriented architecture.

3 0
3 years ago
If background option when creating file. the color of the background is
DaniilM [7]

Answer:

Light Grey.

Explanation:

I guess because mostly I have seen document background colour is Grey.

7 0
3 years ago
Read 2 more answers
In c++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value.
sergiy2304 [10]
<span>In describing an Initialization is when a value is assigned to a variable as part of the variable's definition or the assinged values to variables are defined whenever. 

The best answer would be is that they present the keyword,  when they tell the compiler.</span>
3 0
4 years ago
Internet Security: How can you work securely on the internet? What actions should be avoided and what are the pitfalls?
Cerrena [4.2K]

Answer:First of all, to work safely at the internet you should avoid any not secure page, and if you can’t do that, avoid entering stuff such as credit cards or passwords on this sites. Now, to work safely it’s recomendable to have a VPN(virtual private network), that hides your IP direction.

Explanation:

8 0
3 years ago
Which of the following is a benefit of using technology? a. It increases the number of human service providers in firms. b. It i
o-na [289]

Answer:

The correct option to the following question is b.) It increases quality and productivity of firms .

Explanation:

Advantages of using technology in the business:

  • It increased the quality and the productivity of the firm or business.
  • Automated the business processes with the help of an application and software.
  • It reduced the business cost by having few workers at the workplace and,
  • also increased the mobility of the firm.
  • It helps in effective communication.
6 0
4 years ago
Other questions:
  • When computers connect to one another to share information, but are not dependent on each other to work, they are connected thro
    7·1 answer
  • Using the CPI to calculate the inflation rate​ _______________ the underlying inflation​ rate, and using the core inflation rate
    7·2 answers
  • What do you need for digital photography?
    14·1 answer
  • Answer to this if you have apex legends on either pc xbox one or PS4 for the one that answers and does gets brainliest please do
    7·2 answers
  • . What type of device is a computer? Where does it use?​
    14·1 answer
  • Which role involves designing and creating advertisements for marketing purposes?
    14·1 answer
  • Why does a computer need programs? ​
    8·2 answers
  • Which work habits should you follow to increase work efficiency and avoid health issues?
    6·1 answer
  • What is a computer? ​
    13·2 answers
  • When you're writing for mobile devices, use ________ to present the most important information first and provide successive laye
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!