deterministic algorithm examples