It's a simulation problem. You must have knowledge of following algorithms in order to solve this problem: