Back to Study Material Data Structures and Algorithms

Data Structures and Algorithms Complete Guide

A simple DSA guide covering arrays, strings, linked lists, stacks, queues, hashing, sorting, trees, graphs, DP, greedy, backtracking, and practice.

Data Structures and Algorithms Complete Guide

Introduction to DSA

Introduction to DSA is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Data Structures Overview

Data Structures Overview is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Algorithms Overview

Algorithms Overview is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Need of Data Structures

Need of Data Structures is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Types of Data Structures

Types of Data Structures is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Abstract Data Types

Abstract Data Types is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Time Complexity

Time Complexity is used to measure how efficient an algorithm is. Time complexity counts how running time grows, and space complexity counts extra memory use. For exams, always connect the answer with input size n.

Space Complexity

Space Complexity is used to measure how efficient an algorithm is. Time complexity counts how running time grows, and space complexity counts extra memory use. For exams, always connect the answer with input size n.

Asymptotic Notation

Asymptotic Notation is used to measure how efficient an algorithm is. Time complexity counts how running time grows, and space complexity counts extra memory use. For exams, always connect the answer with input size n.

Big O Notation

Big O Notation is used to measure how efficient an algorithm is. Time complexity counts how running time grows, and space complexity counts extra memory use. For exams, always connect the answer with input size n.

Omega and Theta Notation

Omega and Theta Notation is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Best Average Worst Case

Best Average Worst Case is used to measure how efficient an algorithm is. Time complexity counts how running time grows, and space complexity counts extra memory use. For exams, always connect the answer with input size n.

Recursion Basics

Recursion Basics is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Iteration vs Recursion

Iteration vs Recursion is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Arrays

Arrays is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Array Operations

Array Operations is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Prefix Sum

Prefix Sum is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Kadane Algorithm

Kadane Algorithm is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Two Pointer Technique

Two Pointer Technique is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Sliding Window Technique

Sliding Window Technique is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Matrix

Matrix is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Sparse Matrix

Sparse Matrix is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Strings

Strings is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Pattern Searching

Pattern Searching is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

KMP Algorithm

KMP Algorithm is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Rabin Karp Algorithm

Rabin Karp Algorithm is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Z Algorithm

Z Algorithm is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

String Hashing

String Hashing is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Linked List

Linked List stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Singly Linked List

Singly Linked List stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Doubly Linked List

Doubly Linked List stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Circular Linked List

Circular Linked List stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Linked List Insertion

Linked List Insertion stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Linked List Deletion

Linked List Deletion stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Reverse Linked List

Reverse Linked List stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Detect Loop in Linked List

Detect Loop in Linked List stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Merge Two Sorted Lists

Merge Two Sorted Lists stores data in nodes where each node points to another node. It is useful when insertion and deletion are frequent. For exams, draw nodes and arrows because pointer changes are the main idea.

Stack

Stack follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Stack Operations

Stack Operations follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Infix Prefix Postfix

Infix Prefix Postfix is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Balanced Parentheses

Balanced Parentheses follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Monotonic Stack

Monotonic Stack follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Queue

Queue follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Circular Queue

Circular Queue follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Deque

Deque follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Priority Queue

Priority Queue follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Queue using Stacks

Queue using Stacks follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Stack using Queues

Stack using Queues follows last-in-first-out order. It is useful for brackets, expression conversion, undo operations, recursion, and next-greater-element type problems. Remember push, pop, and top.

Linear Search

Linear Search is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Binary Search

Binary Search is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Ternary Search

Ternary Search is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Lower Bound and Upper Bound

Lower Bound and Upper Bound is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Bubble Sort

Bubble Sort is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Selection Sort

Selection Sort is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Insertion Sort

Insertion Sort is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Merge Sort

Merge Sort is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Quick Sort

Quick Sort is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Heap Sort

Heap Sort is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Counting Sort

Counting Sort is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Radix Sort

Radix Sort is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Hashing

Hashing is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Hash Table

Hash Table is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Collision Handling

Collision Handling is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Hash Map

Hash Map is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Tree Data Structure

Tree Data Structure is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Binary Tree

Binary Tree is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Tree Traversals

Tree Traversals is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Binary Search Tree

Binary Search Tree is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

AVL Tree

AVL Tree is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Red Black Tree

Red Black Tree is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Heap

Heap is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Min Heap and Max Heap

Min Heap and Max Heap is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Segment Tree

Segment Tree is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Fenwick Tree

Fenwick Tree is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Sparse Table

Sparse Table is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Trie

Trie is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Suffix Tree

Suffix Tree is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Suffix Array

Suffix Array is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Lowest Common Ancestor

Lowest Common Ancestor is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Graph Data Structure

Graph Data Structure is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Graph Representation

Graph Representation is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Breadth First Search

Breadth First Search is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Depth First Search

Depth First Search is used to find an item or answer quickly. Linear search checks one by one, while binary search removes half of the range each step when the data or answer space is sorted.

Topological Sorting

Topological Sorting arranges data in a useful order. Sorting helps searching, grouping, duplicate checking, greedy problems, and many interview questions. Compare sorting algorithms by time complexity, space use, and stability.

Cycle Detection

Cycle Detection is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Minimum Spanning Tree

Minimum Spanning Tree is used for hierarchical or range-based data. Trees have parent-child links, heaps help get min or max quickly, tries store words, and range structures answer interval queries efficiently.

Kruskal Algorithm

Kruskal Algorithm is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Prim Algorithm

Prim Algorithm is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Shortest Path

Shortest Path is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Dijkstra Algorithm

Dijkstra Algorithm is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Bellman Ford Algorithm

Bellman Ford Algorithm is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Floyd Warshall Algorithm

Floyd Warshall Algorithm is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Disjoint Set Union

Disjoint Set Union is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Connected Components

Connected Components is used when objects are connected with links. Graphs model roads, networks, friendships, and dependencies. Learn representation first, then traversal, shortest path, cycle detection, and minimum spanning tree.

Greedy Algorithms

Greedy Algorithms chooses the best-looking option at each step. It works only when local choices lead to the final best answer. Always explain why the greedy choice is safe.

Activity Selection

Activity Selection is an important DSA topic. Learn what problem it solves, how the steps work, what time and space complexity it has, and one small example with input and output.

Fractional Knapsack

Fractional Knapsack solves problems by reusing answers of smaller subproblems. It is useful when recursion repeats the same work. For exams, write state, transition, base case, and final answer.

Dynamic Programming

Dynamic Programming solves problems by reusing answers of smaller subproblems. It is useful when recursion repeats the same work. For exams, write state, transition, base case, and final answer.

Memoization

Memoization solves problems by reusing answers of smaller subproblems. It is useful when recursion repeats the same work. For exams, write state, transition, base case, and final answer.

Tabulation

Tabulation solves problems by reusing answers of smaller subproblems. It is useful when recursion repeats the same work. For exams, write state, transition, base case, and final answer.

Longest Common Subsequence

Longest Common Subsequence solves problems by reusing answers of smaller subproblems. It is useful when recursion repeats the same work. For exams, write state, transition, base case, and final answer.

Longest Increasing Subsequence

Longest Increasing Subsequence solves problems by reusing answers of smaller subproblems. It is useful when recursion repeats the same work. For exams, write state, transition, base case, and final answer.

0 1 Knapsack

0 1 Knapsack solves problems by reusing answers of smaller subproblems. It is useful when recursion repeats the same work. For exams, write state, transition, base case, and final answer.

Matrix Chain Multiplication

Matrix Chain Multiplication is used for problems where data is kept in order. Many DSA questions become easier by scanning indexes, using prefix sums, using two pointers, or maintaining a window. Draw the index positions before solving.

Backtracking

Backtracking tries possible choices and goes back when a choice fails. It is useful in puzzles, combinations, permutations, and constraint problems. Draw the decision tree to understand it.

N Queens Problem

N Queens Problem tries possible choices and goes back when a choice fails. It is useful in puzzles, combinations, permutations, and constraint problems. Draw the decision tree to understand it.

Rat in a Maze

Rat in a Maze tries possible choices and goes back when a choice fails. It is useful in puzzles, combinations, permutations, and constraint problems. Draw the decision tree to understand it.

Branch and Bound

Branch and Bound tries possible choices and goes back when a choice fails. It is useful in puzzles, combinations, permutations, and constraint problems. Draw the decision tree to understand it.

Bit Manipulation

Bit Manipulation is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

Number Theory for DSA

Number Theory for DSA is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

Modular Arithmetic

Modular Arithmetic is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

Sieve of Eratosthenes

Sieve of Eratosthenes is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

Computational Geometry Basics

Computational Geometry Basics is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

Divide and Conquer

Divide and Conquer is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

Randomized Algorithms

Randomized Algorithms is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

Online Algorithms

Online Algorithms is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

DSA Interview Questions

DSA Interview Questions is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

DSA Practice Problems

DSA Practice Problems is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

DSA Quiz

DSA Quiz is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

DSA Roadmap

DSA Roadmap is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

DSA Sheet

DSA Sheet is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

Competitive Programming

Competitive Programming is for practicing DSA problem solving. Read the idea, solve simple examples, then try mixed problems with a timer. Always write the algorithm and complexity after solving.

DSA Study Path

ArraysStacksTreesGraphsDP

Problem Solving Map

InputChoose DSAlgorithmComplexityAnswer