Finished the BST deleteValue method...

CodeCaraCodeCara
3 min read

THINGS I’VE WORKED ON/COMPLETED…

I finished the BST deleteValue method.

ISSUES I HAD…

I think I started out well with the delete method, but later learnt that I should have been more methodical in how I approached it. Leaf nodes and nodes with single children were straightforward, but there were a futher few ‘sub-possibilites’ within deleting a node with two children (e.g. does the root’s right node lead to further smaller values and do those smaller values have bigger or small ‘sub-values’ attached, which could occur due to the way the insert method was set up).

I was trying to solve the two-node problem within one block of code and even though parts of it were working, it was getting very confusing, so I decided to separate out those sub-problems to see if I could get it working more quickly. I did get it working in the end, but if I were to do it again, I would absolutely try to write pseudocode first as it’s easy to lose track of the aim of the steps when coding within following a pseudocode outline, particulalry in a case like this, where there are lots of possibilities to consider.

My code could probably also be refined, but as I have been working through this project extremely slowly, I have decided to just leave it as it is.

THINGS THAT WENT WELL…

In spite of not having ‘pseudocoded’ it, I think I did a better job of writing the delete method than the insert method as I was more methodical with it, trying little pieces of code here and there and moving through it step-by-step. I think that with insert method, it seemed like it should be easy and I somehow thought I should be able to look at it and know how to do it, rather than putting it together piece-by-piece.

I spent some time trying to go through the call stack and understand the recursive code better. I am still far from being an expert, but I am certainly less ‘afraid’ of it than I was before.

THINGS I’VE LEARNT/NEED TO IMPROVE ON…

Recursion can still be challenging for me, but moving through it slowly and methodically helps a lot. I could probably benefit from practising further recursion problems to become more comfortable with it.

For tricky problems especially, such as the delete method in the BST, I absolutely need to train myself to write and follow full pseudocode, as I would probably save myself time in the long run.

OTHER…

n/a

PLAN FOR THE UPCOMING WEEK…

I want to say that I will finish BST (again), but I think the remaining methods may be complex. I will aim to finish the next three methods at least and more if I can.

0
Subscribe to my newsletter

Read articles from CodeCara directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

CodeCara
CodeCara