1 1 vote Consider an array of 19 elements, Find the minimum number of comparisons required to find minimum and maximum elements in an array Algorithms algorithms sorting normal numerical-answers + – Rohan Mundhey 2.0k views answer comment Share Follow Print See 1 comment 1 1 comment reply Anusha Motamarri commented Nov 9, 2016 i edited by Anusha Motamarri Nov 9, 2016 reply Follow flag 28?. 1 1 replyShare Please log in or register to add a comment.
Best answer 3 3 votes is anythng i miss? Prashant. answered Nov 9, 2016 • selected Nov 10, 2016 by Rohan Mundhey Prashant. comment Share Follow See all 2 Comments 2 2 Comments reply Rohan Mundhey commented Nov 10, 2016 reply Follow flag how 9 for max ? 0 0 replyShare Prabhanjan_1 commented Nov 10, 2016 reply Follow flag @Anirudh your explaination is clear and simple .. But how about when given 500 elements , this perfectly time taking and not possible even. Please solve this using reccurence relation for three cases https://gateoverflow.in/79484/modified-gate-2014-comparisons 0 0 replyShare Please log in or register to add a comment.
0 0 votes Minimum number of comparison is O(1) ,when we know array is sorted. But here we donot know array as sorted So, minimum no. comparison and maximum number of comparison=O(n)=3/2n-2 comparisons For 19 element , in worst case it will be (3/2*19-2) comparison. srestha answered Nov 9, 2016 • edited Nov 9, 2016 by srestha srestha comment Share Follow See all 6 Comments 6 6 Comments reply Show 3 previous comments srestha commented Nov 13, 2017 reply Follow flag does it matter? 0 0 replyShare Rupendra Choudhary commented Nov 13, 2017 reply Follow flag when n is odd , 1.5n-2 won't be able to produce integer so i think it matters. 0 0 replyShare srestha commented Nov 14, 2017 reply Follow flag @Rupendra not required , see here https://gateoverflow.in/1248/gate2007-50#c169881 0 0 replyShare Please log in or register to add a comment.
0 0 votes We have to do (n-1) comparison , so for 19 elements total comparison requires is 18. vishwa ratna answered Nov 9, 2016 vishwa ratna comment Share Follow See 1 comment 1 1 comment reply Rupendra Choudhary commented Nov 13, 2017 reply Follow flag Hello vishwa , question is not about 'Min number of comparison required in best case' It's general case in which any arrangement can be possible. so it can't be like n-1=18 0 0 replyShare Please log in or register to add a comment.