Given that the list is in sorted order. Let us assume that the list in
the form of an array A[1...n].

Case 1: If n is odd. Then the median is A[(n+1)/2]. Set MEDIAN:=A[(n
+1)/2.
Case 2: If n is even. Then the median is (A[n/2]+ A[n/2 +1])/2. Set
MEDIAN:=(A[n/2]+ A[n/2 +1])/2.

Assuming that the array accessing, the addition and division takes
O(1) time. The running time of the algorithm is O(1).

On Jul 26, 1:15 pm, Manjunath Manohar <[email protected]>
wrote:
> @Anand...for better efficiency..we can find the pivot as a random
> integer..for better worst case complexity..

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to