Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Question:Suppose the probability that \(x\) is the \(i\) element in a list of \(n\) distinct integers is \(i/(n(n + 1))\). Find the average number of comparisons used by the linear search algorithm to find \(x\) or to determine that it is not in the list.

Short Answer

Expert verified

Answer

The average number of comparisons used by the linear search algorithm to find or to determine that it is not in the list is \(\frac{{10n + 11}}{6}\).

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

Over 22 million students worldwide already upgrade their learning with Vaia!

01

In the problem given  

\(P\)(\(x\) is the \({i^{{\rm{th }}}}\)element in a list of \(n\) distinct integers) \( = \frac{i}{{n(n + 1)}}\)

02

The definition and the formula for the given problem

Linear search is a very simple search algorithm. In this type of search, a sequential search is made over all items one by one. Every item is checked and if a match is found then that particular item is returned, otherwise the search continues till the end of the data collection.

Concept used:

\(\begin{aligned}{c}\sum\limits_{i = 1}^i i = \frac{{n(n + 1)}}{2}\\\sum\limits_{i = 1}^i {{i^2}} = \frac{{n(n + 1)(2n + 1)}}{6}\end{aligned}\)

03

Determining the sum in expanded form

The probability that the item is in the list is.

\(\begin{aligned}{c}\sum\limits_{i = 1}^n {\frac{i}{{n(n + 1)}}} &= \frac{1}{{n(n + 1)}}\sum\limits_{i = 1}^n i \\ &= \frac{1}{{n(n + 1)}} \times \frac{{n(n + 1)}}{2}\\ &= \frac{1}{2}\end{aligned}\)

Therefore, the probability that the item is not in the list is also \(\frac{1}{2}\).

If the item is not in the list then the number of comparisons are \(2n + 2\).

Similarly, if the item is the \({i^{{\rm{th }}}}\) item in the list then the numbers of comparisons needed are \(2i + 1\)

The expected numbers of comparisons are given by

\(\begin{aligned}{c} &= \frac{1}{2}(2n + 2) + \sum\limits_{i = 1}^n {\frac{i}{{n(n + 1)}}} (2i + 1)\\ &= (n + 1) + \frac{2}{{n(n + 1)}}\sum\limits_{i = 1}^n {{i^2}} + \frac{1}{{n(n + 1)}}\sum\limits_{i = 1}^n i \\ &= n + 1 + \frac{2}{{n(n + 1)}} \times \frac{{n(n + 1)(2n + 1)}}{6} + \frac{1}{{n(n + 1)}}\frac{{n(n + 1)}}{2}\\ &= (n + 1) + \frac{{2n + 1}}{3} + \frac{1}{2}\\ &= \frac{{6(n + 1) + 2(2n + 1) + 3}}{6}\\ &= \frac{{10n + 11}}{6}\end{aligned}\)

Therefore, the expected numbers of comparisons are \(\frac{{10n + 11}}{6}\).

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Question: Suppose that \(E, {F_1},{F_2}\,and {F_3}\)are events from a sample space S and that \({F_1},{F_2}\,and {F_3}\) are pair wise disjoint and their union is S. Find \(p\left( {\frac{{{F_2}}}{E}} \right)\)if \(p\left( {\frac{E}{{{F_1}}}} \right) = \frac{2}{7},p\left( {\frac{E}{{{F_2}}}} \right) = \frac{3}{8},p\left( {\frac{E}{{{F_3}}}} \right) = \frac{1}{2},p\left( {{F_1}} \right) = \frac{1}{6},p\left( {{F_2}} \right) = \frac{1}{2}\) and \(p\left( {{F_3}} \right) = \frac{1}{3}\)

Question: Suppose that 100 people enter a contest and that different winners are selected at random for first, second, and third prizes. What is the probability that Kumar, Janice, and Pedro each win a prize if each has entered the contest?

Question: A group of six people play the game of “odd person out” to determine who will buy refreshments. Each person flips a fair coin. If there is a person whose outcome is not the same as that of any other member of the group, this person has to buy the refreshments. What is the Probability that there is an odd person out after the coins are flipped once?

Question: An electronics company is planning to introduce a new camera phone. The company commissions a marketing report for each new product that predicts either the success or the failure of the product. Of new products introduced by the company, 60% have been successes. Furthermore. 70% of their successful products were predicted to be successes, while 40% of failed products were predicted to be successes. Find the probability that this new camera phone will be successful if its success has been predicted.

Question: What is the expected sum of the numbers that appear on two dice, each biased so that a 3 comes up twice as often as each other number?

See all solutions

Recommended explanations on Math Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free