Implement Trie (Prefix Tree)

It is Wednesday morning and the cleaning crew is at our place making lots of noise. Typically they show up on Fridays but due to personal issues they requested to move the appointment. They do an excellent job. If you live in the Twin Cities of Minneapolis and St. Paul and are in need of a good cleaning service, please let me know. I will pass your information so you can get in touch with them or vice versa. I value privacy. Continue reading “Implement Trie (Prefix Tree)”

Making a Larger Island – Java

Hello everybody. I have been very busy looking into a problem at work which seemed to be caused by sockets. It seems that the issue might be related to encryption. Have a couple tests that should verify my assumption. Will let you know if that pan out.

Today in the Twin Cities of Minneapolis and St. Paul we woke up with a temperature above 0F (7F). Looking at the weather forecast it seems like the sub zero temperatures will be a thing of the past in a day or so. Weather forecasts are based on models and models in general are far from perfect, but they provide us with an idea of what might happen in the specified future. Continue reading “Making a Larger Island – Java”

Binary Tree Maximum Path

It is a Saturday morning in what has been forecasted so far as the coldest weekend of this winter season in the Twin Cities of Minneapolis and St. Paul. I woke up this morning around 05:00 AM and the temperature was at -8F. It seems like it will go up a few degrees during the day until it starts dropping down in the mid afternoon. On Sunday we should we waking up to a balmy -20F. My wife and I did our grocery shopping for the week yesterday evening. We are not planning on leaving home this weekend.

Earlier today I read Cybersecurity: Is it Worse than We Think? authored by Chris Maurer, Kevin Kim, Dan J Kim, and Leon Allan Kappelman in the latest Communications of the ACM magazine. The article is interesting, but there was a sentence that called my attention the most. The sentence follows:

“While they [organizations] may be saying the right things in public to satisfy investors, underwriters, and customers, there is an apparent lack of urgency in promoting a truly resilient and secure organization”.

You need to read the article to fully understand the meaning. In my opinion addressing cyber threats requires an investment which has no obvious ROI. Given that the word on the street is that it is not if but when a company will be hacked, then by doing as little as possible and carrying insurance to cover the cost of a breach seems the best approach. Of course if you ask a customer whose PID has been published in the dark web, the sentiments might be quite different. Continue reading “Binary Tree Maximum Path”

Flatten a Linked List in Java

This morning I read the article Kode Vicious Kabin Fever on Viewpoints in the latest copy of the Communications magazine from the ACM. I enjoyed reading the article. All of the points with the only exception to exercise, due to winter and the COVID-19 pandemic, with very few additions, are what I have been doing for over a decade. If you have time and are able to access the article, it contains good advice and it can be read in a few minutes.

Most problems in this blog come from companies such as HackerRank or LeetCode just to mention a few. In this case, the problem came up while chatting with a software engineer. I have developed the requirements as accurate as I can recall. I will be using the Java programming language on a Windows 10 machine using the VSCode IDE. Of course you can generate a solution in a different platform using a different IDE. Continue reading “Flatten a Linked List in Java”

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”

All Elements in Two Binary Search Trees

The temperature in the Twin Cities of Minneapolis and St. Paul continues to oscillate between negative and positive values in the Fahrenheit scale. The good thing is that we are around mid February. This year spring starts Saturday March 20. That is about 6 to 7 weeks from today. Continue reading “All Elements in Two Binary Search Trees”

Find a Corresponding Node of a Binary Tree in a Clone of That Tree

It is past 06:00 PM CST in the Twin Cities of Minneapolis and St. Paul. I am quite tired and it is only Tuesday. Hope your week is going smoother than mine.

Earlier in the day I read the article “Let’s Not Dumb Down the History of Computer Science” by Donald E. Knuth, Len Shustek in Communications of the ACM, February 2021, Vol. 64 No. 2, Pages 33-35. If you have trouble accessing the article then you should be able to watch “Stanford Lecture: 2014 Kailath Lecture: Stanford Professor Donald Knuth” on YouTube.

In a nutshell Donald Knuth expresses the need for Computer Science history to be documented. Philosophically speaking I believe he is right on the point. Continue reading “Find a Corresponding Node of a Binary Tree in a Clone of That Tree”

Shuffle an Array in Java

I have mentioned in recent posts that this year the temperature in the Twin Cities of Minneapolis and St. Paul has not dropped down to 0F yet. Well, that is changing this Sunday. It seems that the high temperature for the day will be -6F and the low -20F. The good news is that according to the forecast, the temperature will increase rapidly in the following days.

Last weekend I spend several hours on work stuff. Hopefully the following weekend will be a normal one. Not sure if my wife and I will be venturing out on the forecasted cold. Continue reading “Shuffle an Array in Java”

Shuffle the Array

This morning talking with one of my sons on Skype, I mentioned an article which I rewetted titled “China’s push to control Americans’ health care future”. My wife and I used to watch 60 Minutes every Sunday evening. About a couple years ago we stopped watching TV. It appeared to us that there was not much to watch. I liked the article. I agree with the points presented. To me the best part is the moneys offered to several states in the USA for a Chinese company to be allowed to offer COVID-19 services. My question is:  Where are the funds coming from? Stop for a moment and think about it… OK, now let’s move to a different subject.

Then the pandemic came. With it we started watching more content from Amazon Prime, Netflix and YouTube. In the past year it seems that two or three times Netflix has increased the price for their base tier by $1 each time. Yesterday I read the article “Why I’m canceling Netflix in 2021” which provides some reasons why you should be dropping Netflix. My wife and I seem to always watch YouTube and in addition Netflix or Amazon Prime. In these days we are favoring movies from Amazon Prime. They seem to have a larger and better selection and the service is part of Amazon Prime. Continue reading “Shuffle the Array”

Next Permutation

Good morning! It is an average winter Sunday morning in the Twin Cities of Minneapolis and St. Paul. In about an hour my wife and I will be heading out to go shopping for groceries at the St. Paul Trader Joe’s store.

Yesterday my wife and I made a couple Neapolitan pizzas that were quite close to the original ones. I am not going to go into the ingredients at this time. The technique resides in how the pizza is cooked. In general, in the USA we do not have pizza ovens in our backyards. A pizza brick oven heats up north of 600F which is not possible to achieve in a regular home oven. In addition, the initial transfer of heat, due to the size of the oven, is not possible. So, by reading and watching videos, we ended up with the following set of steps:

1. Preheat oven to 550F (takes about 15 minutes in our convection Thermador oven)
2. Add some olive oil to a large (14 to 15 inch cast iron pan)
3. Carefully place the dough on the cast iron pan
4. Turn on your largest gas burner on your range (we have a Viking with high heating capacity)
5. The first pizza will take about 7 minutes to cook (the following ones will take about 5)
6. Carefully move the pan into the oven
7. Finish cooking the pizza in about 7 to 8 minutes
8. Carefully remove the pan from the oven
9. Move the pizza from the pan to a tray and let it rest for 5 minutes (if you can)
10. Use a cutting wheel to cut 6 slices
11. Enjoy!!!

If you try this cooking technique, please share the experience with others. In general I enjoy reading and experimenting, not only with technical topics and subjects, but in general to improve on life. Continue reading “Next Permutation”