Skip to content

Sayar-212/CompleteDSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DSA Notes - Complete Guide for 2nd Year Engineering

Comprehensive Data Structures and Algorithms reference with 200+ implementations covering all topics from basic to advanced competitive programming.


πŸ“š All Topics Covered (23 Topics - 200+ Algorithms)

βœ… 01. Arrays (22 Algorithms)

Reverse, Find Max/Min, Kadane's Algorithm, Rotate Array, Two Sum, Three Sum, Remove Duplicates, Move Zeros, Find Missing Number, Find Duplicate (Floyd's), Merge Sorted Arrays, Sliding Window Maximum, Subarray with Sum, Longest Subarray Sum K, Prefix Sum, Product Except Self, Trapping Rain Water, Container With Most Water, Next Permutation, Search Rotated Array, Majority Element (Boyer-Moore), Stock Buy Sell

βœ… 02. Strings (16 Algorithms)

Palindrome Check, Anagram Check, Reverse String, Reverse Words, Longest Palindromic Substring, KMP Pattern Matching, Rabin-Karp, Z Algorithm, Longest Common Prefix, String to Integer (atoi), Group Anagrams, Valid Parentheses, Longest Substring Without Repeating, Count and Say, Remove Duplicates, String Permutations

βœ… 03. Linked Lists (7 Operations)

Insert at Head, Reverse Linked List, Detect Cycle (Floyd's), Find Middle, Merge Two Sorted Lists, Remove Nth from End, Palindrome Check

βœ… 04. Stacks (5 Problems)

Valid Parentheses, Next Greater Element, Min Stack (O(1) getMin), Evaluate Postfix Expression, Largest Rectangle in Histogram

βœ… 05. Queues (6 Problems)

Circular Queue, Queue Using Stacks, First Non-Repeating Character, Sliding Window Maximum, Reverse Queue, Generate Binary Numbers

βœ… 06. Recursion (9 Problems)

Factorial, Fibonacci, Power (Fast Exponentiation), Generate Subsets, Generate Permutations, Tower of Hanoi, N-Queens Problem, Solve N-Queens, Combination Sum

βœ… 07. Sorting (7 Algorithms)

Bubble Sort O(nΒ²), Selection Sort O(nΒ²), Insertion Sort O(nΒ²), Merge Sort O(n log n), Quick Sort O(n log n), Heap Sort O(n log n), Counting Sort

βœ… 08. Searching (8 Variants)

Linear Search, Binary Search (Iterative), Binary Search (Recursive), First Occurrence, Last Occurrence, Search in Rotated Array, Find Peak Element, Square Root (Binary Search)

βœ… 09. Hashing (6 Problems)

Two Sum, Subarray with Sum 0, Longest Subarray with Sum K, Count Distinct Elements, First Repeating Element, Group Anagrams

βœ… 10. Trees (10 Operations)

Inorder Traversal, Preorder Traversal, Postorder Traversal, Level Order Traversal (BFS), Height of Tree, Diameter of Tree, Lowest Common Ancestor (LCA), Check if Balanced, Mirror Tree, Path Sum

βœ… 11. Binary Search Trees (8 Operations)

Insert Node, Search Node, Delete Node, Find Min Value, Validate BST, Kth Smallest Element, LCA in BST, Sorted Array to BST

βœ… 12. Heaps (5 Problems)

Min Heap Implementation, Max Heap (priority_queue), Kth Largest Element, Merge K Sorted Arrays, Find Median from Stream

βœ… 13. Graphs (13 Algorithms)

DFS (Depth-First Search), BFS (Breadth-First Search), Cycle Detection (Directed), Topological Sort, Dijkstra's Shortest Path, Bellman-Ford Algorithm, Floyd-Warshall (All Pairs), Prim's MST, Kruskal's MST, Tarjan's SCC, Find Bridges, Articulation Points, Bipartite Check

βœ… 14. Dynamic Programming (20 Problems)

Fibonacci (Memoization), 0/1 Knapsack, Unbounded Knapsack, Longest Common Subsequence (LCS), Longest Common Substring, Longest Increasing Subsequence (LIS), Longest Palindromic Subsequence, Edit Distance (Levenshtein), Matrix Chain Multiplication (MCM), Coin Change - Min Coins, Coin Change - Ways, Subset Sum, Partition Equal Subset, Rod Cutting, Egg Dropping, Palindrome Partitioning (Min Cuts), Climbing Stairs, House Robber, Minimum Path Sum (Grid), Unique Paths (Grid)

βœ… 15. Greedy Algorithms (5 Problems)

Activity Selection, Fractional Knapsack, Minimum Coins (Greedy), Job Sequencing, Minimum Platforms

βœ… 16. Backtracking (5 Problems)

Sudoku Solver, Rat in Maze, Generate Parentheses, Word Search, Graph Coloring

βœ… 17. Tries (5 Operations)

Insert Word, Search Word, Starts With (Prefix), Delete Word, Longest Common Prefix

βœ… 18. Advanced Trees (2 Implementations)

Red-Black Tree (Insert with rotations), AVL Tree (Insert with balancing)

βœ… 19. Bit Manipulation (16 Algorithms)

Check if Bit is Set, Set Bit, Clear Bit, Toggle Bit, Check Power of 2, Count Set Bits (Brian Kernighan's), Find Single Number (XOR), Two Single Numbers, Reverse Bits, Swap Without Temp, Find Missing Number (XOR), Generate All Subsets, Maximum XOR of Two Numbers, Count Bits from 0 to n, Add Binary Strings, Divide Using Bit Manipulation

βœ… 20. Divide and Conquer (10 Algorithms)

Merge Sort, Quick Sort, Binary Search (Recursive), Maximum Subarray (D&C), Count Inversions, Closest Pair of Points, Strassen's Matrix Multiplication, Karatsuba Multiplication, Median of Two Sorted Arrays, Kth Smallest Element

βœ… 21. Segment Trees (3 Implementations)

Range Sum Query, Range Min/Max Query, Lazy Propagation (Range Updates)

βœ… 22. Disjoint Set Union (5 Problems)

DSU with Path Compression, Kruskal's MST using DSU, Cycle Detection, Count Connected Components, Friend Circles

βœ… 23. Math Algorithms (15 Algorithms)

GCD (Euclidean), LCM, Prime Check, Sieve of Eratosthenes, Prime Factorization, Modular Exponentiation, Modular Inverse, nCr (Combinations), Fibonacci (Matrix Exponentiation), Catalan Numbers, Extended GCD, Count Divisors, Sum of Divisors, Euler's Totient Function, Fast Multiplication (Karatsuba)


πŸ“ Folder Structure

Each topic folder contains:

  • README.md - Concepts, theory, time/space complexity, important problems
  • Code file (.cpp) - Clean, minimal implementations of all algorithms
DSA notes/
β”œβ”€β”€ 01_Arrays/
β”‚   β”œβ”€β”€ arrays.cpp
β”‚   └── README.md
β”œβ”€β”€ 02_Strings/
β”‚   β”œβ”€β”€ strings.cpp
β”‚   └── README.md
β”œβ”€β”€ ... (21 more topics)
└── README.md (this file)

🎯 How to Use

  1. Navigate to any topic folder (e.g., 01_Arrays/)
  2. Read README.md for theory, complexity analysis, and problem patterns
  3. Study the .cpp file for implementations
  4. Practice problems mentioned in each README
  5. Implement yourself before checking solutions

πŸ“– Recommended Study Order

Phase 1: Beginner (Weeks 1-4)

β†’ Arrays β†’ Strings β†’ Linked Lists β†’ Stacks β†’ Queues

Focus: Basic data structures, two pointers, sliding window

Phase 2: Intermediate (Weeks 5-8)

β†’ Recursion β†’ Sorting β†’ Searching β†’ Hashing β†’ Trees β†’ BST

Focus: Recursion patterns, sorting algorithms, tree traversals

Phase 3: Advanced (Weeks 9-12)

β†’ Heaps β†’ Graphs β†’ Dynamic Programming β†’ Greedy β†’ Backtracking

Focus: Graph algorithms, DP patterns, optimization techniques

Phase 4: Expert (Weeks 13-16)

β†’ Tries β†’ Advanced Trees β†’ Bit Manipulation β†’ Divide & Conquer β†’ Segment Trees β†’ DSU β†’ Math Algorithms

Focus: Advanced data structures, competitive programming


πŸš€ Quick Complexity Reference

Data Structure/Algorithm Time Complexity Space Complexity
Array Access O(1) O(1)
Binary Search O(log n) O(1)
Merge/Quick Sort O(n log n) O(n) / O(log n)
Hash Table Insert/Search O(1) avg O(n)
BFS/DFS O(V+E) O(V)
Dijkstra O((V+E) log V) O(V)
Dynamic Programming O(nΒ²) typical O(n) to O(nΒ²)
Segment Tree Query O(log n) O(n)
DSU Find/Union O(Ξ±(n)) β‰ˆ O(1) O(n)

πŸ’‘ Learning Tips

βœ… Understand patterns, not just memorize code βœ… Practice complexity analysis for every algorithm βœ… Implement yourself before checking solutions βœ… Solve variations of each problem βœ… Focus on problem-solving approach over syntax βœ… Review regularly - spaced repetition works βœ… Time yourself when practicing


πŸŽ“ Perfect For

  • βœ… 2nd Year Engineering DSA Course
  • βœ… DAA (Design & Analysis of Algorithms)
  • βœ… Competitive Programming (Codeforces, CodeChef, LeetCode)
  • βœ… Interview Preparation (FAANG, Product Companies)
  • βœ… College Exams & Placements

πŸ“Š Coverage Summary

  • Total Topics: 23
  • Total Algorithms: 200+
  • Lines of Code: 5000+
  • Coverage: Basic β†’ Advanced β†’ Competitive Programming
  • Language: C++ (STL optimized)

πŸ† Interview Focus - Top 50 Must-Know

Arrays: Kadane's, Two Sum, Trapping Water, Stock Buy Sell
Strings: KMP, Longest Palindrome, Valid Parentheses
Linked List: Reverse, Cycle Detection, Merge
Trees: All Traversals, LCA, Diameter, Validate BST
Graphs: DFS, BFS, Dijkstra, Topological Sort
DP: 0/1 Knapsack, LCS, LIS, MCM, Coin Change, Edit Distance
Backtracking: N-Queens, Sudoku
Advanced: Segment Trees, DSU, Bit Manipulation


🌟 Company-Wise Focus

Google: DP, Graphs, Trees, Math
Amazon: Arrays, Strings, DP, Trees
Microsoft: Trees, Graphs, DP, Recursion
Facebook/Meta: Graphs, DP, Backtracking
Competitive Programming: All topics, especially Math, Bit Manipulation, Segment Trees


All implementations are minimal, efficient, and interview-ready! Good luck with your DSA journey! πŸš€πŸŽ“

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages