Data structures and algorithms are important for any software developer.

Sometimes loved, more often dreaded, but at the core of our craft.

Here is an introduction to the most important data structures, including learning resources.

A thread. ↓
1. Why you need to learn them

The reality is: You will and should never implement many data structures yourself on the job.

There are libraries for this purpose. Either a language's standard library or a commonly used library will provide them for you.

But is this all?
To decide which data structure you need in what case, you should know about them in the first place.

You need to know:

- Which exist
- What they are good for
- How they work
- Their runtime characteristics (time and space complexity)
- Their pros
- And cons
If you, e.g., want to store values related to keys and also want to loop over the entries in the order they were inserted, you need to know that you:

- Need a map
- Backed by a tree

And you should know that maps backed by trees need a little longer to insert and find entries.
To make this decision, you will need that knowledge about data structures and their traits.

This is the first reason for you to learn about them well at least once.

And well means knowing exactly what's stated above—all of it.
You should even go so far as to implement them all and the algorithms belonging to them, at least once.

You can learn any theory, but doing it yourself will make this knowledge definitely stick.
Many developers tend to remember things they implemented themselves way better than things they only learned in theory.

This way can save you a lot of time you would otherwise spend reading theory over and over again.
Learning the algorithms associated with data structures also greatly benefits you: You will cover all common algorithmic techniques at least once.

You won't need this knowledge to implement a breadth-first-search yourself, but it might help you with the problems you tackle.
Once again, in case it didn't become clear enough:

You probably only need to do this once as long as the knowledge all this brings you sticks.

Only if you somehow lose this knowledge because you haven't worked with it for a longer time, repeat the process.
2. What you should know

You should cover the most prominent data structure groups:

- Arrays
- Lists
- Queues
- Stacks
- Sets
- Trees
- Graphs
- Hash tables
Many of the entries above actually contain different implementations, and of those different implementations, equally as many contain other data structures to back their own implementation.

This is why you reach a certain synergy effect at some point.
Let's look at them a little deeper while you get to know a few of their traits and their average time complexity.

You can use this information as a base for your own research because there is way more to those than only the following information.
-> Arrays

- Most primitive and native data structure
- Linear data structure, values are stored one after the other
- Static in size, once initialized not resizable
- Base for many other data structures
Average time complexity of common array operations:

Access: O(1)
Search: O(n)
Insertion: O(n)
Deletion: O(n)
-> Lists

- Complex data structures but still pretty basic
- Can be backed by arrays or come as linked lists (singly, doubly linked)
- Linear data structure, values are stored one after the other
- Dynamic in size
- Base for other data structures
Average time complexity of common list operations:

(Singly- and Doubly-Linked)

Access: O(n)
Search: O(n)
Insertion: O(1)
Deletion: O(1)
-> Queues

- Linear data structure
- First-in-first-out
- Can be backed by an array or more prominently by a linked list
- Dynamic in size
- Often used to store work that is to be processed one after the other
- Has more implementations with different additional traits
Average time complexity of common queue operations:

Access: O(n)
Search: O(n)
Insertion: O(1)
Deletion: O(1)
-> Stacks

- Linear data structure
- Last-in-first-out
- Can be backed by an array or more prominently by a linked list (sometimes by a Dequeue)
- Dynamic in size
- Undo operations are usually based on stacks, for example
Average time complexity of common stack operations:

Access: O(n)
Search: O(n)
Insertion: O(1)
Deletion: O(1)
-> Sets

- One of a kind (unique value) storage
- Can be backed by a hash table or a tree
- Dynamic in size
- Especially used when you only want unique values of any kind
- Can be ordered and unordered
Average time complexity of common set operations:

(backed by some form of hash table)

Access: O(1)
Search: O(1)
Insertion: O(1)
Deletion: O(1)
-> Trees

- A recursive collection of nodes
- Dynamic in size
- Can be ordered and unordered
- Can contain unique and non-unique values
- Often used to model documents or by your favorite programming language's parser (Abstract Syntax Tree)
Average time complexity of common tree operations:

(Red-Black-Tree)

Access: O(log(n))
Search: O(log(n))
Insertion: O(log(n))
Deletion: O(log(n))
-> Graphs

- Non-linear data structure
- Consists of nodes (vertex) and edges
- Can store information on its edges
- Can be directed and undirected
- Dynamic in size
- Often used to represent networks (your Facebook connections can be represented as a graph, e.g.)
Average time complexity of common graph operations:

(Adjacency Matrix)

Access: O(1)
Search: O(1)
Insertion: Edge: O(1), Vertex: O(|V|^2)
Deletion: Edge: O(1), Vertex: O(|V|^2)
-> Hash tables

- Key-value mapping
- Uses math operations to map a hash value to a spot in a table
- Unordered
- Needs keys that are hashable
- Dynamic in size
- Often used when quick lookup of values by keys is needed
Average time complexity of common hash table operations:

Access: O(1)
Search: O(1)
Insertion: O(1)
Deletion: O(1)
3. Where you can learn more about them

-> GeeksforGeeks

GeeksforGeeks has an incredible collection of articles and how-tos on data structures and algorithms.

Most articles also include implementations in different programming languages.

geeksforgeeks.org/data-structure…
-> Programiz

A full collection of nearly everything you need to know about algorithms and data structures.

Implementations are usually in C, C++, Python, and more.

programiz.com/dsa
-> JavaScript Algorithms

This repository on GitHub will teach you a lot about algorithms and data structures and everything in JavaScript!

Definitely worth a look. Especially if you want to improve your A&DS skills with JavaScript.

github.com/trekhleb/javas…
4. Thread end

That's it for this thread. 💛

I hope you found something useful in it for you. 🙏🏼

If you enjoyed reading this, consider liking the thread, retweet the first tweet, and follow me (@oliverjumpertz) for more content like this.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Oliver Jumpertz

Oliver Jumpertz Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @oliverjumpertz

30 Jul
Cracking a tech interview is one thing, but it's a whole other level of difficulty to get an interview at all.

Marketing yourself takes time, but there is a way to minimize your efforts: LinkedIn.

Let's see how you can use LinkedIn optimally to market yourself.

A thread. ↓
0. Foreword

I have used LinkedIn for quite some time now and put some great effort into optimizing my profile and approach.

Before I decided to go down the content creator route, I had at least 10 recruiters (more often 20 to 30) contacting me daily about new roles.
As soon as I set myself as "open to offers," I can't even catch up with all the messages I get anymore.

This is not to brag but to prove one point: LinkedIn gives you visibility, leading to potential interviews.
Read 40 tweets
29 Jul
I've been a software architect for most of my professional life, and system design has always been my bread and butter.

Here are 7 steps that I would advise you to follow to ace your system design interview.

They will bring you further than ever, promised.

A thread. ↓
0. Foreword

As a software architect and tech lead, I had the chance to interview some very bright engineers throughout my career.

I've also interviewed quite a few times myself.

This approach is the one that I would use to design a system.
I highly believe that this approach is the one you should use in your interviews, as it's an incremental and organized workflow.

Your goal is that your interviewers understand what you design.

This enables them to follow along as you design.
Read 39 tweets
27 Jul
I've started to develop software at the age of 12. That was 21 years ago.

Here is some advice I want to give to any aspiring software developer trying to learn the craft and getting into the industry.

A thread. ↓
1. Spend more time on the why

Ask yourself honestly why you want to learn to develop software.

It is okay to go for the money. In many countries, software developers earn top salaries.

But you should always be aware of your own motives.
If you constantly tell yourself you do it because you love it, while silently thinking that it's for the money that helps you support your family, you could actually end with burnout or depression.
Read 22 tweets
26 Jul
Determining what salary to ask for is difficult.

You ask for too much, and you are shown the door.

If your demand is too low, you'll be underpaid for a long time.

Let's see how you can find the right amount to ask for.

A thread. ↓
1. Do your research

This is important. Often, you don't even have a good idea of which amount of money is actually fair to ask for.

You need to do research to find out what others in similar positions earn.

This usually gives you a basic idea of what range you can aim for.
You can start with salary calculators like PayScale or Salary but only use them as a rough indicator.

Their results are based on the voluntary input of data by people like you.

If someone provides a fake salary, it affects the outcome negatively.
Read 27 tweets
25 Jul
"What is your current salary?"

Have you ever encountered this question in an interview, or has a recruiter ever asked you this?

This is one of the most critical and morally questionable questions to ask a candidate, and here is how you deal with it.

A thread. ↓
1. Determining the value of work

Before we talk about the question and how to handle it, we need to talk about how the value of work is determined.

With this knowledge, you will understand the catch of this question and why answering honestly puts you at a disadvantage.

1/31
To completely cover a topic as deep as how to value work, it would definitely need a thread or even a book on its own.

We will thus go with a pretty simplified version that gives you at least a basic idea of how it works.

2/31
Read 32 tweets
24 Jul
I've recently covered a few common general interview questions and tips for interviews.

Here is a collection of those threads for anyone curious and about to interview soon.

They even occur in tech interviews, so software developers, take a read!

A thread. ↓
1. "Are there any questions left we can answer?"

A simple question but the right answer can be powerful leverage for your position with the company you are applying to.

2. "Where do you see yourself in five years?"

This common question can be difficult to answer.

But with the right preparation, you'll crush it!

Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(