The total comparisons in finding both smallest and largest elements are

Category: QuestionsThe total comparisons in finding both smallest and largest elements are
Editor">Editor Staff asked 5 months ago

The total comparisons in finding both smallest and largest elements are
 
(a) 2*n +2
 
(b) n + ((n+1)/2) -2
 
(c) n+logn
 
(d) n^2
 
Question is from Weak Heap topic in chapter Heap of Data Structures & Algorithms I
 
The question was posed to me in an interview.

1 Answers
Editor">Editor Staff answered 5 months ago

The correct option is (b) n + ((n+1)/2) -2
 
The best explanation: The total comparisons in finding smallest and largest elements is n + ((n+1)/2) – 2.


Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40702