deterministic algorithm

deterministic algorithm