Data Structures and Algorithms (DSA for short) is an implementation based course. Many companies stress heavily on concepts from this course in their interviews. In order to master this course, you need to be strong with both the theory and implementation of various Data Structures and Algorithms.
- Read. You should start reading Introduction to Algorithms by Cormen et. all. This book is said to be the best for DSA but it can become a bit difficult to read it while working with your course load. You can instead use this as a reference book supplementing your recommended course book.
- Implement the Data Structures you read about. While reading about them might give you a fair idea of they work, it is different from actual implementation where you will need to take care of boundary cases. There will be cases where you forget null checks and mess up your entire code.
- Understand complexity. You need to be able to calculate the space complexity of various data structures, the time complexity of their operations and the time and space complexities of various algorithms. You should be able to judge which algorithm works better under various conditions.
- Practice. Solve problems from various online judges like codechef, hackerrank, topcoder and spoj. This will help you choose the optimal data structure or algo for a particular problem. You can even search for problems specific to the data structure or algo you want but where’s the fun in that?
Day -∞ to 0
Stick to a programming language like C or C++. Make sure that you are comfortable with pointers/objects.
Understand the concept of Algorithmic complexity. Skip the theory for now, but for every piece of code you write, you should be able to derive both time and space complexity.
Day 2 – 10
Let’s start with some simple data structures,
* Linked Lists
Understand their basic operations (insert, delete, search, traversal) and their complexity – Big-O Algorithm Complexity Cheat Sheet, and code them all.
Day 11 – 25
Let’s now learn some simple algorithms,
* Sorting – Insertion sort, Merge sort, Quick sort, Heap sort, Bucket sort, Counting sort, Radix sort, External sorting
* Search – Linear search, Binary Search (along with its variants).
* Prime Numbers – Sieve of Eratosthenes, Primality test
* Strings – String searching, LCS, Palindrome detection
* Miscellaneous – Euclidean algorithm, Matrix multiplication, Fibonacci Numbers, Pascal’s Triangle, Max Subarray problem
Day 26 – 50
Once you are comfortable with everything above, start doing problems from,
* Cracking the Coding Interview
* Elements of Programming Interviews
* Programming Interviews Exposed: Secrets to Landing Your Next Job
Stick to chapters of arrays, linked lists, strings, stacks, queues and complexity.
Day 51 – 60
Let’s learn some non-linear data structures,
* Binary Tree, Binary Search Tree – Tree traversals, Lowest common ancestor, Depth, Height & Diameter, Finding k-th smallest element
* Hash table – 4 sum problem, Checking if sudoku solution is valid
* Graph – Breadth-first search, Depth-first search, Topological sorting, Minimum spanning tree, Shortest path problem,
Day 61- 90
Refer to the previous resources and start doing problems from trees, hash tables, heaps and graphs.
Day 91 – 100
Day 101 – ∞
You are now better than most of the CS undergrads. Keep revising the above topics and start competitive programming! Good luck!