AlgoDaily: Left-most deepest node in a binary tree

 I just had to do an AlgoDaily problem today. My boyfriend's been moving house and there were holidays and I was doing interviews and writing a project proposal for a Udacity Machine Learning NanoDegree (it's about reinforcement learning and computational neuroscience and you can check it out here: https://github.com/mariakesa/UdacityMachineLearningEngineerNanoDegree/blob/main/proposal.pdf). My boyfriend said today that if you pick up exercise and quit after two weeks you will reap no health benefits, but if you make it a habit then those small jogs that you do thrice a week will accumulate into a considerable health benefit. So it is with these little programming exercises.

 I am disentangling a complex image registration algorithm (and writing a blog post about it) at work and today I thought about it, hey it's just a collection of sub-algorithms and each little piece is not unlike in complexity to the little AlgoDaily exercises. It's all about decomposing complex tasks into little task syllables. It's how you can handle complexity-- divide and conquer. 

Anyway, today's task was about finding the leftmost bottom node in a binary search tree. NB! You can't always go left, because sometimes you have to take a right to get to a lower left:-D I solved it (with the help of my hacker friend) by doing breadth first search iteratively with a queue. BFS is good for this problem because it searches the tree in "levels" while DFS sometimes backtracks which makes it difficult to keep track of the best node so far. 

Here's the solution: https://github.com/mariakesa/Algorithms/blob/master/AlgoDaily/AlgorithmsPractice.ipynb

Kommentaarid