Guide to Learn Data Structures and Algorithms and Crack the Coding Interview

Most programmers realize the importance of data structure and algorithms as early as possible in their career. The reason is simple: knowledge of this subject helps us grow as a smart programmer. On another side, Interviewer uses DSA to evaluate candidates during the interview. It provides them with a simple approach to test problem-solving skills, coding skills and clarity of thought.

Mastering algorithms and data structure require proper guidance and a continuous learning plan. These questions are important if someone wants to start the DSA journey:

  • How to develop a long-term interest in algorithms and data structures?
  • How to prepare a continuous learning plan to crack the coding interview?
  • What are essential concepts and problem-solving approaches?
  • What critical activities help us to learn quickly?
  • How to prepare for a coding interview in a given time period?

Step 1: Developing a long-term motivation

A long-term motivation is important for learning DSA. We need to explore: Why learning data structure and algorithms are crucial for career growth? What are its real-life applications? Here are some ideas to think about:

  • Designing efficient algorithms is one of the best 21st-century skill.
  • We need to prepare for ups and downs. Once we have basic knowledge about DSA, our problem-solving ability will improve further to the next level.
  • Never giving up is the key. Whenever a thought comes to our mind to give up the problem, we should motivate ourselves, recollect all experiences and give one more best try. Such situations could be one of the defining moments in the journey of learning data structures and algorithms. 
  • Mastering coding problem-solving is always an iterative journey of learning from failures! In other words, think of every error or bug as a new learning opportunity.

Blog to explore: Why should we learn Data Structure and Algorithms?

Step 2: Understanding data structures and algorithms syllabus for coding interview

Now our first goal should be to prepare a list of essential topics in data structure and algorithm. We can also focus on real-life applications to understand the use case of algorithms.

Algorithmic and Mathematical Thinking

Algorithmic puzzles, Brainteaser, Counting, Summation, Numbers theory, Permutation, Mathematical induction, Recurrence relations, Bit manipulation, Probability, etc.

Blog to explore: How to develop algorithmic thinking?

Fundamentals of Programming

Data types, Variables, Operators, Expressions, Control statements, Loops, Functions, Pointers and References, Arrays, Strings, Memory management, Fundamental of OOPS, etc.

Fundamentals of Algorithms

Linear Data Structures

Blog to explore: Introduction to Data Structures

Properties, Structure, Implementation, Basic operations, Patterns of iterative and recursive problem-solving and Real-life applications

  • Array: 1D Array, 2D Array, String, Dynamic Array
  • Linked List: Singly linked list, Doubly linked list, Circular linked list
  • StackQueue, and Dequeue

Non-linear Data Structures

  • Binary Tree: Properties and Structure, Recursive DFS Traversals, Iterative DFS traversal, BFS traversal, Basic operations, Patterns of problem-solving using BFS and DFS traversals, etc.
  • Binary Search Tree: Properties and Structure, BST building, Basic BST operations, BST sort, Patterns of problem-solving in BST, Self-balancing BST, Real-life applications, Comparison with Hash Table.
  • Heap: Properties and Structure, Heap building, Basic heap operations, Heap sort, Patterns of Problem solving, Real-life applications
  • Dictionary and Priority queue: Implementation using array, linked list, BST, heap (Priority queue) and Hash Table (Dictionary), time complexity comparisons of basic operations, and Real-life applications
  • Advanced-Data Structures (Properties, Structure, Basic operations, Patterns of problem-solving and Real-life applications): Trie, Segment Tree, binary indexed tree, K-Dimensional Tree, n-ary tree, suffix tree
  • Graph: Properties, Structure, Types, Adjacency matrix representation, Adjacency list representation, BFS traversal and its properties, DFS traversal and its properties, Problem-solving patterns using DFS and BFS, Topological sorting, Shortest path algorithms, Minimum spanning tree, etc.

Algorithm Design Techniques

Properties, Patterns of problem-solving and Real-life applications

  • Dynamic Programming: Time memory tradeoff, optimization and combinatorial problems, Designing recursive solution of a DP problem, Top-down approach, Bottom-up approach, Bit-masking, Problem-solving patterns, Divide and conquer vs Dynamic programming, etc.
  • Greedy Algorithms: Greedy choice property, Problem solving patterns, DP vs Greedy algorithms
  • Backtracking: Exhaustive Search, Recursive and Iterative Backtracking, Branch and Bound
  • String Algorithms: String matching and Patterns of problem solving
  • Mathematical Algorithms: Numbers theoretic algorithms, Bitwise algorithms, Randomised algorithms

Coding Interview Preparation

  • Continuous practice of coding questions
  • Profile and resume building
  • Preparation via mock Interview
  • Company-specific research of interview process
  • Behavioral interview preparation

Step 3: Collecting the best resources for learning and practice

Our next goal would be to collect the best learning resources: books, blogs, talks, pdf, courses, etc. Internet could be handy for this. We need to follow the authentic sources and organize them according to the above syllabus. Here is the list of some best learning resources:

Data Structures and Algorithms for beginners

Fundamentals of Programming

Data Structures and Algorithms for advanced learners

  • Algorithms by CLRS: Complexity analysis, Divide and Conquer, Sorting, Linear Data Structures, Hash Table, Heap, BST, Graph, Dynamic Programming, Greedy Algorithms, String Algorithms
  • The Algorithm Design Manual by Steven Skiena: Complexity analysis, Sorting and Searching, Linear and Non-linear Data Structures, Backtracking and Dynamic Programming
  • Algorithms by Robert Sedgewick: Complexity analysis, Sorting, Stack, Queue, Priority Queue, Hash Table, Binary Search Tree, Graph, String Algorithms
  • Introduction to Algorithms by MIT Open Courseware

For Advanced Programming Concepts

For Competitive Programming

For data structures and algorithms interview

Step 4: Finding a good mentor and learning community

Our next goal should be to find a good mentor. A mentor can be a person having good conceptual understanding and problem-solving skills. A good mentor can help us in several ways:

  • Learning fundamentals
  • Mastering problem-solving approaches
  • Handling critical doubts
  • Coding interview preparation

In addition to this, an excellent collaborative environment can also work as a catalyst. We can form a group of 2-3 people with similar goals and schedule a weekly discussion. Working as a peer or observer for each other would help bridge the gap between strengths and weaknesses.

If possible, we can also join some groups or online communities to learn from the experiences of other programmers. It can also help resolve DSA doubts and communicate ideas among diverse learners.

Step 5: Preparing a continuous learning and Interview preparation plan

We assume that any professional or student is ready to give an average of 25 hours/week strategically. So, here is a proposed time management plan that one can customize quickly based on personal learning needs.

  • Minimum time on weekdays = 15 Hours
  • Minimum time on weekends = 10 Hours

Based on experience, let's assume:

  • Solving one problem on paper with pseudo-code takes 30 minutes on average.
  • Solving one problem with well-written code takes 1 hour on average.
  • 1 Mock Interview takes 1 hour on average.

4-Week Revision and DSA Interview Preparation Plan

This is recommended for advanced learners who want to revise concepts and warm-up problem-solving skills. Such learners should have a good understanding of algo and data structures, and programming concepts.

  • Minimum estimated time = 25 x 4 = 100 Hours
  • Minimum coding problems to practise = 75
  • Concept revision and Problem-solving research = 25 Hours
  • Problem-solving on paper with pseudocode = 25 Hours (at least 50 coding questions)
  • Problem-solving with coding practice = 25 Hours (at least 25 coding questions)
  • Behavioural interview preparation + Mock interviews = 25 Hours

8-Week Revision and DSA Interview Preparation Plan

This is recommended for learners who want to revise concepts and sharpen problem-solving skills. Such learners should have basic problem-solving skills in data structure and algorithms and good knowledge of programming concepts.

  • Minimum estimated time = 25 x 8 = 200 Hours
  • Minimum coding problems to practise = 150
  • Concept revision and Problem-solving research = 50 Hours
  • Problem-solving on paper with pseudocode = 50 Hours (at least 100 coding questions)
  • Problem-solving with coding practice = 50 Hours (at least 50 coding questions)
  • Behavioural interview preparation + Mock interviews = 50 Hours

12-Week Learning and DSA Interview Preparation Plan

This is recommended for intermediate learners who want to learn advanced DSA concepts and sharpen problem-solving skills. Such learners should have a basic understanding of DSA and programming concepts.

  • Minimum estimated time = 25 x 12 = 300 Hours
  • Minimum coding problems to practise = 200
  • Concept learning/revision and Problem-solving research = 100 Hours
  • Problem-solving on paper with pseudocode = 50 Hours (at least 100 coding questions)
  • Problem-solving with coding practice = 100 Hours (at least 100 coding questions)
  • Behavioural interview preparation + Mock interviews = 50 Hours

24-Week Learning and DSA Interview Preparation Plan

This is recommended for beginners who want to learn fundamentals and sharpen problem-solving skills. Such learners should have basic programming knowledge.

  • Minimum estimated time = 25 x 24 = 600 Hours
  • Minimum coding problems to practise = 300
  • Concept learning and Problem-solving Research = 300 Hours
  • Problem-solving on paper with pseudocode = 100 Hours (at least 200 coding questions)
  • Problem-solving with coding practice = 100 Hours (at least 100 coding questions)
  • Behavioural interview preparation + Mock interviews = 100 Hours

Step 6: Starting continuous learning activities

Concept Learning/Revision

We need to learn concepts in proper order. Preparing a self-note and writing down ideas in a visual format would help significantly in fast revision.

We advise to plan a brainstorming session around each topic with a peer or colleague. If you find any DSA concepts challenging to understand, mark them, revisit them later or take help from a mentor. Continuously learning and never giving up is the basic idea.

Top 20 data Structures and algorithms concepts to master

Top algorithms and data Structures concepts for coding interview preparation

Problem-solving research

Finding various patterns via coding problems is one of the best approaches to mastering the problem-solving skill. The critical questions are: what are the important problem-solving ideas to learn? What would be the best approach to solve a coding problem? Before starting problem-solving, we recommend an in-depth analysis of each problem-solving approach via 3-4 coding problems.

Blog to explore: Popular Problem-Solving Approaches in Data Structures and Algorithms

Top 20 algorithms to learn Problem-solving

Top 20 algorithms to learn problem solving in Data Structure and Algorithms

Top 10 problem-solving approaches to master in algorithms

Top 10 problem solving approches for cracking the coding interview

Problem-solving on Paper and Coding Practice

To master problem-solving, paper or a whiteboard can be a handy tool to practice visualisations, solution steps, and pseudo-codes. Writing down algorithm steps and necessary details can help us in designing efficient solutions.

After designing an efficient pseudo-code, our final aim must be to translate each line of pseudo-code into the correct code. Never forget to test code with various input-output data, edge cases, and all boundary conditions. Now once we are done with writing code in a programming language, take care of the following things: 

  • Does this code provide the correct output for every set of inputs?
  • Can we optimize the code further? Always try to improve the code! If possible, look back, analyze it once again, and find a better solution.
  • How can we improve the readability of the code?

Note: For coding practice, we recommend leetcode. One can find several coding problems organized according to the different difficulty levels.

Blog to explore: Steps of problem-solving in Data Structure and Algorithms

Steps of problem solving in algorithms and data structures

Resolving Critical Doubts

Whenever we start learning algorithms and data structure, doubts frequently occur, however big or small. Sometimes critical doubts work as a roadblock in moving ahead. But our aim must be to take every doubt constructively and try to search for a correct answer. Even we should believe doubts as a natural part of learning which could take us to the next level of conceptual depth.

If there is a doubt, first try to resolve it personally. If we fail to get an answer in a limited duration, then there can be several ways to get it fixed:

  • Discussing it with our peer or colleague
  • Getting in touch with a personal or course mentor.
  • Posting the doubts in the coding or learning community.
  • Ignoring the doubts for a moment, noting them down, and revisit later with a fresh approach. Sometimes doubts are related to the later part of the concept's journey.

Behavioral Interview Preparation

If you are preparing for a dream job, then behavioral interviews are essential parts of the interviews. Most programmers underestimate this and do little or no preparation. One of the popular misconceptions is: behavioral interviews are less critical than technical interviews. But the truth is just the opposite: a behavioral interview is one of the vital factors if we want to stand out among several potential candidates.

Behavioral interviews help the interviewer discover how you make decisions in critical situations and decide if you are fit to work with them. So from the interviewer's perspective, it is as essential as our coding interviews.

The idea of behavioral interviews differs from company to company, depending on their values and culture. Here are some tips to prepare for the behavioral interviews:

  • Practice good communication skills
  • Read the job description more than twice
  • Research the industry and company
  • Prepare for common questions
  • Make your sales pitch clear
  • Speak the correct body language
  • Have smart questions for the interviewers
  • Be positive, authentic, and truthful in your answers
  • Stay optimistic and prepare for the challenge

We should have at least one good example of:

  • An interesting technical problem you solved
  • An interpersonal conflict you overcame
  • Some unique execution story about a past project
  • Leadership or ownership
  • Question about the company's product/business
  • Question about the company's engineering strategy.

Interview Preparation via Mock Interviews

We should practice some mock interviews before attending an actual coding interview. The best idea would be to find a partner with similar career goals and simulate mock interviews with each other. At the end of the interview, both the interviewer and interviewees can exchange feedback for improvement. 

When we get feedback from another person, we can identify what we need to work on. Knowing where we need to improve is crucial for creating a plan for a tech interview. We can also record the mock interview session and use the footage to enhance body language for the actual interview.

Things to keep in mind:

  • Ensure that the pairing partner has basic knowledge and problem-solving skills in data structures and algorithms.
  • Use a timer to limit 45 minutes for the mock interview because most coding interviews last around 45-60 minutes.
  • Try to prepare your partner and ensure all checklists to simulate it as an actual tech interview. 
  • After the completion of the mock interview, now take the interviewer's seat. It will help you understand what companies are looking for when evaluating a candidate.

Learning tips for DSA interview

  1. Our goal must be to cover at least 80% syllabus and prioritise topics based on strengths and weaknesses. A topic that requires more time should get more time.
  2. Doing a weekly critical review could help us to understand the progress. We need to think: what is the further scope of improvement in the topic? What is the current level of our problem-solving ability? For the fact-based view, we recommend rating each topic on a scale of 1 to 10.
  3. Few ideas always come during learning DSA: Brute force solution, efficient solution, boundary conditions, time and space complexity analysis, and coding style. Keep preparing notes if you find something unique or essential patterns.
  4. In the starting journey, focus on the top 150 coding interview questions rather than solving many problems. The best idea would be to pick famous coding interview problems which can be solved using various techniques.
  5. Learn to visualize critical operations, implementations, and use cases of each data structure.
  6. Never mind going through the same concepts and problems again and again. This would help in figuring out hidden ideas. Focus on reason and never try to memorise!

Tips for cracking the coding interview

We need to analyze the different interview scenarios and prepare a well-defined strategy. It would help in improving confidence and provide a competitive advantage. Learn from your mistakes and keep improving! 

Here are some essential tips to keep in mind:

  1. After understanding problem during the interview, never waste time trying to think in your head. Get your thoughts down on paper, draw visualisations, write different test inputs and outputs, outline how you would get the given output by hand, write pseudocode steps, and think about translating it into code.
  2. Don't put yourself in a hurry to design an optimal solution at the start. If possible, start with a brute force approach and improve the solution further.
  3. Communication plays a vital role. Keep telling the interviewer how you are trying to approach the problem and discuss the most challenging part you face. Our goal should be to get all the relevant details and hints to reach an efficient solution.
  4. Make sure you are working as a team member to solve the problem. The interviewer is looking for a team player who can solve problems using good collaboration skills.
  5. Don't get discouraged if you'll get stuck because interviewer is looking for your ability to think about the problem from various angles.
  6. Think out loud and explain what you know about the solution idea. Explain what you thought might work and why it won't work. An interviewer might give you a hint.
  7. Try to apply popular problem-solving ideas or patterns relevant to the problem. This could help you design efficient solutions quickly. So many problem-solving approaches come up, again and again, during problem-solving.
  8. Use descriptive variable names and a good coding style.
  9. Test solution for all the edge cases.

A final motivation

A long-term vision, hard work, and consistency are the keys to mastering algorithms and data structure. Always remember this quote: " If the mind is weak, then the situation becomes a problem; if the mind is balanced, then the situation becomes a challenge. But if the mind is strong, then the situation becomes an opportunity". Enjoy learning, Enjoy coding, Enjoy algorithms!

Share on social media:

More blogs to explore

Our weekly newsletter

Subscribe to get weekly content on data structure and algorithms, machine learning, system design and oops.

© 2022 Code Algorithms Pvt. Ltd.

All rights reserved.