Friday, December 22, 2017

Recursive function practice

Dec. 22, 2017

Introduction


It was another 10:00 PM mock interview. I had one algorithm to work on, write a recursive function.

Here is my C# practice.


Blog written in November, 2017, here is the link.

Blog written in June, 2017, here is the link.


Structure of depth first search


After I practice depth first search with so many peers, until this November, 2017, I start to learn that it is very important to write the algorithm in a very structured way.

First, I should check edge case to prevent the run-time exception,and then I like to write a base case. What is most simple task I can complete to do the work. For the above algorithm, it is the node without any children. Every one can write one line of code to figure out the minimum path. There is only one choice, and one value, just return the value.

So next step is to ask all your children nodes to do the same task for you, and then you only have to find the minimum one, and add current node's value to it.

To peer with so many talent programmers in the world, I have chance to learn the recursive algorithm in most fashion ways. Because if I do perform very well, the peer will give me extra time to share some tips, and also I have time to learn a new person, and get connected with another hard working person.

Analysis of the algorithm


I like to write some review about my practice in November. The peer found the bug in my code. Usually it also tells me that I should work on the analysis of the algorithm. Do not let the problem come to the bug, I should catch it in the analysis of the algorithm.


Statistics


Past practice on the algorithm last 5 rounds:
.1107 12/21, .sh 9/14, .mp 7/30, .ca 6/14, .fl 5/7

No comments:

Post a Comment