Algorithm exercises