0 votes 0 votes In the max heap where the smallest element reside i)if all element are distinct? ii) if all element are not distinct? What is the time complexity in both the cases? If any space complexity required ? srestha asked Jun 26, 2016 srestha 330 views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply vijaycs commented Jun 26, 2016 reply Follow Share i)if all element are distinct? ... Ans- Smallest element must be among the leaf nodes of max -heap. Time complexity - O(n)... Just search last n/2 elements of max heap array. 0 votes 0 votes Kapil commented Jun 26, 2016 reply Follow Share 1) if all are distinct, then search all leaves in O(n) time 2) If all are equal, then searching leaf takes O(1) time 0 votes 0 votes vijaycs commented Jun 26, 2016 reply Follow Share I think there is a difference between ii) if all element are not distinct and your 2nd statement " If all are equal". Am i right ?? 0 votes 0 votes Kapil commented Jun 26, 2016 i edited by Kapil Jun 26, 2016 reply Follow Share yes , there is a difference .it means some can be same and some can be different . so i think we can augment our heap by providing ranking to all the elements and then the heap will become distinct and then as it will be same as all are distinct so , it will also be O(n) what do u say? 0 votes 0 votes Please log in or register to add a comment.