Commit bd758e2f authored by Fokion Zervoudakis's avatar Fokion Zervoudakis

Update Javadoc.

parent fb0dfaec
......@@ -2,16 +2,18 @@ package misc;
class BoyerM {
/**
Uses the Boyer-Moore majority vote algorithm to find the majority element in
an array of integers
Uses the Boyer-Moore majority vote algorithm to find the majority element
(i.e. the element that appears more than {@code n/2} times) in an array of
{@code n} integers. The algorithm will report one of the elements even if
the array contains no majority element. A second pass could be used to
determine whether the element returned is the majority element.
<p>Asymptotic analysis:
<ul>
<li>time_worst=O(n)
<li>space_worst=O(1)
</ul>
@param A an array of {@code n} integers containing a majority element that
appears more than {@code n/2} times
@param A an array of integers
@return the majority element of {@code A}
*/
Integer majorityVote(int[] A) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment