Sunday, January 21, 2018

H tree algorithm

January 21, 2018

Introduction


It is most classical algorithm of recursive function called H-Tree algorithm. I had a mock interview at 12:00 pm, so I had chance to learn python and also learn from the peer how to do the analysis and write code.

Code review 


Here is the python code with the analysis. The peer wrote very good analysis and showed me how depth first search is structured. Later on, I made the comment and asked what is your base case. And then he add the base case for depth = 0, and then I asked him to remove line 20: if depth >= 0 and let it fall through the base case to take care of it.

The peer had math Olympiad contest experience, I like his analysis in terms of time complexity from line 26 to line 31.

No comments:

Post a Comment