Union Find Java

It is Monday morning. Lots of work associated things for the day so this post will be direct to the point.

As I have previously mentioned, I am in the process of reading Algorithms in C Third Edition Parts 1 – 4 by Robert Sedgewick. I finished the first chapter and wanted to experiment with the content in the book. Yesterday I got VSCode on my machine to compile and execute. I thought I was ready to use the IDE in C. It seems that when I created a new project something did not work. I am currently using the MinGW compiler with VSCode. The issue might be associated with it. I decided that over the next weekend I will remove MinGW and will switch to the Microsoft C/C++ compiler. I do a considerable amount of work using Visual Studio Enterprise 2019 IDE. Have been using Visual Studio for a couple decades and I like it. VSCode is quite similar but yet different. Continue reading “Union Find Java”

Setting Up C in VSCode IDE

It is another Sunday morning in the Twin Cities of Minneapolis and St. Paul. The weather forecast indicated that we would be receiving about 3 inches of fresh snow. It seems that we will be getting about 0.1 inches of new accumulation. Given that today is February 28, in the next couple months we might still get winter storms bringing 6 or more inches each.

This past week I had a very nice and interesting conversation with a Principal Software Architect at one of the largest software companies in the world. It was very educational. I really enjoyed the conversation. One of the things that initially called my attention was when I asked the kind of things he does on a regular basis. He mentioned that he “provides guardrails” among other things. When he mentioned it I was not sure what he meant so I made a note to ask him later. At some point I had a chance to describe what I do and have done. One of the things I mentioned was sets of DLLs that with time I have created with the purpose to help developers use a set of tools to get some routine work done without having to redesign and test code use as a scaffold and be able to concentrate on the task at hand. Among the libraries that I have developed are some that deals with encryption, linked lists (I refer to them as queues), sockets, trees, etc. I was then clarified what “guardrails” refer to. It is the same concept in order help developers produce faster code with fewer bugs. It seems that we are performing some similar tasks. Continue reading “Setting Up C in VSCode IDE”

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”

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”

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”

Encode and Decode TinyURL in Java

It is Sunday morning again. It seems that time is flying by faster than ever. Yesterday I worked all morning (about 6 hours). My daughter in law was going to visit her family and my son had to stay home. They were expecting a delivery and installation of a piece of exercising equipment. The delivery was scheduled between 03:00 PM and 06:00 PM.

Earlier that day I had made some pizza dough. I used to knit the dough by hand. In the past couple years I have switched to using our Kitchenaid mixer. I can take all the ingredients, mix them and put the dough to rise in about 25 minutes. I do it while chatting with my wife during breakfast. She just watches me switch tasks while having yogurt with homemade granola and warm milk with a triple espresso. We both like to drink coffee. Continue reading “Encode and Decode TinyURL 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”

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”

Minimum Remove to Make Valid Parenthesis in Java

Good morning. Hope you are doing well and keeping safe. Not sure what is happening with the COVID-19 pandemic. In some parts of the world i.e., Peru, hospitals are full and people are dying out of control. On the other hand in Sicily, Italy most people are socializing and not wearing masks. In Israel the entire population is receiving the second shot of the COVID-19 vaccine.

Close to home, my wife and I continue to practice social distancing. On Sunday we had family members visiting. No one wore masks but we all kept at a distance from each other. Of course, we will not know if something happened for a couple weeks. Continue reading “Minimum Remove to Make Valid Parenthesis in Java”