To find the second smallest element, first find the smallest element using tournament method.
Finding the smallest element requires:
$n-1$ comparisons
The smallest element can lose comparisons against at most:
$\lceil \log n\rceil$ elements
Now, to find the second smallest among these elements, comparisons required are:
$\lceil \log n\rceil-1$
Total comparisons:
$(n-1)+(\lceil \log n\rceil-1)$
$=n+\lceil \log n\rceil-2$
Online Test Series, Information About Examination,
Syllabus, Notification
and More.
Online Test Series, Information About Examination,
Syllabus, Notification
and More.