## DEV Community is a community of 549,910 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# How To Learn Data Structures And Algorithms (An Ultimate Guide For Beginners)

Nick Chen Originally published at coderscat.com Updated on ・6 min read

## Mindset

As my previous article elaborated, data structure and algorithms are the ultimate basis for a programmer. I strongly believe that a good knowledge of these two topics is also key to become a better programmer because an engineer who has a good understanding of algorithms and data structures can make thoughtful choices and write programs that can handle changes better and perform well.

### I come, I conquer

Some beginners will be discouraged and be frustrated at the beginning, feel that the data structure and algorithm are very abstract and obscure.

Don’t worry, that is very normal for beginners. I also got the same feeling when started learning. The real reason is that you did not find your own learning method, and haven’t built confidence for it. This is my roadmap and tips for you, Keep patience and keep moving.

### Don’t be afraid of the mathematical part.

Data structure and algorithms do involve some mathematical reasoning and proof, especially when analyzing the time and space complexity of an algorithm.

The big-O complexity analysis is important, but you don’t need to worry about it too much. You don’t need a high IQ or abstract mathematical knowledge. You can master it as long as you have a high school mathematics level.

You will have more confidence after months of practice and learning.

### What is data structure and algorithm essentially?

Generally speaking, the data structure is a storage structure for a set of data, an algorithm is a method and pattern for solving problems.

#### Take an example

How do you find a book from a library?

• Method #1: You can check each book one by one until you find the wanted
book.

• Method #2: You can first locate the bookshelf according to the category
of a book, whether it is humanity, or science, or computer science,
and then you search in the specific bookshelf.

In general terms, these two methods for finding a book are both algorithms, so we get the definition of an algorithm is: The methods for solving problems, which could be implemented in programming.

In detail, when we talk about data structures and algorithms, we are talking queues, stacks, heaps, binary search, dynamic programming and so on.

These are patterns for abstraction and solving problems, which invented by computer pioneers. We can effectively learn them and use them to solve many practical development problems.

#### The relationship between data structures and algorithm

Data structures and algorithms complement each other. The data structure is for the algorithm, and the algorithm is applied to a specific data structure. Therefore, we can’t isolate the data structure and algorithms.

For example, because arrays have the characteristics of random access, the commonly used binary search algorithm requires an array to store data. But if we chose a data structure like a linked list, the binary search algorithm will not work because the linked list does not support random access.

## The Steps

### Get good books and resources

There are some really good textbooks for data structure and algorithms, but at the beginning, you maybe need the books which are coded in a programming language you have mastered.

Visualizations will help you understand how data structure and algorithms works, you can find awesome animations of this kind from the site: visualgo.net.

### Learning the basics data structures

Many advanced data structures and algorithms, such as bipartite graphs, maximum streams, etc., are rarely used in our usual development. So, you don’t have to look at them at the beginning.

Here are 11 basic data structures for your starting:

``````array, linked list, stack, queue, hash table,
map, heap, binary tree, trie tree,
graph, skip list
``````

You should learn these data structure APIs and also the complexity of their operations.

GeeksforGeeks summarized many good practices for data structures.

### Learning basic algorithm design pattern

From my experience, studying algorithms should not try to remember the steps and details of algorithms, but try to reinvent, reason and reimplement the algorithm by ourselves.

Why?

If you didn't understand how it works, you could not remember the details and will forget it later. Implied ideas in algorithms are more important than details.

My recommended flow for learning classic algorithms is:

The most used algorithms come to these categories, some harder problems need some variants, you need to combine several algorithms to solve one problem.

Follow the principle of deliberate practice, you should focus on one specific category in a short time, try to learn them one after another:

``````  sorting, binary search, search, string matching, recursion,
hash algorithm, greedy algorithm,
divide and conquer algorithm, backtracking algorithm,
dynamic programming
``````

### Learn by doing

There are many websites for deliberate practicing data structures and algorithms, I recommend these two, which both contain excellent online judge system:

• Leetcode: which contains almost all the interview questions frequently asked by big companies(like Facebook, Google, Amazon), it's a very helpful resource for interviewing.
• HackerRank: which has very clean categories for data structures and algorithms, even contains problems of mathematics, database, and security. And you can also enter the programming contest for fun.

Another good practice is finishing some trivial projects which using one specific data structure or algorithm.

For example, this project creates a Maze with the data structure of “union-set” and also tries to implement pathfinding algorithms. Finish this kind of projects will build your confidence, and also lets you realize it’s useful for creating real applications.

## Get deeper

### More books

Introduction to Algorithms, 3rd Edition is for your deeper studying, the algorithm reason part is awesome and also has more details on complexity analysis and mathematical tools.

And the final book is: The Art of Computer Programming, very few programmers have finished reading all this book. This is the ultimate and authoritative reference for you to dig deeper, this book almost covers all the corners of programming, especially about data structures and algorithms.

### Learn from real projects

Knowledge and skill will only prove the value when they are applied to products.

You could learn much from existing products and applications.

For instance, are you curious about what data structure or algorithm used for Google’s search suggestion?

Some great open-source projects will be the most useful resources for your learning.

Redis contains many mostly used data structures and has many optimizations on performances. The Linux Kernel also used many data structures like link list, red-black tree, hash, etc.

After more years of practice, data structures will be yous tools for abstraction and algorithms designing will be the natural pattern for your problem-solving.

Keep curiosity and practice!

## Discussion

Ivan Trajanovski

Great article! Just what I was looking for recently.

I recently bought the Algorithms and Data Structures Masterclass by Colt Steele on Udemy. I have been going slowly through and it seems really good for now. Have you or anyone done it, and would you recommend it?

Anwarul Haq

Absolutely, after a week, I feel more confident in solving the problem. Colt way of teaching is really good. I would highly recommend to newbies.

Nick Chen

I didn't learn on Udemy, it will be OK if you feel good.
But practice with coding is necessary for any kind of learning about programming.

G. Berthiaume

+1 for including resource for other programming languages than JS.

Siddhant Chimankar

Great article! I'm using GeeksForGeeks and LeetCode and can't recommend them enough!

Zak

Thanks a lot for sharing. DS and Algorithms has been like a road block for me in my programming career. This article has given me a lot of clarity and confidence approaching it again.

Duhita D

Amazing article, I finally got clarity!! thank you

Keramot UL Islam

Thanks for sharing visualgo.net, this is one of the best learning sites I ever have seen.

Nick Chen

Iamsbharti

Inspirational findings and path , I will start the process again after 2years of my job experience. I had left practicing the actual stuff ,but I think it will help me to get through.

SVR

This is a nice article. I realised I was on the right track but not completely following it out of anxiety. Also saw new pointers. Thank you!