Challenging question find if there is an element repeating himself n/k times

Posted by gleb-pendler on Stack Overflow See other posts from Stack Overflow or by gleb-pendler
Published on 2010-06-08T20:48:49Z Indexed on 2010/06/08 20:52 UTC
Read the original article Hit count: 215

Filed under:
|
|
|

here how it's goes:

You have an array size n and a constant k (whatever) you can assume the the array of int type tho it kind be of whatever type but just for the clearane let assume it's an integer.

Describe an algorithm that finds if there is an element/s that repeat itself at least n/k times... if there is return one - do it in linear time running O(n)

Imortent: now the catch do this algorithm or even pseuo-code using a constant usage of memory and running over the array only TWICE!!!

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about homework