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

Answers

Answer 1

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.


Related Questions

An important communication principle states ""prepare before you communicate."" How should this preparation manifest itself in the early work that you do? What work products might result as a consequence of early preparation?

Answers

Answer:

Planning is very important before communicating a product to others.

Explanation:

We should always prepare well about what we are going to communicate to others. We should know the topic properly or know about the product before we speak about it in front of others. We should understand the concept of the product before we communicate it to others.

Planning is also an important before going to speak or communicate.

Before communicating a product to others, we should prepare :

1. We should very well understand the concept of the product also its scope. The scope will provide product team with the destinations.

2. We should keep in mind to involve the valuable customers in our plannings.They defines the priorities of the product.

3. We should recognize that the planning is highly iterative.

4. We should do a market research or study or the business domain that the product will address.

5. We should understand the different stakeholders and their requirements and be open to negotiations.

It is vital to prepare in every communication as your success  depends on it. One can prepare by researching on the area we want to talk about and practicing one's speech.

Why do we need to prepare in communication?

The success one has in communicating is said to be a skill that is often used in a lot of field of work.

Conclusively, It is vital that a person do  prepare to communicate well when they have been given the opportunity to do so and this involves a lot of research and practice.

Learn more about preparation of manifest  from

https://brainly.com/question/13524298

Pleases Help ME An example of a _________________ impact is when a product is back ordered and the business contacts the customer via email to let them know of the new ship date.


A)Negative



B)Positive

Answers

Answer:

positive

Explanation:

it shows good customer service

plssss help i will mark u as brainliest plssss ​

Answers

Answer:

Explanation:

<p style="color: red">Random Name 1</p>

<p style="color: blue">Random Name 2</p>

<p style="color: yellow">Random Name 3</p>

<p style="color: green">Random Name 4</p>

<p style="color: gray">Random Name 5</p>

<ol>

   <li>Pen 1<li>

   <li>Pen 2<li>

   <li>Pen 3<li>

<ol>

<ul>

   <li>CPU<li>

   <li>Motherboard<li>

   <li>RAM<li>

   <li>GPU<li>

<ul>

I think is this you need, have a nice day ;)

A program that will ring a bell six times is what kind of program?
A. Edited
B. Iterative
C. Selection
D. Sequence

Answers

Answer:

D

Explanation:

because it is a sequence it does more than one thing

Answer:

B

Explanation:

I took the test

Which of the following online activities seem appropriate for the workplace? (select all that apply) A.watching a webinar to learn new job skills
B.watching TV online
C. seeking donations to support your election to the Senate
D. reading press releases from your company's competitors
E. sharing career advice with your peers
F. sharing company secrets in a public forum​

Answers

Answer:

A, D, and E

watching a webinar to learn new job skills

reading press releases from your company’s competitors

sharing career advice with your peers

Explanation:

got it right on edge2020

The online activities that seem appropriate for the workplace  is sharing career advice with your peers.

What are virtual activities?

The virtual activities are known to be any kind of online activities that is often done by people to make sure they have good and continued collaboration with other people.

Conclusively, Note that the use of online activities in the workplace should be the one that will help you and your peers to grow such as  sharing career advice with your peers.

Learn more about  online activities  from

https://brainly.com/question/13171394

Why would a programmer use a flow chart? (Edge2020 Coding Critical Thinking Questions)

Answers

Answer:

As a visual representation of data flow, flowcharts are useful in writing a program or algorithm and explaining it to others or collaborating with them on it. You can use a flowchart to spell out the logic behind a program before ever starting to code the automated process.

Explanation:

Answer: I answered yo can give the other guy brainliest yw

Explanation:

Suppose that one of the following control signals in the single-cycle MIPS processor has a stuck-at-0 fault, meaning that the signal is always O, regardless of its intended value. What instructions would malfunction? Why? (a) RegWrite (b) ALUOp1 (c) MemWrite Repeat for all three signals (a) to (c) above, assuming that the signal has a stuck-at-1 fault.

Answers

Answer:

Explanation:

RegWrite:

• All R-type instructions, lw and addi:

• The result of the operation/load/addition would not be written back to the destination register

• ALUOP

• The following R-type instructions: add, sub, and, or, slt

• With ALUOp stuck at 0, the ALU decoder would interpret all those instructions as either add or subtract operations. The ALUOp gets decoded to add or subtract depending on ALUOp[0].

• MemWrite:

• Only sw is affected.

• The memory write won’t take place.

What kind of skill is persuasion?


neutral skill

hard skill

soft skill

high skill

Answers

Answer:

soft skill

Explanation:

____________________________ and _________________________ are 2 positive impacts of the internet on businesses.

A)Competition and Easy Marketing


B)Improved Communication and Worrying security


C)Improved Communication and Increased unnecessary competition


D)Improved Communication and Easy Advertisement

Answers

D improved comms and easy ads

Answer:

D)due to it we can have more profit with less time and wide area communication

I NEED HELPS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! UWU

jeremy has a handful of resisters and all of them except one have for bands the exception has three why?

Answers

Answer:

The 3 band resistor does not specify the tolerance.

Ususally this means the tolerance is 20%, which is not great.

Explanation:

The last band is typically the tolerance band, i.e., the lower the tolerance the more accurate the value as indicated by the other bands. In case of a 3 band code, there is no tolerance specified and you have to assume the default of 20%.

During periods when the internet is not slowed by congestion, the number of internet searches is probably close to the socially efficient number. how can we tell this this is true?

Answers

Answer:

We can this is true because the number of internet searches that are being done at that time is just enough to meet the actual capacity of the internet facility.

Explanation: Socially efficient number is that number that is just enough to meet the actual capacity of a given system such as an internet connectivity or internet facility.

When the number of internet searches are just enough not to cause congestion in the search engines or internet facility,it can be said that the socially efficient number has been achieved.

Just took a test and I got 5 wrong and I wanted to know the correct answers

Answers

Answer:

I need the pic

Explanation:

What computer part it this? Explain to get brainliest. People that don't explain, won't get it, but will get a thanks + a 5 star rate.

Answers

Answer:

That is a motherboard, a circuit board containing the main components (CPU, RAM, etc) of a computer. It contains connectors in which other circuit boards can be slotted into.

Explanation:

A motherboard is a specialized circuit board (a thin board containing a electrical circuit) used for containing major components of a computer and allowing the parts to be used in conjunction with each other. This is why you'll find a motherboard in a large variety of computers, from phones, to PC's and laptops.

Answer: Motherboard.

Explanation: it's the backbone of a computer, it ties all the computers components together.

Before radio, many minority musicians were severely limited by the prejudice of the era. true o rfalse

Answers

Answer:

True

Explanation:

Minoritys have always faced prejudice

PLEASE I NEED HELP NOW!!!!!


Frank types in many numbers to calculate baseball statistics. To enter these numbers, he should use the _____.

Answers

Answer:

Numeric keypad

Explanation:

The numeric keypad has mostly only numbers so it would be more convenient for him.

Hope this helps!

Answer:

Numeric keypad on the right side of the keyboard.

Explanation:

Ap*x

How goes design again ones attention?

Answers

Answer:

the only thing i could think of is creating a different way to get someone to pay attention to you like maybe instead of shouting or tapping on ones shoulder maybe try to ask the person closest to them to get their attention for you. or by doing something extremely impressive or distracting

Explanation:

How does natural gas move through pipelines from the well head to the end user thousands of miles away

Answers

It’s the large compressors that are pumping and working together through the different stations ... They move the gas through the pipelines which they’re under high pressure.

ASAP PLZ!!!. Which command group is used to apply effects and modify color schemes of SmartArt graphics?

Reset Graphics

SmartArt Styles

Graphic Layouts

Create Graphics

NVM!! The answer is B. SmartArt Styles

Answers

Answer:

I think I am wrong but I assume it is C. Graphic Layout Sorry if I am wrong but if I am not please reward me brainlist.

The answer is B. Smart Art styles because your adding a styles to SmartArt

how to create diagram that demonstrates the step
by step procedures in performing a mail merge.

Answers

Answer:

hope it helps

1-Creating a Main Document and the Template.

2-Creating a Data Source.

3-Defining the Merge Fields in the main document.

4-Merging the Data with the main document.

5-Saving/Exporting

What number will be output by the console.log command on line 5

Answers

Answer:

-2

Explanation:

What are the ten main components of a report that would be delivered at the end of a data science project?

Answers

Answer:

The answer is below

Explanation:

The ten main components of a report that would be delivered at the end of a data science project are the following:

1. Cover page: the involves elements such as the title of the project, the name of the author, name of institution, date of publication

2. Table of Contents: this comprised information like chapters, topics, and subtopics

3. Abstract: a summary of the whole project

4. Introductory Section: a brief background study

5. Methodology section: this describes the methods used in gathering and analyzing the data

6. Data section: this shows the data gathered for the project. It is mostly represented in tables, histograms, pie charts, etc.

7. Analysis section: this describes what was analyzed

8. Result section: this described the outcome of the analysis

9. Conclusion section: this describes the whole outcome of the data project and what the author derived or concluded.

10. References: this describes the information about the works of other authors, the author used in building his background knowledge towards his data science project.

Which of the following is considered an input device?

Answers

Do you have a picture or list?

Answer:

Keyboard

Mouse

Light pen

Microphone

Touch pad

When a called function completes its task, it normally:_________a. logs its results b. terminates program execution normally c. aborts program execution d. returns to the calling function

Answers

Answer:

sorry this is tought

Explanation:

no idea

Why is content knowledge as important as generalized critical thinking for Web Analytics and Web Intelligence reporting and insights? A) Because it's very difficult for students to apply critical thinking skills learned in one subject to another, even between different fields of science. B) It is said that content is king and that having up to date content knowledge of Web Analytics is crucial in order to be an effective Analyst C) Everything is changing so fast that you need to keep up to date with the changes in the platforms that you use or are considering using for personal or organizational deployment. D) Content knowledge of Web Analytics is important because in a field like emerging technology that Web Analytics is still considered to be, new features of a Web Analytics platform can have a major impact on the ability to do the project and deliver value from it.

Answers

Answer:

B) It is said that content is king and that having up to date content knowledge of Web Analytics is crucial in order to be an effective Analyst

Explanation:

The answer is option B. A good knowledge of content is very important and crucial due to the fact that knowledge stands at the center or the most important thing in the business sector.

Web analytics is a method of measuring, analysing and reporting web usage data. Content knowledge is a good understanding of the subject area. To understand web analytics, a going knowledge of the facts, theories and concepts are important if one wants to be an effective analyst.

Therefore b is the answer to this question.

Range is an example of a ______________.

Answers

Answer:

example in ( 4,6,9,3,7) lowest value is 3and highest is 9.

Given main(), complete the Car class (in file Car.java) with methods to set and get the purchase price of a car (setPurchasePrice(), getPurchasePrice()), and to output the car's information (printInfo()).
Ex: If the input is:_______.
2011
18000
2018

Answers

Answer:

Explanation:

This a java code for a car and can be written as follows:

public class Car {

   private int modelYear;

   private int purchasePrice;

   private int currentValue;

   public int getModelYear() {

       return modelYear;

   }

   public void setModelYear(int modelYear) {

       this.modelYear = modelYear;

   }

   public int getPurchasePrice() {

       return purchasePrice;

   }

   public void setPurchasePrice(int purchasePrice) {

       this.purchasePrice = purchasePrice;

   }

   public int getCurrentValue() {

       return currentValue;

   }

   public void calcCurrentValue(int year) {

       int age = year - modelYear;

       currentValue = (int) Math.round(purchasePrice * Math.pow(0.85, age));

   }

   public void printInfo() {

       System.out.println("Car's information:");

       System.out.println("   Model year: " + modelYear);

       System.out.println("   Purchase price: " + purchasePrice);

       System.out.println("   Current value: " + currentValue);

   }

}

Can someone help me to write a python code to save list form python to CSV file please?​

Answers

f = open("MyFileName.csv", "w")

lst = ["Hello", "Hi", "Bye"]

f.write(str(lst))

f.close()

I didn't necessarily know what you meant by list form. This program works for me in pycharm. I had to install the CSV plugin though. If you encounter any errors, I'll try my best to help you.

PLZ HELP!!!!!!!!! XC

what dose it mean if a circuit is hot to the touch

Answers

Answer:

The circuit is carrying more than it is supposed to and is overheating.

The series is overloaded

Which of the following are reasons why it is important to write readable code?
Choose all that apply.

Readable code is easier to maintain.

Readable code is easier to modify.

Readable code is fun to write.

Writing readable code saves time in the long run.

Answers

Answer:

Readable code is easier to maintain.

Writing readable code saves time in the long run.

Readable code is easier to modify.

Readable code is fun to write.

Explanation:

Readability of a code means that how easy it is to read the code even if any person other than programmer reads the code. Different techniques like line breaks and indentation are used to make the code readable. the program follows an indentation pattern so it is easy and fun to write.

Hence,

it can be concluded that the true statements are:

Readable code is easier to maintain.

Writing readable code saves time in the long run.

Readable code is easier to modify.

Readable code is fun to write.

Answer:

for short answer it is a,b and D

Explanation:

Define a function pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a pyramid with a rectangular base.

Answers

Answer:

Define a function pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a pyramid with a rectangular base.

Explanation:

thats all you said

In python 3.8:

def pyramid_volume(base_length, base_width, pyramid_height):

   return round((base_length*base_width*pyramid_height)/3,2)

print(pyramid_volume(1,1,2))

I used the round function to round the volume to 2 decimal places. You can change this if you need more or less precision. I hope this helps!

Other Questions
what is 5(3x+8) answer? what is 25+30 pleas help me Exploration changed the whole face of the ________ countries A. Italian empire B. European C. Unexplored Robert de la salle was instrumental in encouraging__ Simplify4x+2y+z3x+2y2z A train traveled at an average speed of 45 miles per hour for 40 minutes, and at an average speed of 60 miles per hour for 1 hour. What was the average speed of the train, in miles per hour, for the trip?a.) 50, b.) 52.5, c.) 54, d.) 57,5, e.) 60 What are some of the achievements of the Gupta Empire that still affect society today? Discuss contributions made in mathematics, science, and medicine.WILL MARK BRAINLIEST (2-3 paragraphs) calculate the perimeter of a square with vertices on a circle of diameter 4 cm I need help asap thxss What is the best reason for including paragraphs 1 through 12 in this piece?(Will give brainliest)A.They provide historical context for the argument.B.They provide ethos, logos, and pathos to the central argument.C.They encourage the reader to question the authors premise.D.They establish the primary rebuttal of the authors argument.E.They outline the chronology of the events, allowing the authors to reference them to support their main argument.(piece bellow)https://www.bartleby.com/71/1304.html Formulate a weekly schedule that shows evidence of three different activities beneficial for your muscular system. what common geographic features are there? In the human body, the heart lies in front of the spinal cord, which runs down the back of the body. The heart is _______ to the spine. a. superiorb. dorsal c. perpendiculard. ventral What is the binary number for 24 Please help. Please answer if you know. The weight of eggs from a local farm are Normally distributed with mean of 2.1 ounces and a standard deviation of 0.25 ounces.A graph titled Weight of Eggs has ounces on the x-axis going from 1.35 to 2.85 in increments of 0.25. The highest point of the curve is at 2.1. Everything to the left of that point and under the curve is labeled average, everything to the right is large.An egg that weighs 2.0 ounces or more is labeled large and anything below is labeled average.What percent of eggs from this farm are labeled as large? Round to the nearest tenth. 65.5 IS THE ANSWER Write a recursive rule for the sequence 10, 18, 26, 34. what is the answer? What becomes visible during prophase under a microscope? A. RibosomesB. ChromosomesC. Cell MembraneD. Nucleus Which city is the capital of Iran and is labeled with the letter Y on the map above? A. Tehran B. Beirut C. Baghdad D. Damascus