0 votes 0 votes An element in an array $X$ is called a leader if it is greater than all elements to the right of it in $X$. The best algorithm to find all leaders in an array solves it in linear time using a left to right pass of the array solves in linear time using a right to left pass of the array solves it using divide and conquer in time $\theta (n\log n)$ solves it in time $\theta (n^{2})$ Algorithms nielit2016mar-scientistc algorithms array + – admin asked Apr 2, 2020 • recategorized Oct 28, 2020 by Krithiga2101 admin 1.6k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes (B) is the correct answer. for the detailed explanation. https://www.geeksforgeeks.org/leaders-in-an-array/ vschs007 answered Apr 4, 2020 vschs007 comment Share Follow See 1 comment See all 1 1 comment reply aanchal008 commented Apr 4, 2020 reply Follow Share to find leaders just do a scan from right to left in the array. This will be done in linear time O(n). So, the correct option (B). 1 votes 1 votes Please log in or register to add a comment.
0 votes 0 votes Do a scan from right to left, and keep storing the max. element encountered till that point. Whenever an element greater than max. is encountered, it is a leader. Joey answered Jan 5, 2021 Joey comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes B,C,D ALL ARE POSSIBLE WHEN WE TRY TO FIND A LEADER BUT QUESN ASKS BEST ALGORITHIM SO SIMPLY OPTION B IS BEST lovegate answered Mar 9, 2021 lovegate comment Share Follow See all 0 reply Please log in or register to add a comment.