Wednesday, December 5, 2012

Time to wrap up

Time flies so fast! Three months has passed and it is time say goodbye!

Before leaving I just want to check what I have learned in that course:

Induction (mathematical, complete, structural and WOP)

Time Complexity for recursion (involving closed form, Master Theorem, etc)

Correctness proof of a program (formally check whether an algorithm is correct)

Automata theory (regex, DFSA, NFSA)

So far I can know lots of things about an algorithm by using what I have learned

from this course. Also the formal language section guides me to know the very

basic concepts about a programming language.



Regards

Problem-solving episode

I found an interesting math problem to share.

This problem is a fundamental illustration of mathematical induction, but it is still a bit tricky.

"tromino" is an L-shaped object consisting of three squares of the same size.
Consider a 2n 2n square. If one of the smaller squares is removed from a corner of the large square, the the resulting region can be completely covered by trominos.

I will try to use Polya's method.

Understanding the problem
Known: the square (size, shape) need to be covered
Unknown: I must discover whether trominos can cover that square

Devising a plan
It seems a bit difficult at first glance, but I notice that the problem deals with a natural number n, so the idea of induction may help.


Proof
I carry out my plan using mathematical induction.
Base Case: when n = 1, the region after removal is exactly a tromino. So the theorem holds when n = 1


Induction Step: suppose when n = k, the theorem holds, so the 2^k X 2^k square region after removing the corner can be covered by trominos. Let me examine the 2^k+1 X 2^k+1 square. It should be like this:


Then we can put a tromino in the middle


















And we can obverse the region can be divided into four 2^k X 2^k medium-sized regions as illustrated:
















By induction hypothesis, those four regions can be covered by trominos, and the three small blank squares can be covered by one tromino, so the whole region can be covered by trominos as well. so the theorem holds for n = k + 1. By MI, we know the resulting region can always be covered by trominos.

Looking back
After looking back, we find that without a plan of using induction, it will be very difficult to come up with a good idea to strictly solve this problem. So it is a good idea to use Polya's method when solving tricky problems.

Sunday, December 2, 2012

Formal Language and Automata

Formal language is largely different from the previous chapters, except the frequent use of induction. DFSA is a way to describe a language, and it is also of great fun because it reminds me of the puzzles I solved when I was in primary school. I think devising a DFSA is not difficult, because what you need to do is simply draw "0" lines and "1" lines and connect circles with those lines. But proving DFSA is a different story, for you must follow the format in the course notes like finding state invariants. Also problems related to DFSA can be very hard sometimes, the question 1 in Assignment 3 is not funny at all. I spent almost a whole week on that problem and finally got a right answer before the due time. I think automata will be a important part for the final exam, so I must work hard on that section. And no matter how hard the final exam would be, I must stay calm (just as the guy below) and try my best to conquer that.