Hey,
ich hab folgende Aufgabe im Studium und weiß nichts recht damit anzufangen:
An element of an array A is a winner if it is stored in A more than length(A)/2 times. Clearly, an array does not necessarily have a winner.
Suppose you can perform comparisons on the elements of the array. The comparison test can give 3 possible outcomes: <, >, = .
Using SELECT find a Winner in O(n) comparisons. Make sure your algorithm correctly determines whether a winner exists.
Ich steh da ziemlich auf dem schlauch. Kann mir vielleicht jemand weiterhelfen? Danke im Voraus.
lg