00:01
Hello student, here the problem is find the median l.
00:04
Input l is the input list containing the n real number n output.
00:08
The median of the l is m.
00:10
If n is less than 10, then sort l and return the median m.
00:15
And if divide l into the n list of size 5.
00:19
So, here we are dividing the list into the 5 list.
00:24
So, here recurrence formula for this running time for algorithm 1 is if i am dividing n into n by 5.
00:34
So, and again i am applying the recurrence.
00:37
So, here for n by 5.
00:39
So, time will be n by 5 for if for n tn then for n by 5 it will be tn by 5 and again big o of n.
00:50
So, here big o of n term is the cost of sorting each list of the size 5.
00:56
So, here we are dividing the list into the 5 sub parts.
01:01
So, this will be the cost.
01:03
So, this factor represent the cost.
01:06
The solution of this recurrence equation.
01:08
So, here this is the recurrence equation.
01:10
This is the recurrence equation and so its solution come.
01:14
So, if we look like this is because the recurrence is similar to the recurrence for the quick sort algorithm.
01:19
This is and quick sort running time is n log n.
01:22
So, with the help of this we i provided the running time.
01:26
Now, correctness of the algorithm to prove that the algorithm 1 is correct we need to show that it is always return the medium of the input list l.
01:35
So, if the algorithm is running very well then it will always return the medium.
01:39
So, we can do this by the induction on the size of the input list best case.
01:45
If the size of the input list is less than 10 then the algorithm simply sort the list and return the medium.
01:52
So, this is given in the problem.
01:53
Then if the size is less than 10 so here then the algorithm will simply sort the list and return the medium.
02:01
This is correct because the median of the sorted list is the median element.
02:05
So, if we want to calculate the median then we have to always sort the list.
02:11
So, list must be always sorted.
02:14
Induction step assume the algorithm is correct for all the input list of the size less than n...