Before Your Next Interview Watch This
Key Takeaways
The video discusses the 10 most important data structures and algorithms for technical interviews, including linked lists, binary trees, stacks, queues, merge sort, and quick sort, and provides steps for implementing and understanding these concepts in JavaScript.
Full Transcript
have you ever been overwhelmed by the sheer number of data structures and algorithms you need to learn and just not knowing where to start well in this video i'm going to share with you the 10 most important data structures and algorithms you need to know in order to land your very first job and at the end we're going to be turning it up to 11 because i'm going to give you a bonus tip that's going to be important across all the interviews no matter where you go so let's get started now [Music] welcome back to web dev simplified my name is kyle and my job is to simplify the web for you so you can start building your dream project sooner so if that sounds interesting make sure you subscribe to the channel for more videos just like this now to get started we're going to be going over probably the most infamous data structure out there which is a linked list i actually have an entire tutorial on how to create a linked list in javascript i'll link up in the cards and description for you but essentially a linked list is one of multiple types either a singly linked list double a linked list or you can have a circular linked list which could also be doubly linked as well but essentially the way a linked list works is it's very similar to an array in how the data is structured it's a list of items but unlike an array instead of having indexes and positions in an array where your items are each item in a linked list points to the next item in the linked list or in the case of a doubly linked list it points to the next item and it also points to the previous item which is where you have these arrows that point forward and point forward or in this case they point forward and point backwards so you can kind of tell where in the array you are you can get the next item or you can get the previous item and link through an array like that this is great for certain things like insertion into an array like this is very quick because you can insert right into here and just change the next position from one to another and that's going to work just fine but if you wanted to for example get an individual element at a specific index that is going to be much slower than a traditional array so there's definitely pros and cons to a linked list but understanding a linked list overall how it works and how to create one is going to be crucial for pretty much any interview that you go into now the next type of structure that you should understand is going to be trees in general but more specifically we're going to be talking about the binary tree because the binary tree is probably one of the most popular tree structures out there and it's asked about all the time inside of different interviews and really the only features you need to know about when it comes to a binary tree is that in a binary tree you have a root node so you have one node at the very top and every single node in your tree can have at most two children so you can see this root node two here has two children seven and five seven has two children two and six six has two children five only has one child and nine only has one child that's because you can have at most two children or zero children or one child either way with a binary tree you can only have at most two children which is super important so the important thing to understand about a binary tree when it comes to structuring out in your code is each node is going to have a value in our case these values are numbers like two and seven and they're also going to have a left and a right and those left and right just point to other nodes so this left points to the node seven and this seven node has a left that points to two and a right that points to six six has a left that points to five and a right that points to eleven so you can have this tree structure which you can navigate by using these left and right properties of each of the nodes and you can get the value of each one of them so understanding binary trees and how to do different operations on them such as reversing binary trees or sorting binary trees is really important for interviews now this next data structure is something you're almost always going to be implementing or using inside of an interview and that is either a stack or a queue of some kind and these are lumped together because they're both very similar to one another so first we're going to talk about the stack and then talk about the queue with the stack what's happening is just like a stack in real life imagine you have a stack of papers or a stack of books when you approach this stack of books and you have a book in your hand you put your book on the top of the stack and then if you need to take a book off the stack you take the book off of the top of the stack this is why stacks are generally called last in first out or lifo for short and essentially all that means is the last item that gets put onto the stack is the first one that gets taken off when you need to take something off and with this demonstration here you can see that usually the push method is used to push something on top of a stack and then we call pop to pop the item off the stack and as you can see push puts it on the top and pop takes it off the top so always the very last thing that you put on is the first thing you take off and the very bottom of the stack is the very last thing that gets taken off and that's the first thing that gets put onto the stack now cues are just like a cue in real life like a line that you're going to wait in to get something you go to the very back of the line when you enter and the person that's in the front of the line is the first one taken off so this is first in first out the first person in line is going to be the first person that gets helped while the last person in line is the last person that gets helped so usually the methods you use with a cue are nq and dq but you could also use things like push and pop if you really wanted or add or remove the really important thing is that when you enqueue an object onto a queue you put it in the back and when you dequeue something off you take it off of the front of the queue so this is called first in first out and understanding when to use a stack when to use a cue and how they work or even how to create them is super important when it comes to landing your interview next we're going to mix things up and talk about an algorithm and this algorithm is merge sort and merge sort is a type of divide and conquer algorithm where you take a large problem of sorting an array and you divide it into smaller and smaller subsets until you essentially have nothing else to do and then you take these small subsets of just one element and start conquering them by combining them together over and over and over again until we get to a final sorted array this is much quicker than algorithms such as bubble sort so this is why it's really important to understand another algorithm that you might want to understand is going to be quick sort there's very few differences between quick sort and merge sort when it comes to the performance of them merge sort is generally going to be a little bit quicker but it does take up more space so you have to kind of weigh the space versus time complexity to figure out which one is more important but both of them are divide and conquer algorithms that work in similar yet different ways so understanding merge sort and possibly quick sort are crucial in your interview prep now this next type of data structure is one that you're most likely very familiar with especially if you use something like javascript before and this is the idea of a map a dictionary or even like a hash table really all it's doing is taking some key and converting that key to a value in some kind of storage method so in javascript you could use an object for this also you could use a map inside of javascript they actually have a map built into javascript and a map is very similar to an object it takes keys and values and allows you to convert between a key to a value if you want to learn more about this map object i have an entire blog article on it linked in the description below but understanding how this dictionary map kind of idea works and how you can convert from keys to values is super crucial and something you're going to use definitely inside of an interview but most likely this is one that you already know now this next type of data structure is going to be a graph of really any type the two main types you're going to run into are an undirected graph and a directed graph and really the only difference is a directed graph points you in the direction that you can go from one node to another for example here we can go from two to zero from zero to one one to two we could go from zero to two and so on well in this undirected graph over here we can go from zero to one or zero to two it doesn't matter because there is no direction and the most important thing to understand about a graph is how they're actually structured inside of a code so generally graphs are going to have things called vertices or nodes these are going to be essentially the places where your graph can point to so for example this one four three two zero and generally these are gonna have some type of value associated with them in our case one zero two three four these are just numbers and then between your different vertices or nodes you're going to have edges and the edges are just the lines that connect one vertice to another vertices so the way that these different vertices connect is called edges and these edges can also have a value to them for example it could be like how long it takes to go from one location to another so take for example google maps google maps is kind of like a graph because you graph how you get from one point to another point following a bunch of edges that connect vertices these edges would be the roads and the vertices would be essentially the places where you can turn from one road to another road and those roads they have lengths associated with them for how long the road is how slow it is how long it's going to take so google maps essentially can calculate all of these different things related to the edges of this graph and can determine the best path for you through the graph based on the different values of each of the vertices and each of the different edges so understanding how a graph is laid out how it looks in code and just in general how you can use them to do different calculations is super crucial now another important algorithm that you should understand is going to be the binary search algorithm because it's used all over the place and is pretty efficient what it does so understanding how it works is really crucial and binary search is very similar to that divide and conquer style algorithm you start with your array it has to be a sorted array and what you do is you go to the very dead center of that sorted array and you say okay in our case we're searching for 13 so is 13 greater than 11 or less than 11. we say okay 13 is greater than 11 so we look at the right half of the array we go to all the values greater than 11. we again go to the dead center and say okay is 13 less than or greater than 19. it's less than so we go to this next section over here which is 1317 and we just happen to choose 13 as our starting point because it's the center in our case we don't actually have a true center so it just chooses one of the two values that's the center in our case we get 13 exactly chosen so with binary search we're kind of doing that divide and conquer thing where we're constantly cutting the array at half over and over again which is where it gets that binary name from because it cuts in half over and over and over again until we finally get to the value that we're actually looking for now understanding how this actually works and how you can implement this in your language of choice is going to be really useful in an interview because questions related to binary search and other search algorithms are really really popular in interviews and binary search is probably the most popular search out there when it comes to web development now while we're on the topic of search i also want to talk about two more popular search algorithms which are breadth first search and depth first search and they're pretty straightforward you just think about the name with a depth first search over here on the right you essentially want to go as deep as possible first so this is a just binary tree here and you start by going all the way down one side until you get all the way to the bottom and then you go up one level and go again till you get all the way to the bottom you go up again down all the way till you get to the bottom up a little bit down all the way so you're just constantly trying to search as deep as you can at first and with a breadth of first search what you're doing is you're essentially going down one level and searching all the way across that level and then once you finish that you go down to the next level and search all the way across that level down again and all the way across so you're really trying to search from the shallowest all the way down to the deepest and the deepest is the very last thing you do so you can kind of think about breadth first search is going to left to right on a you know binary tree like this well depth first search is going top to bottom it's going up down up down up down up down while breath first search is left right left right red light really there's not many differences between these two when it comes to performance but depending on the problem that you're trying to solve one may be slightly more efficient than the other and just understanding what they are and how to explain them and talk about them in an interview is super important a lot of times you may not actually be asked to implement these or use these but just being able to talk about them with an interviewer because you might get asked questions about the differences between the two is really important to understand and the next thing i want to talk about really isn't an algorithm or data structure but it's more of a concept that's really important to understand and that concept is memoization i actually have an entire video on the concept i'll link in the cards and description for you but in short essentially memoization is when you calculate a value and you store that value to use later so if you try to recalculate the same value you already have it saved memoization is really useful for when you have to calculate something a lot of times with the same inputs or if you need to calculate something that takes a long period of time and you're going to calculate it again in the future a common example used with memoization is the fibonacci sequence because there's a ton of repeats in the fibonacci sequence so here we can see we're searching for f of zero f of one f of two f of three we're just passing these numbers into the fibonacci sequence and you can see that f of three requires us to figure out the value of f of 1 and f of 2. we've already calculated f of 1 so we don't need to recalculate it same here with f of 2 it's already been calculated so we've saved all these steps that are x out f of 3 saves all these x doubt steps f 4 since we already saved it we already can just remove all these x out steps so essentially instead of recalculating the value of what 4 is when we pass it into our function we saved it from the first time we calculated it and we can just get that value from a cache a memory and that's what memoization is you just save the output of a calculation that way when you have to redo the calculation you can use the saved output instead of recalculating everything over and over and over again and with things like fibonacci sequence it's incredibly important and it's going to save you tons of computation time now the final concept before we get to the bonus one is going to be recursion and recursion is a pretty simple concept of having a function call itself so you have a function that calls itself which calls itself which calls itself until eventually it exits out of itself and goes all the way down the stack a famous example of recursion is this image you can see we have one giant triangle and then this giant triangle is composed of three smaller triangles that are all exactly the same and those three triangles are composed of three triangles that are all the same and so on and so on and so on all the way down this is a recursive drawing because everything is composed of itself we just have this one triangle element and that triangle element is made out of itself and that thing also makes other bigger triangle elements so that's what recursion is you're just calling the same function over and over again i again have an entire tutorial on recursion i'll link up in the cards and description down below now the final bonus thing that i want to talk about is going to be big o notation and that's because big o notation is pretty much used in every single algorithm and data structure that you can think of because it's going to calculate the time and space complexity of your algorithm that you're writing out so understanding how you can use big-o notation is incredibly important and again i have an entire tutorial on big-o notation i'll link up in the cards and description down below but essentially with big-o notation you're just taking a look at your algorithm and figuring out okay how many times am i doing an operation am i doing it n times so if i have an n length array i put inside of here am i doing the n times am i doing n squared times 2 to the n times n factorial times or is it really quick maybe it's just constant time where i'm just doing it once no matter how big the array is being able to calculate this big-o notation is absolutely crucial you're going to get asked this in pretty much every interview that you go to so just having a basic understanding of big-o notation is going to put you a step ahead of everyone else that doesn't understand it and those right there are the most important data structures and algorithms that you need to understand if you enjoyed this video make sure to check out my other videos linked over here and subscribe to the channel for more videos just like this thank you very much for watching and have a good day
Original Description
There are tons of data structures and algorithms that you can learn but you do not need to know them all. In this video I will share with you the 10 most important data structures and algorithms that you need to know in order to pass your next technical interview.
📚 Materials/References:
Linked List Tutorial: https://youtu.be/gJjPWA8wpQg
Map Article: https://blog.webdevsimplified.com/2020-12/javascript-maps/
Memoization Video: https://youtu.be/WbwP4w6TpCk
Recursion Video: https://youtu.be/6oDQaB2one8
Big O Notation Video: https://youtu.be/itn09C2ZB9Y
🌎 Find Me Here:
My Blog: https://blog.webdevsimplified.com
My Courses: https://courses.webdevsimplified.com
Patreon: https://www.patreon.com/WebDevSimplified
Twitter: https://twitter.com/DevSimplified
Discord: https://discord.gg/7StTjnR
GitHub: https://github.com/WebDevSimplified
CodePen: https://codepen.io/WebDevSimplified
⏱️ Timestamps:
00:00 - Introduction
00:36 - Linked List
01:52 - Binary Tree
03:11 - Stack And Queue
04:57 - Merge Sort
05:52 - Dictionary/Map
06:37 - Graph
08:17 - Binary Search
09:33 - Breadth/Depth First Search
10:54 - Memoization
12:23 - Recursion
13:09 - Big O Notation
#DataStructures #WDS #Algorithms
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Web Dev Simplified · Web Dev Simplified · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Introduction to Web Development || Setup || Part 1
Web Dev Simplified
Introduction to Web Development || Understanding the Web || Part 2
Web Dev Simplified
Introduction to HTML || Your First Web Page || Part 1
Web Dev Simplified
Introduction to HTML || Basic HTML Elements || Part 2
Web Dev Simplified
Introduction to HTML || Advanced HTML Elements || Part 3
Web Dev Simplified
Introduction to HTML || Links and Inputs || Part 4
Web Dev Simplified
Learn Git in 20 Minutes
Web Dev Simplified
5 Must Know Sites For Web Developers
Web Dev Simplified
10 Best Visual Studio Code Extensions
Web Dev Simplified
Learn CSS in 20 Minutes
Web Dev Simplified
How to Style a Modern Website (Part One)
Web Dev Simplified
How to Style a Modern Website (Part Two)
Web Dev Simplified
3D Flip Button Tutorial
Web Dev Simplified
How to Style a Modern Website (Part Three)
Web Dev Simplified
Animated Loading Spinner Tutorial
Web Dev Simplified
How to Write the Perfect Developer Resume
Web Dev Simplified
Animated Text Reveal Tutorial
Web Dev Simplified
Learn Flexbox in 15 Minutes
Web Dev Simplified
Custom Checkbox Tutorial
Web Dev Simplified
Start Contributing to Open Source (Hacktoberfest)
Web Dev Simplified
JavaScript Shopping Cart Tutorial for Beginners
Web Dev Simplified
Responsive Video Background Tutorial
Web Dev Simplified
1,000 Subscriber Giveaway
Web Dev Simplified
How To Prevent The Most Common Cross Site Scripting Attack
Web Dev Simplified
Transparent Login Form Tutorial
Web Dev Simplified
The Forgotten CSS Position
Web Dev Simplified
How to Code a Card Matching Game
Web Dev Simplified
10 Must Install Visual Studio Code Extensions
Web Dev Simplified
Learn CSS Grid in 20 Minutes
Web Dev Simplified
Learn JSON in 10 Minutes
Web Dev Simplified
10 Essential Keyboard Shortcuts For Programmers
Web Dev Simplified
What Is The Fastest Way To Load JavaScript
Web Dev Simplified
Differences Between Var, Let, and Const
Web Dev Simplified
How To Install MySQL (Server and Workbench)
Web Dev Simplified
Learn SQL In 60 Minutes
Web Dev Simplified
How To Solve SQL Problems
Web Dev Simplified
What Are Design Patterns?
Web Dev Simplified
Null Object Pattern - Design Patterns
Web Dev Simplified
Your First Node.js Web Server
Web Dev Simplified
How To Setup Payments With Node.js And Stripe
Web Dev Simplified
How To Learn Any New Programming Skill Fast
Web Dev Simplified
Asynchronous Vs Synchronous Programming
Web Dev Simplified
JavaScript ES6 Arrow Functions Tutorial
Web Dev Simplified
Are You Too Old To Learn Programming?
Web Dev Simplified
JavaScript Cookies vs Local Storage vs Session Storage
Web Dev Simplified
JavaScript Promises In 10 Minutes
Web Dev Simplified
Builder Pattern - Design Patterns
Web Dev Simplified
JavaScript == VS ===
Web Dev Simplified
JavaScript ES6 Modules
Web Dev Simplified
8 Must Know JavaScript Array Methods
Web Dev Simplified
CSS Variables Tutorial
Web Dev Simplified
JavaScript Async Await
Web Dev Simplified
How To Choose Your First Programming Language
Web Dev Simplified
Easiest Way To Work With Web Fonts
Web Dev Simplified
Singleton Pattern - Design Patterns
Web Dev Simplified
Responsive Navbar Tutorial
Web Dev Simplified
CSS Progress Bar Tutorial
Web Dev Simplified
Learn GraphQL In 40 Minutes
Web Dev Simplified
What is an API?
Web Dev Simplified
Learn How To Build A Website In 1 Hour!
Web Dev Simplified
More on: LLM Foundations
View skill →Related Reads
📰
📰
📰
📰
Advanced Stack ApplicationsData Structures and Algorithms Deep‑Dive — Advanced Stack Applications…
Medium · Programming
The Minecraft anvil is a tree-cost optimization problem in disguise
Dev.to · Mark
KMP Algorithm (Knuth-Morris-Pratt): The Smart Way to Perform String Matching in O(N)
Dev.to · Jaspreet singh
Every Backtracking Problem Is the Same Three Lines. I Just Couldn't See the Tree.
Dev.to · Alex Mateo
Chapters (12)
Introduction
0:36
Linked List
1:52
Binary Tree
3:11
Stack And Queue
4:57
Merge Sort
5:52
Dictionary/Map
6:37
Graph
8:17
Binary Search
9:33
Breadth/Depth First Search
10:54
Memoization
12:23
Recursion
13:09
Big O Notation
🎓
Tutor Explanation
DeepCamp AI