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
xxMikexx [17]
3 years ago
13

1. Describe a linear search (explain how it works).

Computers and Technology
1 answer:
timurjin [86]3 years ago
7 0
1. A linear search searches on a straight path, hence the term “linear”. So a linear search would search from a one index to another in a straight path. For example, a linear search of an array, if given given the first and last index of the array, would search it one index after the other. First it would check index 0, then index 1, then index 2, and so forth.

2. A linear search can be useful if you are trying to find more than one instance of an value in a data structure. Since you want to search the whole array for each instance of the object or value.

3. A binary search only works with sorted data structures. It takes a data structure, finds its mid point, and checks I see if the value it is looking for is greater, less than, or equal to the midpoint value. If it is equal to the midpoint value, it’s finished and the search function is over.
If it’s greater than the midpoint, it disregards the lower half of the data structure and focuses on the upper half. If it’s less than the mid point then it disregards the upper half and focuses on the lower half.
It then repeats what it did at the beginning of the search function to again narrow down the amount of searching that needs to be done. In other words, if it disregarded the lower half of the data structure in the first part of the search, it finds the midpoint of the upper half of the data structure, checks to see if the value it’s looking for is greater than, less than, or equal to the midpoint. If it’s equal to it the searching is done, if it’s greater it disregards the lower half of the upper data structure, and repeats the process.
It will continue to do this until either the value is found or the value is not found.

4. You would use binary search if you are searching for one specific value in a sorted data structure.

5. A binary search must have a sorted data structure for it work.

6. Binary search is more efficient because the cost to run a binary search is substantially less than running a linear search.







You might be interested in
Write a program that accepts three decimal numbers as input and outputs their sum​
Sophie [7]

Answer:

sum = 0.0

for i in range(0,3):

   sum += float(input("Enter a decimal number to sum: "))

print ("Sum: ", sum)

*** Sample Input ***

Enter a decimal number to sum: 1.1

Enter a decimal number to sum: 2.2

Enter a decimal number to sum: 3.3

*** Sample Output ***

Sum:  6.6

Explanation:

For this problem, a method was devised in python to create the sum of three individual decimal numbers.

The first line of code, <em>sum = 0.0</em>, initializes a variable to the float type in which we will store the value of our sum.  Note, it is initialized to 0.0 to start from a value of 0 and be considered a float.

The second line of code, <em>for i in range(0,3):</em>  is the creation of a for loop control structure.  This will allow us to repeat a process 3 amount of times using the iterator i, from value 0 to 3 in this case.  Note, 0 is inclusive and 3 is exclusive in the python range.  This means the for loop will iterate with, i=0, i=1, and i=2.

The third line of code, <em>sum += float(input("Enter a decimal number to sum: "))</em>  is simply asking the user for a number, taking that input and converting it from a string into a float, and then summing the value with the previous value of sum and saving that into sum.

The fourth line of code, <em>print ("Sum: ", sum)</em> is simply displaying the final value that was calculated by adding the three user inputs together which were stored into the variable <em>sum</em>.

Cheers.

6 0
2 years ago
Read 2 more answers
Which type of network cover a large geographical area and usually consists of several smaller networks, which might use differen
nlexa [21]

Answer: WIDE AREA NETWORK (WAN)

Explanation: hopes this helps

7 0
3 years ago
They predicted another cold day in Seattle. They predicted another windy day in Seattle. Combine the sentences into one sentence
VLD [36.1K]

Answer:

They predicted another cold day in Seattle and another windy day in Seattle.

4 0
3 years ago
Area on a computer screen where<br> you perform work
raketka [301]

Answer:

Screen or monitor, it may be also the central processing unit (CPU) where you manage your computers actions

brainliest please ;)

3 0
3 years ago
Pls help me computer science discoveries
lara31 [8.8K]

Answer:

jdinwoahdjsioadjsakodsiaohdeioajfnsohfujkdshksyfneowjdfikdjiadjsadhnsuidghaiudbnha

Explanation:

3 0
2 years ago
Other questions:
  • What port does rdp use by default and from what range of numbers should you select a private port number?
    15·1 answer
  • Susan is keen to learn various safe ways to browse the Internet. She is looking for suggestions that would help her. Which activ
    15·2 answers
  • If you press the Tab key when you're in in the last cell of a table,
    10·2 answers
  • Consider relations A and B. Relation A represents the entity on the ""one side"" of a one-to-many relationship; Relation B repre
    11·1 answer
  • When a user inserts a PivotTable, where will it be inserted?
    15·1 answer
  • Roark has just joined a company and in his role as a lead analyst, he will be responsible for determining which systems developm
    11·1 answer
  • Which of these statements about the truck driving occupation in the U.S. are accurate?
    12·2 answers
  • Which one is the answer for the question.
    11·1 answer
  • You learned that "The CPU interacts with memory in a process that is known as
    6·1 answer
  • Explain the correct ways of using keyboard. .​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!