It's a new year which means many of us are searching for our next role. It's no secret technical interviews are hard, so we've compiled (hehe) a list of six data structures you should be comfortable with in 2020.
If you're going through a technical interview, these are must-knows.
We chatted about data structures & algorithms on this week's Ladybug Podcast so I recommend checking that out if you haven't already! We'll cover a lot more than the six data structures here!
Since these data structures have been written about until the cows come home, here are some of our favorite resources for learning them!
Good luck, devs!
🐞 Arrays
Arrays are the bread and butter of data structures. They are list-like data structures which allow you to keep track of elements. These elements can be reference types, like objects or other arrays, or primitives, like numbers or strings.
The length of an array in JavaScript is not fixed, meaning you can add values to the array easily.
🐞 Linked Lists
Linked lists are a data structure which isn't built-in to JavaScript, but can be created out of other JavaScript data structures.
A linked list represents a series of nodes where each node points to the next node in the list.
There are also doubly-linked lists where each node also points to the previous node in the list.
This structure uses the LIFO, or last-in-first-out, method where nodes are added to and deleted from the same end.
- Ali's 'Thank U Next' blog post
- Emma's linked list blog post
- Kyle Shevlin's Egghead.io course on data structures with JS
🐞 Stacks
A stack is not a built-in JavaScript data structure but can be built using arrays.
A stack is based on the LIFO, or last-in-first-out, concept. A stack is like a pile (or stack) of books where you have to take the top book off before you can get to the bottom book (unless you're a savage).
Stacks allow for constant time adding and removing of an item but unfortunately they don't provide constant-time access to the nth item in the stack.
- Emma's 'Stacks vs. Queues in JavaScript' blog post
- Emma's 'Creating Three Stacks With One Array' blog post
- Stacks in JavaScript
🐞 Queues
A queue is similar to a stack, but uses the FIFO, or first-in-first-out, method. You can think of a queue like a line of people waiting to buy a movie ticket. The person who has been in line the longest (first) is the first to be serviced.
🐞 Binary Trees
Binary trees are a data structure consisting of a series of nodes where each node can have a maximum of two child nodes as well as a value. The root is the top node in the tree structure and doesn't have a parent node.
A binary search tree is another type of binary tree where all node values are distinct, every parent node has a left child whose value is less than it and a right child whose value is greater than it.
🐞 Graphs
Graphs are a data structure comprised of nodes with edges. If a graph is directed, that means each edge has a direction associated with it (like a one-way street). In contrast, undirected doesn't have associated edge directions.
You might have a graph of people (purple) and movies (green) where each person can have several favorite movies but movies don't have a favorite person.
What are some other resources you like for learning data structures and algorithms?!
Leave yours below! 👇