Completed the Binary Search Tree

THINGS I’VE WORKED ON/COMPLETED…
I completed the Binary Search Tree.
Started Knights Travails.
ISSUES I HAD…
BST
I needed a separate function to sort the new array for the rebalance method. I initially tried to do this using a function within the method, but was having some scope problems and then I realised I could just create a ‘helper’ method, which seemed simpler and more importantly, which worked.
When I went to test everything at the end, my Pre, In and postOrder mthods were suddenly not working correctly. I realised this only happened when I called more than one of those methods, so I decided to print the trees befores and after each method to see what (if anything) was being distorted. In the end, this was due to an incorrect return value in my methods, which was returning undefineds instead of null and so I changed the return from ‘return’ to ‘return null’, which fixed everything.
I realised I had not implemented the callbacks in the Pre, In and postOrder methods correctly at all - I had been ‘calling back’ a separate method in my class. Why? Probably a combination of not refreshing my knowledge of callbacks and not having used them much, if at all. This was obviously a big mistake - I should have taken the time to look into this further when I initially implemented it.
KNIGHTS TRAVAILS
Knights Travails - some parts of the reading were not going into my head clearly (adjacency lists and adjaceny matrices) - I re-read the next day and it made sense. This often happens when reading new material in the course.
After some reading and recommendations, I decided I would follow the Khan academy material and challenge based on Bread First Search, but I then changed my mind and decided to just try to see what I can put together myself first. When it comes to the actual BFS logic, I may refer to the Khan material again.
I have been very slow starting this as was not/still am not entirely sure how to approach the whole thing, but I am trying to get some of the elements coded up (the chessBoard and the appropriate data structure to represent the Knight and relevant information), as I am hoping that if I get some of this in place, the approach might become clearer to me.
THINGS THAT WENT WELL…
Finishing BST.
Although I have never used AI to write actual code (and I don’t plan to as long as I am trying to learn to code), I have started using it this week to fix technical issues I had (with VS code for example) and also, to answer questions I had about various coding concepts; I found the AI tools extremely beneficial for these purposes.
THINGS I’VE LEARNT/NEED TO IMPROVE ON…
The error I made with the callback was actually a great learning experience, because it proved that I did not really have a firm grasp of callbacks (my own fault for not taking enough time to practice it/read up on it) and by fixing the problem, I actually learnt a lot.
OTHER…
I had a number of issues with json files and VS code which took quite a lot of time to fix.
PLAN FOR THE UPCOMING WEEK…
I will be working on Knights Travails.
Subscribe to my newsletter
Read articles from CodeCara directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
