Showing posts with label Catalan number. Show all posts
Showing posts with label Catalan number. Show all posts

Saturday, January 27, 2018

Catalan number

January 27, 2018


Introduction


It is another mock interview and I had to work on the algorithm related to Catalan number. This time the peer dropped a hint, do not need to use previous row, only use current row and then save the space. I wrote the code based on his advice.

Algorithm 


Here is the code based on the advice from the peer.


Sunday, January 21, 2018

Catalan number

January 21, 2018

Introduction


It was another 10:00 PM mock interview again. I had to write the algorithm called catalan number. After I finished coding, the peer asked me if I can make an array copy instead of writing a for loop. So I looked up Array.Copy and then used it first time in mock interview.

Code review


Here is the C# code.

Wednesday, January 17, 2018

Catalan number

January 17, 2018

Introduction



It is the algorithm peer gave it to me for a test since he had the algorithm the day before. I had to work on the algorithm called Catalan number on January 15, 2018, 10:00 mock interview. I explained the algorithm to the peer, and also showed last 3 practices.

Will write down the discussion of the algorithm here later.

Wednesday, November 8, 2017

Catalan number

Nov. 8, 2017

I will write something here about the algorithm. Will come back very soon.

Transcript is here. I will write down the story later on.



Follow up 


January 17, 2018

It is the advantage of mock interview. I learned the algorithm after I had practive over a few times. But some one with very good talent on algorithm just showed me his way to solve the problem.

The peer just wrote down a 5 x 5 matrix using x to reprent each number, and then he went over the first row, to start from the first row from left to right, write down one for each column; and then go to next row, and then quickly from left to right, add the value underneath and left neighbor in the same row. He finished the process in less than 5 minutes, and then showed me the calculation of value for n = 4.

It is the best coaching experience for me. I learn that some one is much better than me to understand the algorithm. And after mock interview, the peer told me that he got some training in competitive programming before.

Tuesday, September 12, 2017

Catalan number (II)

Sept. 12, 2017

Introduction


It is the classical algorithm to calculate the catalan number. My last practice is documented here. It is very challenge to work with the peer and I ran into the index out of range error in my first writing, and then I modified the code, and argued that first row and first column should exclude from the double for loop, and discuss first row and first column separately.

I need to work on the algorithm problem solving, need to look into the feedback.

Algorithm practice 


C# practice code is here which passes all test cases. 


From the above feedback, I did not communicate very well this time. Need to figure out how to clarify of my answers and line of reasoning. 


Follow up 


January 17, 2018

It is the first time I know how to review my own past practice. Missing the analysis of the algorithm writing is a big issue for me now, production ready code should be written with some analysis and time complexity and space complexity. I have to write down the algorithm, and constraints, and the requirement, what problem to solve. And also my analysis of the problem, solve it on a simple example, go over the example to explain to the peer first. And make sure that the peer understands the problem.

From the transcript of the practice, I did not write any analysis of the algorithm. That is not good practice at all.

The peer did complain and I should have let peer know the algorithm and how to solve it first using a simple example. 

Monday, May 8, 2017

Catalan number wiki article

May 8, 2017

Introduction


It is very interesting to study catalan number again. This time Julia likes to go over the wiki article and then try to get better understanding the algorithm.

Tonight she had mocking experience to learn an algorithm - find maximum number of path from bottom-left corner to top-right corner, and do not cross the diagonal line. In other words, always stay underneath the diagonal line. She learned that the algorithm is similar to Catalan number.

Catalan number