recategorized by
1,645 views
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

  1. solves it in linear time using a left to right pass of the array
  2. solves in linear time using a right to left pass of the array 
  3. solves it using divide and conquer in time $\theta (n\log n)$
  4. solves it in time $\theta (n^{2})$
recategorized by

3 Answers

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.
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
Answer:

Related questions

3 votes
3 votes
1 answer
1
admin asked Apr 2, 2020
1,411 views
To sort many large objects or structures, it would be most efficient to placethem in an array and sort the arraypointers to them in an array and sort the arraythem in a l...
3 votes
3 votes
2 answers
3
admin asked Apr 2, 2020
920 views
The most efficient algorithm for finding the number of connected components in a $n$ undirected graph on $n$ vertices and $m$ edges has time complexity$\Theta (n)$$\Theta...
0 votes
0 votes
1 answer
4
admin asked Apr 2, 2020
1,648 views
The advantage of better testing in software development is in waterfall modelprototypingiterativeall of these