Managing Binary Trees – Linux

This post deals with an API for binary trees in Linux. The API consists of the following functions:

Function Brief Description
tdelete() Deletes an item from a tree.
tdestroy() Deletes the entire tree.
tfind() Finds an item and if not found returns NULL.
tsearch() Search a binary tree for an item.
twalk() Performs a depth-first, left to right tree traversal.

In the past I have used and implemented, using different programming languages, several classes, methods and functions to deal with binary trees. Binary trees are used to keep data in sorted order. This allows for quicker search times. This particular implementation comes with the Linux operating system. You can read more about it by typing on a Linux console:  man twalk Continue reading “Managing Binary Trees – Linux”

Log Files

About a couple decades ago I came up with the idea for a storage server. This occurred while experimenting and working with a Hierarchical Storage Manager (HSM) product that worked on a Sun Solaris system and used tapes in an automated library to manage the contents of the files. At that time the idea of a Content Addressable Storage (CAS) was several years away. Continue reading “Log Files”

New, Duplicate or in Segment – Part 4

Ditto. This post covers the continuation of the original proposed (by me) challenge to HackerRank. Seems that I made the mistake to generate the post New, Duplicate or in Segment – Part 2 which describes this challenge. As you can verify I did not suggested a solution. Apparently that was enough to disqualify this entry. Next time I come up with a proposed challenge will not post a thing about it. Continue reading “New, Duplicate or in Segment – Part 4”

New, Duplicate on in Segment – Part 3

I received a message from HackerRank indicating that they would not be able to use the New, Duplicate or in Segment proposed (by me) challenge because I had already made a post in my blog. I thought it would be fine if I did not describe a possible solution. I guess I was wrong.

Within the specified range label each received integer as “New” if the integer is being processed for the first time, “Duplicate” is the integer is not in a segment but has been processed before or “In segment” if the integer is part of a segment of two or more integers. Continue reading “New, Duplicate on in Segment – Part 3”

New, Duplicate or in Sequence – Part 2

I decided to complete the continuation of the HackerRank challenge that I put together. This is a follow up on my post New, Duplicate or in Segment.  Regarding the previous challenge, I need to get back to HackerRank. A member of their team sent me an invitation on Google Hangouts so the ball is in my court. Have been very busy this week so will be calling them over the weekend. If that plan does not work, I will try Monday. I believe there are several hours difference between us.

I am not going to provide a solution for this challenge but will provide the requirements at this time. Continue reading “New, Duplicate or in Sequence – Part 2”

New, Duplicate or in Segment

This is my first attempt to create a set of two challenges for HackerRank. If you are interested in generating a new challenge you should try the Challenge Guidelines link and read all about how to proceed.

After reading the guidelines I created the following information for the “New, Duplicate or In Segment” challenge: Continue reading “New, Duplicate or in Segment”

Ice Cream Parlor – Part I

Decided to take a stab at “Binary Search: Ice Cream Parlor” challenge in Hacker Rank. If interested you can get the requirements at the following URL:  https://www.hackerrank.com/challenges/ctci-ice-cream-parlor

The general idea is to solve the sum of two numbers. I will address more on the subject of sum of two numbers on the second part of this post.

It is nice that Hacker Rank has been putting links to short videos with some challenges. In this case there is a video on Binary Search by Gayle Laakmann McDowell author of “Cracking the Coding Interview”. I watched the video. It was simple and to the point. Gayle covers the subject with an implementation using a recursive approach which she then converts to a loop implementation. Continue reading “Ice Cream Parlor – Part I”

Polygon Area

The requirement for this task is to verify the area of polygons. The motivation could be controlling the amount of material used to cut shapes on some type of material. Some time ago led a project that developed a system to print images on film. The software used two hardware devices to keep track of the number of feet used per roll and the total area of all images (polygons) used to generate images by the software.

In this case the description of the polygons (made up of consecutive lines), lines (made of start and end point) and points (3D coordinates) are provided via an XML file. For simplicity and brevity I will skip the code I wrote to load and parse the XML file. The polygons are defined in a 3D space. Continue reading “Polygon Area”