Six Data Structures To Help You Ace Your Technical Interview
Tags: computerscience
Published: 2020-02-07 19:17:10

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](https://www.ladybug.dev/data-structures-and-algorithms) so I recommend checking that out if you haven't already! We'll cover a lot more than the six data structures here!

{% spotify spotify:episode:36bNHccJuFkGgz78UNdSsi %}


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
![Array](https://dev-to-uploads.s3.amazonaws.com/i/70hr5mwpa9ky6hpgy0ee.png)
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.

- [Full array methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
- [Free Code Camp arrays](https://www.freecodecamp.org/news/https-medium-com-gladchinda-hacks-for-creating-javascript-arrays-a1b80cb372b/)


# 🐞 Linked Lists
![Linked list](https://res.cloudinary.com/practicaldev/image/fetch/s--2IiQrKI4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2cq9rn3vn1z1zrvgvlnq.png)

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](https://dev.to/aspittel/thank-u-next-an-introduction-to-linked-lists-4pph)
- [Emma's linked list blog post](https://dev.to/emmabostian/creating-linked-lists-with-javascript-391e)
- [Kyle Shevlin's Egghead.io course on data structures with JS](https://egghead.io/lessons/javascript-linked-list-data-structure-in-javascript)


# 🐞 Stacks
A stack is not a built-in JavaScript data structure but can be built using arrays.

![Stack](https://res.cloudinary.com/practicaldev/image/fetch/s--nsKF_YXk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2AO91_4SoZ3V2uouYqeEYQlQ.png)

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).

![Stack](https://res.cloudinary.com/practicaldev/image/fetch/s--Gy5Vb00x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2AalBuMMj2DMwZm750uzRs_Q.png)

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](https://dev.to/emmabostian/stacks-vs-queues-in-javascript-4d1o)
- [Emma's 'Creating Three Stacks With One Array' blog post](https://dev.to/emmabostian/creating-3-stacks-with-1-array-in-javascript-514b)
- [Stacks in JavaScript](https://www.geeksforgeeks.org/implementation-stack-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.

![Queue](https://res.cloudinary.com/practicaldev/image/fetch/s--_pp5Lukw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2AA143SzcQuOhlZixXbFBpoA.png)
- [Emma's 'Stacks vs. Queues in JavaScript' blog post](https://dev.to/emmabostian/stacks-vs-queues-in-javascript-4d1o)


# 🐞 Binary Trees
![BST](https://dev-to-uploads.s3.amazonaws.com/i/w3v7c9lg6z7xw52d3oo4.png)
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.

- [Kyle Shevlin's Egghead.io course on data structures with JS](https://egghead.io/lessons/javascript-linked-list-data-structure-in-javascript)
- [BST in JavaScript](https://www.geeksforgeeks.org/implementation-binary-search-tree-javascript/)

# 🐞 Graphs
![Graph](https://res.cloudinary.com/practicaldev/image/fetch/s--Kv5ciqHz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2AbH2AHhFt9P_Tb8Opp6bhLQ.png)

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.

- [Emma's 'Creating Graph's With JavaScript' blog](https://dev.to/emmabostian/creating-graphs-with-javascript-4efm)
- [Graphs in JS](https://adrianmejia.com/data-structures-for-beginners-graphs-time-complexity-tutorial/)

---

What are some other resources you like for learning data structures and algorithms?!

Leave yours below! 👇