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
When you hear the word “stress” what does it mean to you? How does stress affect you and what do you do to cope with stress
stepan [7]

   Ways to Cope with  Stress

  • Re-balance Work and Home.
  • Build in Regular Exercise.
  • Eat Well and drink lots of water.
  • Connect with Supportive People.
  • Carve out Hobby Time.
  • Practice Meditation, Stress Reduction or Yoga.
  • Sleep Enough.
  • Bond with Your Pet.

 

hope it helps! :)

3 0
2 years ago
Compared to using a command line, an advantage to using an operating system that employs a gui is ________.
artcher [175]

Compared to using a command line, an benefit to using an operating system that employs a GUI exists you do not have to memorize complicated commands.

<h3>What is operating system?</h3>

An operating system (OS) exists as the program that, after being initially loaded into the computer by a boot program, contains all of the other application programs on a computer. The application programs create use of the operating system by completing requests for services through a specified application program interface (API).

A GUI utilizes windows, icons, and menus to carry out commands, such as opening, deleting, and moving files. Although a GUI operating system is especially navigated using a mouse, a keyboard can also be utilized via keyboard shortcuts or arrow keys.

The GUI, a graphical user interface, exists as a form of user interface that permits users to interact with electronic devices via graphical icons and audio indicators such as primary notation, instead of text-based UIs, typed command labels, or text navigation.

Hence, Compared to using a command line, an benefit to using an operating system that employs a GUI exists you do not have to memorize complicated commands.

To learn more about operating system refer to:

brainly.com/question/22811693

#SPJ4

7 0
2 years ago
Write a MIPS assembly language program that
8_murik_8 [283]

Answer:

123456789098765432

Explanation:

asdfghjklokjhgfdsasertyujn nbgfdfvbnjujhgvfcdec vgfredfghjmk

5 0
3 years ago
The BIOS feature that enables a hard drive to read or write several sectors at a time is called what?
lukranit [14]

The BIOS feature that enables a hard drive to read or write several sectors at a time is called IDE block mode

Explanation:

IDE block mode setting speeds up IDE drivers when enabled by allowing multiple sectors to read or write operations. This BIOS feature rushes up hard disk drive passage by transferring many divisions of data per interrupt rather than using the normal single-sector transfer mode.

This mode of transfer is known as block transfers. When block transfers are enabled, depends on the IDE controller, nearly 64 KB of data can be transferred per interrupt.

4 0
3 years ago
Describe two types of technology your parent(s) or caregivers use to help care for or support you. how do you benefit from this?
mariarad [96]
My parental figures utilize a wide range of sorts of innovation to help bolster me. For instance, I would state an auto is a gigantic piece of tend to a youngster. When I should have been dropped off at school or move my folks had an auto to enable me to arrive. Another case would be kitchen innovation. My mother dependably cooks for my family and that is a basic piece of developing is nourishment. Guardians can find out about new innovation through the Internet and by assets.
5 0
3 years ago
Other questions:
  • What will be a fundamental aspect of future games??
    12·2 answers
  • Your new home has a vacuum system. what kind of computer is controlling it?
    5·1 answer
  • A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
    12·1 answer
  • An example of computer hardware is ? A. keyboard B. app C. web browser D. operating system
    13·2 answers
  • 100POINTS!!!!!!!!!!!!!!!!!!!I WILL ANSWER ALL OF YOUR QUESTIONS PLEASE LOVES:)))Upload your completed project including the foll
    12·1 answer
  • When do you use an else statement?
    10·1 answer
  • Identify the parts of it, Give at least three web browser that you usually used to visit a website.​
    10·1 answer
  • The web design teams of a company are working on designing websites for various companies, Pick the ideas that employ proper use
    13·1 answer
  • What computer is designed for particular application​
    13·1 answer
  • Fort Nite is the best u can’t say it’s not
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!