Given ve distinct values, the median would be the value in the third posi- tion
ID: 3550123 • Letter: G
Question
Given ve distinct values, the median would be the value in the third posi-
tion if they were sorted. Prove that the median can be
found more efciently, namely, with no more than six comparisons.
http://books.google.com/books?id=FUeGDaqjk5oC&pg=PT108&lpg=PT108&dq=Given+%EF%AC%81ve+distinct+values,+the+median+would+be+the+value+in+the+third+position+if+they+were+sorted&source=bl&ots=qBgXGgayAi&sig=MIl5cHNp7W_ojJ5S1EGmQWURsRU&hl=en&sa=X&ei=nGT4Uuy8N43YyAG-1YHgDw&ved=0CCoQ6AEwAA#v=onepage&q=Given%20%EF%AC%81ve%20distinct%20values%2C%20the%20median%20would%20be%20the%20value%20in%20the%20third%20position%20if%20they%20were%20sorted&f=false
Explanation / Answer
// Compare elements in O(log n), means order 2 ^ 6 elements. 64 elements as
if(upper > middle) element, array == array / 2 nd so on..
if(arraysize is zero) return arr[2];
.//hope clerify your doubt.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.