Microsoft Interview Question

Write and explain an algorithm in a language that you choose.