174
правки
Изменения
→Псевдокод
findMajorityElement(a, N, K)
'''while ''' true
candidate = a[random(N)]
count = 0
'''for ''' i = 0 '''to ''' N - 1 '''if ''' a[i] == candidate
count++
'''if ''' count > N / K '''return ''' candidate
=== Доказательство ===