Introduction This is a series where you will learn about singly linked lists in JavaScript, doubly linked lists, stacks, and queues. The other links Are Here: How To Do Singly Linked Lists in JavaScript How To Do Stacks in JavaScript (This post) How To Do Doubly Linked Lists in JavaScript (Coming Soon) How To Do Queues in JavaScript (Coming Soon) What is a Stack? A stack is a abstract data structure that holds a list of components (such as a linked list of nodes). Think of it like a stack of dishes. You stack the dishes, so the last one...

Continue reading...# Algorithms

## How To Do Singly Linked Lists in JavaScript

Introduction This is a series where you will learn about singly linked lists in JavaScript, doubly linked lists, stacks, and queues. The other links Are Here: How To Do Singly Linked Lists in JavaScript (This post) How To Do Stacks in JavaScript (Coming Soon) How To Do Doubly Linked Lists in JavaScript (Coming Soon) How To Do Queues in JavaScript (Coming Soon) What is a Linked List? A linked list is an abstract concept in which you have a “node” object that references the next object (which is a property within that node) and has a value property. The object...

Continue reading...## What are Closures in JavaScript?

Closures in JavaScript is where your function can “remember” the lexical scope — even when the function is ran outside of the scope. Instances of similar occurrences like this can be seen in Object Oriented Programming (OOP). In OOP, you can create an instance of the class object and access it. This functions in a similar way. This is called: Closures in JavaScript. First, let’s dive into what “lexical scope” is and the significance of its role in closures. Lexical Scope Scope is lexical, meaning it can be accessed only on the block of code in which it is defined....

Continue reading...## What are Code Design Patterns?

A “Code Design Pattern” is a re-usable pattern that is used to solve problems with code. This happens on a design level in software, and ultimately makes code easier to manage, and more efficient in some cases. From algorithms to LeetCode patterns, Code Design patterns even go as broad as entire ways to design an entire system and how it relates to other internal systems. Why should I care about Code Design Pattern? Design patterns can accelerate the development process. When you try to solve something without a pattern, you are actively trying to reinvent another pattern that someone else...

Continue reading...## for(;i–;) (JavaScript for loop explained)

This JavaScript for loop is something I came across the other day solving problems in LeetCode. What seemed like an easy problem was difficult as to understanding different ways to combine a set of stairs. Here’s a picture of the problem on LeetCode (the algorithm problem): Solving the for loop So, to solve something like this, there needed to be a form of loop as to the number of times, and then adding exponentially a number that counts the amount of times. So without going much further, here is a solution to this problem: Understanding the JavaScript loop versions So,...

Continue reading...## Space Complexity & How to work on it

Introduction to space complexity Space complexity is how much memory an algorithm takes when executing it’s set of instructions. Usually, time complexity is much more important in a business perspective (quicker results to the client, and we can just buy more hard drive room). However, making sure that you are not taking up too much space is also just as important. Why should I care? When computers evolve, so do the problems we need to solve using the algorithms. The data continuously grows over time, and so does the demand. We also do not want to overload or run out...

Continue reading...## Algorithm Efficiency & Time Complexity.

As you keep hacking away, you will sooner or later hit a brick wall because your algorithm efficiency takes a century to run. You can solve this by creating an efficient algorithm, and measure the algorithm efficiency. Big O notation “Oh no it’s Big O!”…. Oh, yes! The big O notation allows us to measure space and time complexity as to measure the efficiency of our algorithms in two dimensions. By using this, we can work on more efficient algorithms and compare solutions to one another. O(1) Time Complexity The ideal/perfect algorithm efficiency is shown in green. O(1) would be...

Continue reading...## How to Do Recursion in JavaScript (The Basics)

Recursion in JavaScript (and any other language as well) is where you create a function, and then have that function call itself recursively to solve a problem. Think of it as an alternate method of looping through some data or related. It’s common in the algorithm area for you to use recursion to solve some types of problems. In this post, I will outline the basics of solving some simple recursion problems as an introduction to those unfamiliar. The Recursion Problem Okay, so an example of a problem you could solve in recursion with JavaScript is getting the length of...

Continue reading...