Learning DSA — The right way!

Ashish Papanai
TheWisdomCodes
Published in
4 min readJun 1, 2020

--

A lady is explaining code to her colleague.

Data Structures and Algorithms (DSA, as abbreviated by the Tech Giants) is the fundamental building blocks of Computer Science aptitude. Data Structures come as tools to be used in programming and Algorithms form a set of instructions to be followed will using these tools.

Data Structures are broadly classified into two categories —

  1. Basic Data structures — Array, Linked List, Stack, Queue, HashTable, Graph, Tree.
  2. Advanced-Data Structures — Advanced data structures include, Generic (N-ary Tree), Self Balancing BST (AVL Tree, RBT, ), Trie, Disjoint Set, etc.

Basic Data Structures is the bare minimum requirement that a Computer Science Undergrad student should know, Advanced-Data Structures comprises an ocean of data structures that must be studied as per requirements, For instance, If you are targeting to excel in Competitive Programming, You must try to get your hands on Segment tree, Suffix tree, trie. Whereas some advanced data structures are necessary for coding interview and it gives you an edge and confidence the data structures like BST (AVL), Generic Tree, Disjoint Set.

Coming to the Algorithm part, It’s like religion, No one compels you to use them but you must use them for your good! Some advanced algorithms play an important role in Competitive Programming.

Some basic Algorithms Every programmer should know —

  1. Sorting Algorithms (Selection, Bubble, Quick and Merge Sort)
  2. Searching Algorithms (Linear and Binary Search)
  3. Graph Algorithms (DFS and BFS)
  4. Array range queries
  5. Kadane’s Algorithm
  6. Kruskal and Prims Algorithms
  7. Topological Sort
  8. Disjoint Set Union

The list of algorithms goes endless, the more we dive into algorithms the more we get stuck in this cobweb.

All the data structures and algorithms mentioned are the tools that are listed and provided to you, But can you eat spaghetti with a hammer? One must know how to use the tools provided to him, You can take the deadliest and unknown weapon to war but if you are not familiar with the minute technicalities and the method to use it, You will lose most dreadfully.

How to learn DSA, the Smart way?

Good things brew slowly

Don’t expect drastic results with the theory of DSA, If you fail it implement it on the day of requirement it will be of no use. According to me the best method to start learning DSA is —

  1. Practice writing code in a plain notebook or a simple Google doc, Don’t use IntelliSense some platform and companies may provide you with Intellisense but never rely on it while you practice, consider it as a cherry on the cake when AutoComplete option is enabled.
  2. While you practice consider all approaches of a question you encounter, Start from brute-force approach and then try to think if there’s a way to reduce the complexity further, Don’t jump to the most optimised approach while learning, Learning should always be done in small steps [If you aren’t too late].
  3. Spend 20 mins to think an approach to an easy, easy-medium question, If you are unable to come up with an approach move to the brute force approach, try to understand it (By understanding, I mean to visualise how the code is working for a test case), For medium and hard question never spend more than 40 minutes in finding an approach. [Follow this step for 50 questions of Easy, Medium and Hard categories, respectively]
  4. While you find an approach, try to understand and calculate its time complexity. For every approach, you must have an idea about time complexity and for competitive programming, you must have a rough idea about the running time of the program.
  5. Never hit the submit button after you complete coding, Alway give 5 minutes to analyse the code you have written, consider a quick dry run for all the corner and edge cases, once you are 70% sure of correctness, hit the submit button. Raise this 70% bar as you practice question, raise the bar by 5% after every 10 questions.
  6. Learn from quality resources from trustworthy sources.
  7. Code with your peers, There are numerous groups on telegram for competitive programming, there are various discord servers for the same, Learn from others till you have accomplished 40% knowledge After you cross this mark, you should take only your trustworthy companions with you.

I would love to listen to your views on the learning methodology in the comment section.

Some learning resources to learn Data Structures and Algorithms —

  1. We will be starting with blogs on Medium, where we are planning to write blogs so that you learn through 300 questions of varying difficulty so that you can upgrade from beginner to intermediate level. [We don’t recommend intermediate level coders to rely on blogs, they should focus more on problem-solving]
  2. Algorithms Part — I by Robert Sedgewick, Algorithms Part — II by Robert Sedgewick [Free]
  3. Resources from YouTube — Abdul Bari, CodeNCode, TakeUForward
  4. I recently encountered a Youtube channel for Codechef Editorials — Algorythm, They are pretty fast in uploading explanation videos for CodeChef Competitions.
  5. For textual explanations refer GeeksForGeeks.
  6. For intermediate level programmers focusing on Interview Preparations consider LeetCode as your Bible.

I would be happy to add other resources which are worth mentioning.

Give a man a fish and you feed him for a day,

Teach a man to fish and you feed him for a lifetime.

#LearnDSA series will not be focusing on competitive programming concept, we will be coming with a new series for competitive programming, web development, Machine learning and data science soon!

--

--

Ashish Papanai
TheWisdomCodes

Publishing content on following domain — technology, learning, experiences, poems and blogs!!