Binary Tree Pruning

Have an on-line call at 02:30 PM. I believe I am well prepared. Will see how it goes.

Earlier today I selected LeetCode 814 Binary Tree Pruning problem.

We are given the head node root of a binary tree, 
where additionally every node's value is either a 0 or a 1.

Return the same tree where every subtree (of the given tree) 
not containing a 1 has been removed.

(Recall that the subtree of a node X is X, plus every node that is a descendant of X.)

Note:

o The binary tree will have at most 200 nodes.
o The value of each node will only be 0 or 1.

We are given a binary tree whose nodes are holding 0 or 1 as value. We need to prune the BT as described in the requirements. If you are interested in this problem please navigate to the LeetCode web site and read the actual requirements. In addition LeetCode has a set of test cases.

In this post we will solve the problem using the Java programming language on a Windows 10 computer using the VSCode IDE. You can use any of the languages supported by LeetCode and solve the problem on the LeetCode side with the IDE provided. Continue reading “Binary Tree Pruning”

Sort the Matrix Diagonally in Java

Good morning. It is Sunday again. I woke up around 05:00 AM and the outside temperature was -17 F. We are finally experiencing cold winter days in the Twin Cities of Minneapolis and St. Paul. An added bonus for football fans is that today is Super Bowl LV. My wife and I are not sports fans. We like to bike and walk and occasionally scuba dive. Up to a couple years ago we would watch the half time show. We so not watch TV any more. Perhaps we will find the half time show on YouTube. Continue reading “Sort the Matrix Diagonally in Java”

Dot Product of Two Sparse Vectors in Java

It is Thursday and for a while it was snowing. We received a couple inches of fresh snow. Will see what the weather brings us this weekend. I believe Sunday is going to be the coldest day of this winter so far. We might hit -20F. That said; it appears that the weather forecast changes multiple times a day.

Today my wife was not at home for lunch. I prepare toasts with avocado. Put a dab of butter on a couple slices of ciabatta bread, place them on a cooking sheet and into the oven (set at 400F) they went for about seven minutes. While that was going on, I took out from the freezer a Butter Chicken with Basmati rice tray from Trader Joe’s. As soon as the toast was done I swapped the tray with the chicken. The instructions called for 25 minutes so I consumed the toast with avocado and went back to my office. Continue reading “Dot Product of Two Sparse Vectors in Java”

Alien Dictionary

It is Thursday morning and it has been a long week at work. Apparently we have been experiencing lots of issues with our cloud platform. It seems that the storage server works fine when running on bare metal, but it experiences network related issues when running on virtual machines. We are currently looking at what might be causing the issues with the stack in VMs.

Before we start dealing with the problem at hand, I want to mention that I have a few books on algorithms. Like most people, I like to avoid spending money when I can get the same or similar results by doing a web search and reading the resulting material. I am a member of the ACM. I have access some of O’Reilly materials on-line. I believe both the books and videos have helped me locate quality information and are planning on continuing to use it. Continue reading “Alien Dictionary”

Verifying an Alien Dictionary

Running tests and verifying code is the work order for the day. I have a Command Line Interface (CLI) for the storage server sending the equivalent of ping requests but at the application level. Since I started the test at around 09:30 AM today it has processed so far 1,190,833 requests and associated responses without a single warning or error entry in the log files. I will stop the test at the end of the work day.

Earlier today I was going to work on a different LeetCode problem, but when I did a search on “alien” two problems were selected. Since one was flagged Easy and the second Hard, I thought some items might apply from the first one to the second problem. Hopefully it would not take too long to solve the Easy problem so I could tackle the Hard after the end of the workday. Boy was I mistaken. Continue reading “Verifying an Alien Dictionary”

Can you solve it? Java Solution

Good morning. Hope you are doing well. It is a dark, foggy and cold morning in the Twin Cities of Minneapolis and St. Paul. I woke up around 05:00 AM. I finished reading the article Does Facebook Use Sensitive Data for Advertising Purposes? article in the Communications of the ACM magazine. I though the article was interesting. Apparently Facebook has a set of several thousand categories of which up to 1000 can be applied to each user. Not sure if there is an opt out setting. The authors of the paper suggested a tool that can be used in a couple browsers to check and delete the advertising labels assigned to your account. Continue reading “Can you solve it? Java Solution”

Design Tic-Tac-Toe in Java

It is about quitting time for today Friday January 15, 2021. Due to the snow storm the cleaning lady called to postpone for today. She will be here Monday morning. I guess different cities received different amounts of snow. I am not sure how much fresh snow fell during this storm. My guess is that we received between 2 to 3 inches. That said; the service that cleans our driveway and paths was here around 01:00 PM.

For lunch my wife prepared a Chinese meal with products from Trader Joe’s. It was quite good taking into consideration that it came from a super market. It took my wife about 30 minutes to prepare lunch from start to finish. Continue reading “Design Tic-Tac-Toe in Java”

Reverse Operations Revisited

Yesterday morning I attended a one hour webinar sponsored by the Association for Computing Machinery titled ACM Queue Case Study Q&A: Always-On Time-Series Database. It was very interesting. There was no presentation segment. There were only questions. The presenter, Theo Schlossnagle which is the founder of Circonus was very eloquent and seems very versed in the technology and their products.

During the conference I made several notes and searched for several topics that I found of interest. I will be reading the associated pages later this week. Continue reading “Reverse Operations Revisited”

Contains Duplicate

Good day! It is Thursday morning and it is a typical gloomy and cold winter day in the Twin Cities of Minneapolis and St. Paul. The good thing is that is Thursday. One more day to go to and we can start enjoying the weekend. For most of us the weekend will be 2-days long. It is different from the past two weekends in which most people enjoyed 3 or 4 days off work.

Due to COVID-19 my wife and I just leave home for grocery shopping and healthcare appoints when needed. The good thing is that vaccination has started in the USA and hopefully in a few more months most of us will be vaccinated and can start getting back to normal. We all will see what happens. Continue reading “Contains Duplicate”

Design HashMap

It seems like I lost track of time this week. It is early morning on Wednesday December 23, 2020 and the weather forecast calls for 8 inches of fresh snow and a low of -1 F. This would be the first time this season that we experience subzero temperatures in the city where I live.

We always should look at the positive side of things. With the snow less people will be out and about which is good for restraining new COVID-19 infections. In addition, the days are starting to get longer. We will not be able to notice it for a few weeks, but it is happening.

I brought in from the refrigerator we keep in the garage, a 24 lbs. turkey, which we will roast tomorrow morning and will consume it mostly as sandwiches. Given that it will be my wife and I consuming this bird, it will last for several weeks. We will freeze most of it and consume it as needed. Continue reading “Design HashMap”