DEV Community

loading...
Cover image for Complete Roadmap to Learn Data Structure and Algorithms πŸ±β€πŸπŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

Complete Roadmap to Learn Data Structure and Algorithms πŸ±β€πŸπŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

Suchitra
I am enthusiastic about code and technology!!
・Updated on ・7 min read

The very 1st step you have to do is, choose a programming language, either Java or C++ (or it's up to you which language you want to learn).

🎯 Now, start learning the language 1st

Learn giphy

Like…
πŸ“Œ Basic Syntax
πŸ“Œ Data Types
πŸ“Œ Operators, Variables, functions
πŸ“Œ Conditional Statement, loops
πŸ“Œ And the most important OOP(Object-Oriented Programming)


Learn about Collection frameworks if you chose java or STL(Standard Template Library) in C++.
(Or you can skip this as of now).

Now, I can assume that you are a bit familiar with your preferred language.
Like if I say every language has their own unique features/ operations which make them different from others right?

So, my point is that learn the language in such a manner that you don't suffer later.


Suppose, as an example, I am taking Java language here.
So, in this you should know about java…

  • Whether it is a OOP or procedural language?
  • And if OOP, whether it is fully OOP or not?
  • Why java does not support pointers?
  • Why java is a platform independent language?
  • Some features of it!

I will encourage you when you start leaning in any language to ask these type of question and try to explore more.

🎯 Now, you learned the language, got familiar with syntax and OPP concepts. So, It's time to deep dive into DSA(Data Structure and Algorithm).

You may or may not be familiar with this term DSA so, I am just briefing you here or in the alternative, you can search into google baba:πŸ˜€

Let me explain

let me explain

Data Structure and Algorithms play a vital role in solving problems (industrial problem, real scenario problem, etc…)

Basically, DSA is a very crucial thing in a software field as even in real world scenario as well. In day to day life, you may or may not be notice these, or even we don't have any idea related to it…
Like...

Example 1:

In your phone contacts, you must be search some contacts by their name, right?
Here, have you thought that how fast your phone shows you the results?? Probably in secs or even less, right!

How it searches so fast even we have more than 200 or 500 contacts, but it gets back with results within secs
How??

How?

You would be thinking about that, which algorithm it uses or which data structure it uses…??

So, before knowing the data structure, you should know about Time and Space complexity because of it you can analyze your algorithm that how fast and how efficient it is (It's very important concept)!

What exactly is it, and why is it so important?
So, here Asymptotic Notation comes into picture...in this you will be learning about How can you make your algorithms more efficient or more optimized by reducing their time and space complexity.

Basically this concept is very, very important, or I can say it is a building block of your DSA.
In this, you would learn about…

Two type of Complexities:

  • Time
  • Space

Notations:

  • Big-O Notation (Ο) – Big O notation specifically describes worst case scenario.
  • Omega Notation (Ξ©) – Omega(Ξ©) notation specifically describes best case scenario.
  • Theta Notation (ΞΈ) – This notation represents the average complexity of an algorithm.

Then learn about

  • O(1)
  • O(log N)
  • O(N log N)
  • O(N)
  • O(N^2)
  • O(2^N)
  • O(N!)

Graph

You can follow this book for learning these concept


Example : 2

In your phone suppose you opened multiple websites suppose 1, 2, 3, 4 then you tapped in back what you see means in which order the websites appear…
In this way, right!
4 3 2 1 (LIFO) it is the concept of Stack(Which you will be studying in DS)


Example : 3

In day to day life most of you use Google Map right!
Have you ever thought that how easily google find your specified location and get back to you with some results within secs?
(Basically the Graph concept involves here)

Also involves lots of algorithms and logics behind on it.

Now you would have some idea that how important the DSA is!!


So, without any worry, let's get started. Learn the basic Data Structure.
Like 1st know
Types of DS
It is of two Linear and Non-linear

Linear DS

  • Array
  • String
  • Linked list
  • Stack
  • Queue
  • Hash Table etc…

Non-linear

  • Tree
  • Graph
  • Heap etc…

You can learn these from here
Pick those DS one by one and start to learn those.
Now, you can explore or learn Collection frameworks or STL.


🎯 In mean time pick any one of these HackerRank, HackerEarth, Leetcode, Codechef platform for solving the problems and test your understanding on those topics. I will suggest you that just complete one topic in DSA and try to solve some questions(solve topic wise). In this way, you will get more productive results to grasp the concept!


Now learn some basics Algorithms…

Sorting Algorithms

  • Bubble Sort
  • Selection Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort
  • Count Sort etc…

πŸ‘©β€πŸ« Learn it here

Searching Algorithms

  • Linear Search O(N)
  • Binary Search O(log N)

πŸ‘©β€πŸ« Learn it from here

Recursion :

(Grasp the concept very clearly)
It is a technique in which the function call itself again and again until the base case occurs.

πŸ‘©β€πŸ« Learn it from here

Backtracking :

It is itself a recursion, but here it has some additional conditions which makes it more efficient.

Backtracking is an algorithmic-technique for solving problems recursively by trying to build a solution incrementally, one piece at a time, removing those solutions that fail to satisfy the constraints of the problem at any point of time (by time, here, is referred to the time elapsed till reaching any level of the search tree).

Some standard problems

  • Sudoku Solver Problem
  • Rat In Maze
  • Combination sum, Combination Sum II, Combination Sum III
  • N Queen Problem

πŸ±β€πŸ You can visit here
πŸ‘©β€πŸ« Check it here

Greedy Approach :

Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. So the problems where choosing locally optimal also leads to global solution are best fit for Greedy.
For example, consider the Fractional Knapsack Problem.
πŸ‘©β€πŸ« Check it here

Dynamic Programming:

DP = Recursion + some memory

It has two approach:

  • Memoization (Top down πŸ‘‡)
  • Tabulation (Bottom Up ☝)

You can follow these resources to learn the concept

Bit Manipulation / Bit Masking :

  • AND (&)
  • OR (|)
  • XOR (^)
  • NOT (~)
  • Left Shift (<<)
  • Right Shift(>>)

πŸ“Œ Learn from here!

πŸ‘‡ Here as well

πŸ“Œ Another one πŸ˜€


Some Advance Topics :

  • Segment Tree
  • Tries
  • Suffix Tree,
  • Suffix Array,
  • Advance Graph Theory

you are done

Now, it's time to solve problems as much as you can:)
(Practice Makes Man perfect)

Be consistent practicing, initially you will be facing difficulty to solve and even understand the logic by seeing the solution as well. These things are common, it happens to everyone. Just do and don't give up.
(You will be master if you practice 😊)

Participate in contest if you want to test yourself or also interested in CP(Competitive Programming), give it try.

Otherwise, you are good enough for interview if you practice by yourself without giving contest as well!


Some Tips :

  • While solving problems if you don't come up with solution with spending at most 1 hour, I will suggest you leave that question as for that time no need to spend more time on that!
  • Try that question another day or some days later. If still stuck, then you can refer to some editorials or hints.
  • One thing is very important is that suppose you successfully solved some questions πŸ˜€. Congratulations, but still I will suggest going to discussion and see other's solution as well. It will be more insightful, and you can get to know different approaches.
  • And suppose you are in that situation that you can't solve the problem or even seeing the solution, you are unable to think that logic which are used in the solution. So, don't be panic and don't depress. Just dry run the solution, it really helps(Personally it helps me a lot 😊).
  • If still you are thinking that the concept is not so much clear then try to write on paper what you understand the concept via dry running! (Also, you can refer to video lectures).

Some Free Resources

I hope it helps you 😊

Thanks for reading 🧑

image

suchitra_13 image

Discussion (11)

Collapse
hieptl profile image
Hiep Le • Edited

Hi @suchitra_13 , thank you for taking time to write the article.

I think you should specify clearly about the top common data structures and algorithms which would be used in the real-life projects or would be asked in the coding interview.

From my point of view. I think that 80 / 20 principle takes an important role in the learning process. It means that 80% of the result would be achieved by 20% of effort. For this reason, If we could determine common data structures and algorithms, it would help others solve problems in their real-life projects and crack the coding interviews πŸ˜„

In my opinion, we should take care about DSA first before learning any frameworks / libraries. Frameworks / libraries are really important in speeding up the development process. However, if we good at DSA, we could learn any frameworks / libraries very quickly because we are having good mindset and great logical thinking. That's why there are many companies asking about DSA questions in their interviews instead of asking too much questions about frameworks / libraries. We can imagine that we are building a house and we should build a good foundation first before building each floor πŸ˜„

On the other hand, I think we should also consider about databases, operating systems, networking and so on. We do not need to have a computer science degree to learn those things. For example, if you are a Windows user or a MacOS user, you could try to use Linux. Beside that, you should learn about RDBMS before learning NoSQL. Nowadays, many tutorials are sharing about NoSQL, Mongo for beginners. The last but not least, understanding some networking concepts would help you a lot in your daily works. By the way of illustration, my friend who did not have knowledge about networking and then he could not find out how to communicate between the docker container and the outside environment, he found some answers from StackOverflow without understanding about what behind the scenes.

Collapse
suchitra_13 profile image
Suchitra Author

Thanks for pointing out!
Also I will try to include thsose things:)

Collapse
evelinchamp profile image
EvelinCHamp

This was a great article and such an easy read. i appreciated it and the effort you have placed in making it and posting it here. Yes, I think it lacked some explanations but it was actually good. I'll wait for the updates you've mentioned.

Collapse
suchitra_13 profile image
Suchitra Author

@evelinchamp thanks for reading and your kind words, really motivated me to write more!
BTW I didn't explain each topic more cuz it would be very lengthy(in same article it's not possible to explain every topic).
But don't worry I will try to make a series of every topic one by one with detailed explanation!(mean time you can follow resources which I have mentioned)
Just stay tuned!
Thanks:)

Collapse
akglearn profile image
akglearn

These what was dreaming for thanks for these

Collapse
suchitra_13 profile image
Suchitra Author

@akglearn Thanks😊

Collapse
goldenlion7 profile image
Kumar Vivek

Great article Suchi :)

Collapse
suchitra_13 profile image
Suchitra Author

Thanks😁

Collapse
harinivas profile image
Harinivas

Your article was good but I expect more explanation.

Collapse
suchitra_13 profile image
Suchitra Author

will update soon:)

Collapse
suchitra_13 profile image
Suchitra Author

Let me know if you have any suggestions, query or anything
it would be great if I can help you :)