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
mixas84 [53]
3 years ago
11

We have said that the average number of comparisons need to find a target value in an n-element list using sequential search is

slightly higher than n/2. In this problem, we find an exact expression for this average.
a. Suppose the list has an odd number of items,say 15. At what position is the middle item? Using sequential search, how many comparisons are required to find the middle item? Repeat this exercise with a few more odd numbers until you can do the following: If there are n items in the list and n is an odd number, write an expression for the number of comparisons required to find the middle item.
b. Suppose the list has an even number of items, say 16. At what position are the two "middle" items? Using sequential search, how many comparisons are required to find each of these? What are the average of these two numbers? Repeat this exercise with a few more even numbers until you can do the following: If there are n items in the list and n is an even number, write an expression for the number of comparisons required to find the two middle items.
c. Noting that half the items in a list fall before the midpoint and half after the midpoint, use your answer to parts a and b to write an exact expression for the average number of comparisons done using sequential search to find a target value that occurs in an n-element list.
Computers and Technology
1 answer:
bija089 [108]3 years ago
6 0

Answer:

Part a: If the list contains n elements (where n is odd) the middle term is at index (n-1)/2 and the number of comparisons are (n+1)/2.

Part b: If the list contains n elements (where n is even) the middle terms are  at index (n-2)/2 & n/2 and the number of comparisons are (n+2)/2.

Part c: The average number of comparisons for a list bearing n elements is 2n+3/4 comparisons.

Explanation:

Suppose the list is such that the starting index is 0.

Part a

If list has 15 elements, the middle item would be given at 7th index i.e.

there are 7 indices(0,1,2,3,4,5,6) below it and 7 indices(8,9,10,11,12,13,14) above it. It will have to run 8 comparisons  to find the middle term.

If list has 17 elements, the middle item would be given at 8th index i.e.

there are 8 indices(0,1,2,3,4,5,6,7) below it and 8 indices(9,10,11,12,13,14,15,16) above it.It will have to run 9 comparisons  to find the middle term.

If list has 21 elements, the middle item would be given at 10th index i.e.

there are 10 indices (0,1,2,3,4,5,6,7,8,9) below it and 10 indices (11,12,13,14,15,16,17,18,19,20) above it.It will have to run 11 comparisons  to find the middle term.

Now this indicates that if the list contains n elements (where n is odd) the middle term is at index (n-1)/2 and the number of comparisons are (n+1)/2.

Part b

If list has 16 elements, there are two middle terms as  one at would be at 7th index and the one at 8th index .There are 7 indices(0,1,2,3,4,5,6) below it and 7 indices(9,10,11,12,13,14,15) above it. It will have to run 9 comparisons  to find the middle terms.

If list has 18 elements, there are two middle terms as  one at would be at 8th index and the one at 9th index .There are 8 indices(0,1,2,3,4,5,6,7) below it and 8 indices(10,11,12,13,14,15,16,17) above it. It will have to run 10 comparisons  to find the middle terms.

If list has 20 elements, there are two middle terms as  one at would be at 9th index and the one at 10th index .There are 9 indices(0,1,2,3,4,5,6,7,8) below it and 9 indices(11,12,13,14,15,16,17,18,19) above it. It will have to run 11 comparisons  to find the middle terms.

Now this indicates that if the list contains n elements (where n is even) the middle terms are  at index (n-2)/2 & n/2 and the number of comparisons are (n+2)/2.

Part c

So the average number of comparisons is given as

((n+1)/2+(n+2)/2)/2=(2n+3)/4

So the average number of comparisons for a list bearing n elements is 2n+3/4 comparisons.

You might be interested in
Which option correctly identifies if the researcher’s approach was the best choice in the following scenario and explains why?
Tasya [4]

Answer:

A

Explanation:

go do it

4 0
3 years ago
Read 2 more answers
Carlos had 194 seeds and 11 flower pots he put the same number of seeds in each flower pot which is the best estimate for the nu
Anon25 [30]

Answer: in solution.

Explanation:

It is basically 194 divided by 11 since we are evenly grouping 194 seeds into 11 pots. This gives 17.636363…

This means that the best estimate is around that number.

6 0
2 years ago
Linda installed a special pool for the hydrotherapeutic treatment of severe arthritis, as prescribed by her doctor. The cost of
stellarik [79]

Answer:

Linda is entitled to deduction (before any AGI limitations) of $896 in one year of installation of the pool.

Explanation:

Following is explained calculation for deduction (before any AGI limitations) that is Linda entitled to in the year of installation of the pool.

Given that:

Cost of Installing the pool = $22,400

Paid by insurance company = $5,600

So by deducting the price paid by insurance company from total cost the balance becomes:

Balance = $22,400 - $5,600 = $ 16,800

As the pool increased the value of house by $7,840 so we will deduct this amount from balance:

Balance = $ 16,800 - $7,840 = $8,960

As the useful life given for pool is 10 years so we will divide the balance with 10 to obtain the deduction amount for 1 year:

Deduction amount for one year = $8,960/10 = $8,96

Hence $8,96 will be deducted in one year installation.

i hope it will help you!

7 0
3 years ago
Which of the following is an example of a data base?
mihalych1998 [28]

See how long I can hold the key down. I forgot there was a max :/

 

hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

7 0
2 years ago
Once a manual is written, it may change over time as procedures change. What's a recommended format for a manual to incorporate
zhenek [66]

Answer:

Print the manual in a loose leaf binder so even small changes can be replaced

Explanation:

Procedure  manual is the document that contains the business policies and strategies. These strategies can be changed time to time in the interest of company.

As these policies or procedures changes, it is necessary to communicate with all employees. To communicate this updated information to all employees it is necessary to print all that pages, where the changes have been made to replace them in the current manual. If we print whole manual it may increase the cost of printing. To reduce printing cost and wastage of pages only print those particular pages that have been changed. This will help to communicate to the existing employees as well  as to newly hired employees.

3 0
3 years ago
Other questions:
  • Your desktop computer monitor is not displaying a picture. What would you do to troubleshoot the problem?
    7·2 answers
  • This stores a piece of data and gives it a specific name
    7·1 answer
  • A high-angle shot is the same thing as a bird’s-eye shot. True False
    11·2 answers
  • Which of the following statements about Linux is not​ true? A. Linux works on all the major hardware platforms. B. It plays a ma
    5·1 answer
  • The process of encoding messages or information in such a way that only authorized parties can read it is called ____________.
    7·1 answer
  • A byte is made up of 8 bits (binary digits). You have a programming language that uses one byte to represent characters and are
    5·1 answer
  • The pay of an hourly worker is calculated by multiplying the hours worked by the hourly rate—up to 40 hours; any hours worked be
    11·1 answer
  • Can anyone help me this is due today :) <br> Thank you so much
    14·2 answers
  • When would you insert a merge field?
    10·2 answers
  • Identify and explain 3 methods of automatically formatting documents​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!