Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a series of articles titled Algorithm Action.
Today, we’re wrapping up our exploration of Object Oriented Programming in Javascript.
In part one, I covered how Javascript handles Object Oriented Programming without actually being an OOP-based programming language. We covered classes, constructors, and instance method. Now, we’re diving a little more deeply into class methods.
Also known as static methods, class methods are used only with entire classes rather than instances of that class. …
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a series of articles titled Algorithm Action.
Today, we’re exploring using Object Oriented Programming in Javascript.
Technically, Javascript doesn’t support OO programming but in 2015 introduced the Class syntax. A Class is a blueprint for creating objects with predefined properties and methods.
We’ll be using the Class syntax to define data structures.
The class keyword creates a constant. (Keep in mind you cannot redefine it.) The method to create new objects must be called constructor and serves to give an opportunity for attributes to be defined on instantiation. …
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a series of articles titled Algorithm Action.
Today, we’re wrapping up our exploration of merge sort.
In Part 1 of this series, we explored why we need a helper function to make merge sort work and defined it.
function merge(arr1, arr2){
let results = [];
let i = 0;
let j = 0;
while (i < arr1.length && j < arr2.length) {
if (arr2[j] > arr1[i]) {
results.push[arr1[i]];
i++;
} else {
results.push(arr2[j]);
j++;
}
}
while (i < arr1.length) {
results.push(arr1[i]);
i++
}
while (j < arr2.length) {
results.push(arr2[j]); …
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a series of articles titled Algorithm Action.
Today, we’re beginning our exploration of merge sort.
Merge sort is a combination of splitting, sorting and merging actions. It works because it exploits the fact that arrays of 0 or 1 element are always sorted. Therefore, by decomposing an array into smaller arrays of 0 to 1 elements, it’s possible to build up a newly sorted array.
But to make it work, let’s take a quick detour to define the helper function we’ll need to make this work. …
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a series of articles titled Algorithm Action.
Today, we’re checking out a specific sorting pattern known as selection sort.
Selection sort is similar to bubble sort, but instead of first placing large values into sorted position, it places small values into sorted position.
Let’s wrap our head around this one:
1. Store the first element as the smallest value you’ve seen so far in the given array. So if that’s 2, this variable will be equal to 2.
2. Compare this variable to the next element in the array until you find a smaller number.
3. If a smaller number is found, designate that smaller number to be the new minimum and continue until the end of the array.
4. If the minimum is not the value(index) you began with, swap the values.
5. …
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a set of articles titled Algorithm Action.
Today, we’re checking out a specific sorting pattern known as naive search.
Naive search is more of a brute force method of finding strings inside of other strings, or any other problem like it, for example.
Naive search is pretty straightforward, using two for loops to go through each string and increment a matchCount as matches are found.
Let’s first define a function that takes two strings:
function naiveSearch(long, short) {…
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a set of articles titled Algorithm Action.
Today, we’re checking out a specific sorting pattern known as binary search.
Binary search is a much faster form of search. Instead of eliminating one element at a time, you eliminate half of the remaining elements each time a certain condition is met. The one caveat, however, is that binary search only works on sorted arrays. …
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a set of articles titled Algorithm Action.
Today, we’re checking out a specific sorting pattern known as bubble sort.
Bubble Sort if an algorithm where the largest values “bubble” to the top. While it’s not commonly used or very efficient, it does work in niche situations. In the category of sorting algorithms, it’s especially important to know what each type does and in what situations they perform optimally. …
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a set of articles titled Algorithm Action.
Today, we’re checking out a specific problem solving pattern known as the sliding window.
Algos, algos, algos: the cornerstone of a competent software engineer. This is why I’m compiling all my research and work on the topic in a set of articles titled Algorithm Action.
Today, we’re checking out a specific problem solving pattern known as divide and conquer.
The Divide & Conquer approach is important because, for a lot of problems, it usually greatly decreases time complexity. It involves dividing a data set into smaller chunks, applying some sort of condition to both, and then repeating the process with whichever subset of data passes, and on and on. …