My implementation of some well-known algorithm and comparison with naive approach