00:01
Okay, so we want to analyze the average case performance of the linear search algorithm if exactly half of the time the element is not in the list and half of the time it's in the list.
00:10
So what this question means is that suppose we have the list and we have an element x.
00:17
So we want to find this element x.
00:19
So what the question is saying is half of the time this element is in this list, half of the time it is not in this list.
00:26
So what we first want to do is we want to first find the number of comparisons when x is in this list.
00:36
So the average number of comparison in this, so what we know is that x can either be in any one of these positions.
00:43
So any one of these boxes is equally likely for x occurring.
00:48
So the number of comparisons on average is just one plus by two, plus by three, plus all the way up to n because there are n terms.
00:57
And divided by n.
01:00
So if you think about this, if you only had two boxes, the average, the number, on average, the number of comparisons you need is 1 .2, so that is just 1 .5.
01:11
So which is just 1 plus by 2 divided by 2.
01:14
So we do the same thing here and we'll just take an average.
01:17
So for this equation, this equation is an athrismatic progression, and athrithmetic progression has a formula.
01:25
The formula is just n times of n plus 1 divided by 2...