Range Sum of BST

Good morning! Yesterday my wife and I grilled some beef, made French fries in an iron pan in the grill and topped it off with some grilled asparagus. We spend the rest of the day making some profiteroles. We explored using a different flower in order for the pastry to not rise much (our oldest son prefers them that way), but the flavor changed. My wife is in charge of the pastry cream which she made. When all was set and done we delivered them to my son who lives in a different suburb of the Twin Cities of Minneapolis and St. Paul.

While driving back, my wife and I were talking about how the social life of people has changed since the COVID-19 pandemic started. We and most of the people when know, are taking care of themselves and others by following social distancing rules, wearing masks and gloves and lately even wearing goggles. We are very tired of the pandemic, but like most people, we need to continue to observer the rules until vaccines are approved and become available to all. Continue reading “Range Sum of BST”

Shuffle Array – Java

Every work day when quitting time approaches (around 05:00 PM) I check my to-do list. One thing I had for the day was to check is there is a method in a Java class to shuffle the contents of an array. This is a nice mechanism to have in your toolbox. For example, if you want to load a binary tree search (BST) and the data is sorted, the tree will basically load like a linked list. In a BST you can typically find an element in O(log(n)). But if the elements were inserted sorted, the search is performed in O(n) which is slower than O(log(n)). In such cases you can just shuffle the array and then load the BST. Continue reading “Shuffle Array – Java”

BST Operations

It is a Saturday morning in the Twin Cities of Minneapolis and St. Paul. It rained last night. Hopefully the day will be dry. I am planning on cooking chicken wings in the gas grill on the deck. There are not too many warm days left to use the grill this season.

A few days ago I started reading chapter four from “Cracking the Coding Interview” by Gayle Laakmann McDowell. For some reason I diverted to adding and deleting values from a BST. I always like to find how others approached the problem. I started watching some videos and reading some articles on the web. Several of the algorithms were convoluted and they seem to fail with different values. So I decided to write some code which seems to work as expected. If you give it a try and find issues please let me know. Continue reading “BST Operations”

BST Search

It is a Saturday in August in the Twin Cities of Minneapolis and St. Paul and it is going to be a warm and humid day. My wife is out shopping with a friend and I am in my home office having fun with Binary Search Trees (BSTs).

This past week I was talking with a software engineer about coding interviews. I have mixed thoughts about them. Not sure about their value as far as finding out if a person is able to develop quality software. Allow me to describe the process which seems to be quite spread around the industry.

The candidate is interviewed by multiple technical people. The idea is to present the candidate with a set of one or more programming problems and expect working code written on a whiteboard. Typically the programming language of choice is up to the candidate. Continue reading “BST Search”

Distance Between Nodes in a BST

I was looking at several articles on binary trees and thought it would be a good opportunity to write some Java code in order to refresh knowledge of binary trees, in particular with BSTs (Binary Search Trees). You never know what new things are out there.

I am not sure if most system architects and software developers run into the same situation as I do. I have learned and worked with many data structures and programming languages. I do not work with every single data structure often enough that I recall how to implement or use it as far as all the associated methods and functions. I have a reasonable understanding of most data structures and I can get back on the horse rather quickly. Continue reading “Distance Between Nodes in a BST”