Amazon interview question

Array shifting, sorting, recursion, and trees.