Saturday, April 8, 2017

H tree - a talk about training

April 8, 2017

H-tree is constructed by layers, next layer will start from four corners of H as centers, and the size will be smaller one.

Problem statement - Read this Java implementation from princinton.edu - H-Tree

Introduction


Julia started to study mocking interview, and see how many things she should work on. Instead of writing a simple recursion version, Julia chose to write a BFS solution using queue. It is a good practice and also showed her passion to write a solution and learned from her mistakes on the mocking.

Training review 


Here is the C# code she wrote in mocking 30 minutes.

Spent over one hour to make the C# code bug-free and code readable.
Also, line 83, correct the calculation of length using square root 2. C# code is here.
Again, make variable names shortest, line 90 - 95. C# code is here.
Things learned in the mocking experience:

1. Julia thought out loud using queue to implement the solution, the interviewer gave out hints to use stack, depth first search;

2. Julia thought about using stack but forgot about recursive function is a natural stack; in other words, using simple recursive function call.

BFS/ DFS difference - DFS can use recursive call, internal stack.

3. Using Queue will work, but the depth should be pushed with queue with center node's information.

4. It is important to stay calm, write instructional code.

Highlight of good/ bad things in mocking experience
(the C# code in mocking experience, good thing is highlighted using brown color, bugs and mistakes are in yellow color):

0. line 1 - 12 work on a H-tree understanding, write a small test case. Understand the H-Tree draw lines, and also requirement of starting length and depth.
1. line 18 - 27, write an internal class Node, define two variables, node and depth.
2. line 22 - 26, Write public constructor of Node class to set up a new node
3.  line 30, Function name is very good - DrawHTreeToDepthUsingBFS
4.  line 30, Function DrawHTreeToDepthUsingBFS's design flaw - return argument should be IList<Node>, not IList<Tuple<int,int>>, missing depth information. Depth information is needed to calculate length of H-Tree.
5. line 29, time complexity is correct? Need to write a recurrence formula first, and then time complexity.
6. line 34 - 37, depth <= 0 will be better
6B. line 39 - syntax error - duplicate new Node(
7. line 41 - Enqueue method - input argument should be variable - node
8. line 43 - adjustLength = depth;  should be adjustLength = startLength, mix length and depth two variables
9. line 57 - 64, should add checking of depth, add H-tree is conditional - major issue
10. line 57 - 60, 4 corners of H, new center node's x, y values are not correct.


Julia, you have to learn from tennis training coach - Janko Tipsarevic - train yourself to be able to write a bug-free, very instructional code. When in real matches, a lot of emotions are mixed with pressures, will to win, anxiety and pressure, you will not notice those mistakes and errors.

Next time, try to write much more slowly, make sure that every line of code is bug-free, syntax ok, no duplicate code.

Through this mocking experience, Julia learned that she still had to practice more on BFS algorithm using Queue, Julia was very comfortable to write and understood that either BFS/ DFS will work out with no problem.

Julia did not have time to go over the code because the peer did not want to wait after 30 minutes.

Also, Julia did not come out using recursive function to write, even after hints. Julia was nervous because she asked help to understand H-Tree with the test case.

Julia likes to show her rigor training through asking over 30 algorithm questions she got from codereview.stackexchange.com code reviews last 6 months, she is able to write perfect and most modern C# code.

Actionable Items


1. Learn to interview people with different background, technical strength; Learn to write down notes and give out good advice.

2. Do not book more than one mocking a time.

3. Try to improve score of problem solving skills, ratings are low 3 of 7.

4. Take it slow, write instructional code, avoid duplicate code. Using meaningful variable name, function name.


5. Go through up-and-downs through mocking experience, learn to appreciate the time of peer. Try to
manage better the 30 minutes time. Avoid lengthy discussion, be very diplomatic, writing is most important part to show good skills and analysis.

6. Work on a small test case first, this part is very good warmup and prevent bugs in writing and design correctly first time.

7. Make the mocking experience more structured, write down a small test case to understand the problem, show some analysis, and talk about design and choices I may have.

8. All issues Julia had on real experience are reproduced in this mocking experience. Julia, practice more. Do not give up. Write down your feelings, and issues. You will sort it out later.

Follow up 


June 19, 2017 mocking third time. Very short and clean, using recursive function, using meaningful name. C# practice is here.

No comments:

Post a Comment