I always meant to start a blog where I share what I’ve learned in computer science and other parts of my life. Well, now I’m just going to do it because one thing I’ve learned this week is you can’t do anything if you don’t start doing something.
Back in high school, my CS teacher always warned that the hardest thing we would ever do in his class was delete from a binary search tree.
After six whole months of hyping up this super difficult task, I completed the assignment about 15 minutes after it was assigned wondering what the big fuss was about. Not only was deleting from a binary tree exceedingly simple to understand, it was trivial to implement.
I just chalked it up to having a really good teacher; Dr. Halbert was the best teacher I’ve ever had, and I will forever be thankful for what he has taught me (along with Mrs. Waterman who also helped form me into the young programmer that I am today).
Well this Tuesday, I learned of an even easier way to delete from a Binary Search tree from my Data Structures and Algorithms professor. She called it a lazy deletion, but it is essentially a logical deletion.
Instead of removing the node from the tree itself, a lazy deletion is marking the node as deleted by utilizing a boolean flag in the node. When searching, printing, or adding to the tree, you can check this flag to see if the node is logically deleted or not. If it is, just ignore it (or flip the flag if you are trying to add the value that has been logically deleted).
While this type of tree is easy to implement, it has very few performance benefits. Your tree will take up more space in memory because you will be holding onto nodes that a regular tree would have just deleted. Searching, adding, and transversal will take more time because you have to check if each node is deleted or not and you’ll have to go through nodes that wouldn’t exist at all in other tress.
This was an interesting thing I learned. Wednesday, I was trying to drive to work. I got into my car and turned it on. Nothing unusually, so I put the car into gear and started backing out of my driveway.
ding! ding! ding!
I look down at my dash and see that my trunk is open. “How weird,” I though, “I am positive I didn’t open my trunk last night.” After getting out of my car to shut the trunk, I settle back into the driver’s seat and put the car back into gear.
The trunk opens again. “Yikes!” I was already running late for work. After trying to get my trunk to stay closed for half an hour, I just called into work telling them I wouldn’t be able to make it.
“I’m sorry, I can’t come in today. This is going to sound like the most bullshit excuse in the world, but my trunk legitimately will not stay closed…”
The above is a text message I sent to my manager. I didn’t expect him to believe me, but I let him know the reason anyways. I gave up and went back into the house to work on some of my schoolwork.
At work, I’m working with a Spring Boot App, and I am using STS as my IDE in order to write the code and run the application. However, I am using Visual Studio Code purely to do my git commands.
I am perfectly capable of using the terminal. In fact, I did use the terminal at first, but I had to open up Visual Studio Code in order to edit the .sql files we had because STS can’t open them for some unknown reason.
Since I had VSC open, I figured I might as well flip over to the git tab in order to do my commits. Well, now VSC is my dedicated git tool because it’s is perfect for checking what changes I’ve made to my file with the working tree view. On top of that, it has some pretty solid merge conflict tools.