POJ 3050 Hopscotch

There is a 5 * 5 array filled with integers. You can only go up, down, left and right. You can start on any point in the array and can only move 5 times. Therefore, you will get 6 integers. Find the number of distinct integers you can constructed. Link: http://poj.org/problem?id=3050 Solution I use a set to avoid same sequences. Since there are only 6 steps and the array is only 5*5, dfs each point, add into the set.

POJ 3187 Backward Digits Sums

There are 1 to $$N$$ digits ($$1\le N \le 10$$) in certain order. Add adjacent numbers together to get the next line, until the there is only one number left.(Just like Pascal’s triangle) For example, there are 3 integers: $$1, 2, 3$$ $$3, 5$$ $$8$$ So, given $$N$$ and the final sum, find the lexicographically least ordering of integers. Link: http://poj.org/problem?id=3187 Notes: Be aware of that the question is asking 1 to $$N$$ digits, so we don’t have to test all possible permutations from 1 to 10.

Binary Tree

Binary tree is called so because of its shape. It’s like a tree, it have leaves and a root. In computer science, the “tree” is usually upside down, the root at the top and leaves grow below it. It is binary so it every node only can have 0, 1 or 2 leaves. Terminologies Leaf Node The node do NOT have any child nodes. Inner Node The Node between the leaf node and the root.