[Algorithm] Level Order Binary Tree Traversal (Iterative and Recursive)

Traverse a binary tree in level order is intuitive. We can initialize a queue and add elements. Every cycle you need to print out the nodes in the queue, and add their children to queue, until queue is empty. However, since the recursive solution for pre-order, in-order, and post-order traverse is quite easy, I wonder if level traverse is also … Read more…

[LeetCode] Longest Valid Parentheses

Got stuck in this problem for one hour. I was trying to use a variable left to count the left parentheses. However, we should not only count the number of them, but also the position of them. Then we need to use stack. There is a very elegant solution here (In Java): http://rleetcode.blogspot.com/2014/01/longest-valid-parentheses.html This problem really cost me so much time. So … Read more…

Java Problem: java.lang.NoSuchMethodError

I was doing a project to implement TCP over UDP. I used makefile to compile these java files easily. After editing and compiling several times, the Server became unavailable in terminal. It shows just like below.

However, it works well in Eclipse. I tried it in ubuntu and it also works. I have no idea about this problem. But … Read more…

Hello world!

When I want to learn a programming language, most tutorials and books often let me start with “Hello world” programs.

So I start this blog with “Hello world”, which is also a new start of graduate student life.