A binary tree is a specific type of graph data structure and is often the first graph people learn. Binary trees contain a root node that has two branches which are arranged from left to right in ascending order. Each branched node can have up to two branches of its own, and so on. If these two requirements are not met then the data structure is likely still a tree, just not a binary tree. For instance, if a node had three branches it might be considered a ternary tree. This article will cover only binary trees as they are…
Every person has waited in a queue, whether it is at the grocery store or to get into you favorite concert. A queue’s operation is simple and intuitive, you get in the back of the line and wait your turn until your in the front of the line before exiting the queue. This is the same way the data structure of a queue works.
In the person queue analogy, each person can be considered a node that contains some data and points the the next node. …
There is nothing better than a stack of buttermilk pancakes to calm that early morning sweet tooth. Now, I normally slice through the whole stack and eat a bit from each pancake at once but lets pretend, for the sake of this discussion, that I am a reasonable person that eats a single pancake at a time. To do so, the top most pancake would be pulled off of the stack and consumed followed by the next pancake on top. This is the same way the linear data structure of a stack works. …
In the previous “Data Structures in JavaScript” discussion, we walked through the methodology used to construct a node class which represent each “link” in the “chain” that is a linked list. From there we discussed how to construct a singly linked list from a an array. Building on the previous discussion, we will now dive into editing that singly linked list. If you are not familiar with the code and terminology covered in the previous article it is recommended you review Building a Singly Linked List.
With a linked list there are three ways to edit the list: update a…
Most likely you arrived at this article because your preparation for an interview has lead you down a LeetCode rabbit hole. Linked lists are a favorite of many interviewers to test an interviewees understanding of basic data structures as well as your problem solving skills. Whether you're just a bit rusty from school or this is your first time encountering linked lists they can be a bit tricky to understand at first.
As with most problems it is helpful to start with a diagram. A linked list is a linear data structure which can be thought of as a chain…
In Java, enumerables or enums for short, are a special type of class that represents a group of related constants. For example a list of the days of the week or a set of Redux action types are good candidates for a enumerable. These can come in handy when your code references these group of constants but you want a single source of truth. In addition, enums improve readability via documenting the intent of your code. Vanilla JavaScript does not have enums but they are available in the superset of JavaScript, TypeScript version 2.4 and on. …
As I continue the Udemy course TypeScript: The Complete Developers Guide I’ve been introduced to several new to me concepts. Generics & abstract classes are two tools a developer can use to make their code more reusable and maintainable. More senior developers who are accustomed to strong type languages such as C, Go, Java and Swift are likely already familiar with these concepts.
As discussed in Typescript Type Declaration when declaring functions the input and output types should be annotated but what if you don’t know what type your input or output will be? Initially it may sound like this…
A tuple, not to be confused with the musical term tuplet or the flower tulip, is an ordered and finite list of elements. In programming, a tuple’s elements tends seem to be closely related but can have varying types. Tuples can be found in several programming languages such as Python, C++, and TypeScript. For example, if we were trying to describe a set of cars in TypeScript one might code the following.
Most programming languages are designed in a way to limit the amount of typing a user has to perform because well, people are naturally lazy. So when I decided to start learning TypeScript, which is a strict syntactical superset of JavaScript that adds optional static typing, I also want to be lazy at every opportunity I could find. In order to save my fingers some effort in TypeScript I first had to understand type annotation and inference.
Type Annotation is simply when you tell Typescript what type of variable you want to define in same line you define it. There…
When I first started programming I was overwhelmed by the sea of languages I could learn. Which one should I learn first, what is the difference, what can this one do that the other can not? In the end, all programming languages tend to be able to perform similar tasks, with relatively similar syntax, and serve the the same purpose of telling the computer how to do some work. New languages seem to be written to fill a gap or make something easier but in the end which language you use seems to come down to personal preference. …
I am a software engineer with a mechanical background. Interests swing from aerospace, to woodworking, travel, skiing, hiking, running, climbing, and lasers.