An Introduction to Linked Lists
Published: 03-14-2020Over the past few days, I’ve been studying data structures. This time, rather than a niche data structure, we’ll dive into the more common linked list. There are two types of linked lists: single and double. As this is intended as an introduction to data structures, we’ll focus on the easier one — singly-linked lists. If you are able to understand singly-linked lists, doubly linked lists will come naturally to you. For the purposes of clarity in this blog, a linked list is the same as a singly linked list, unless otherwise stated.Read More...
An Introduction to Binary Heaps
Published: 03-08-2020Time for another introduction to a niche data structure! For this blog, this will be on binary heaps. If you are familiar with binary search trees, this data structure will look very familiar. If not, don’t worry, we’ll be going step by step on the concept of binary heaps.Read More...
Keeping Your Code DRY
Published: 02-29-2020This past week, the majority of my time was spent on working on a coding challenge. It was definitely tough, from understanding the user stories to wireframing out the application to implementing the code to debugging. There was a lot of going back and forth between my components. I was slowly starting to realize that when I changed one part of my code, I would need to change all the other parts of the code that was dependent on it. By having a downstream effect of manual changes from changing one part of my code, this was violating the DRY (Don’t Repeat Yourself) principle. When you initially write out your code, this may happen a lot more than you think. Keeping your code DRY is part of the refactoring process, so if you don’t catch it right away, that’s not a problem.Read More...
Data Structures: Improving Time Complexity on Stacks and Queues
Published: 02-23-2020In my previous blog, I provided an introduction to a niche data structure called stacks and queues. If you are unfamiliar with it, please take a quick look at my blog Stacks and Queues. In a nutshell, stacks and queues follow the principle of first-in-last-out (stacks) and first-in-first-out (queues). However, for out-of-the-box JavaScript array methods, the time complexity for stacks is O(1) and the time complexity for queues is O(n). Which led me to think, can we do better? Specifically, can we improve the time complexity for queues to be faster than O(n)?Read More...
An Introduction to Stacks and Queues
Published: 02-16-2020Optimizing code is rarely an easy task. The code may be working as intended, but if it takes too long to execute, then the code is inefficient and needs to be optimized. Data structures — a necessary evil in the coding world — represent the main crux for optimization. Using the correct data structure for the correct scenario will make your code run considerably faster than using a brute-force method. One of these data structures is stacks and queues. Personally, I feel like this is a lesser-known data structure that’s extremely easy to implement and doesn’t get enough love.Read More...