This repository is a structured collection of Python programs to help understand Data Structures and Algorithms (DSA). It's organized by topics like basic math logic, hash maps, and recursion—ideal for beginners and intermediate programmers.
01_Basic_Maths_Logic
02_Hash_Map_Python
03_Patterns
04_Recursion
05_Searching
Algorithm | Time (Best) | Time (Avg) | Time (Worst) | Space | Requirement |
---|---|---|---|---|---|
Linear Search | O(1) | O(n) | O(n) | O(1) | None |
Binary Search | O(1) | O(log n) | O(log n) | O(1) | Sorted array |
Interpolation Search | O(1) | O(log log n) | O(n) | O(1) | Sorted and uniformly distributed array |
06_Sorting
Algorithm | Time (Best) | Time (Avg) | Time (Worst) | Space | Stable? |
---|---|---|---|---|---|
Bubble Sort | O(n) | O(n²) | O(n²) | O(1) | Yes |
Selection Sort | O(n²) | O(n²) | O(n²) | O(1) | No |
Insertion Sort | O(n) | O(n²) | O(n²) | O(1) | Yes |
Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) | No |
Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) | No |
Counting Sort | O(n + k) | O(n + k) | O(n + k) | O(k) | Yes |
Radix Sort | O(nk) | O(nk) | O(nk) | O(n + k) | Yes |
Bucket Sort | O(n + k) | O(n + k) | O(n²) | O(n + k) | Yes |
07_Array
Easy Level
- Reverse an array
- Check if the array is sorted
- Find the maximum and minimum element in an array
- Second Largest Element in an Array without sorting
- Remove Duplicates from Sorted Array
- Right rotate an array by K places
- Move Zeros to end
- Move all negative number to end
- Sort an array of 0, 1, & 2
- Find missing number in an array
- Find duplicate in an array of N+1 Integers
- Maximum Consecutive Ones
- Find whether an array is a subset of another array
- Merge 2 sorted Arrays
Medium Level
- Union of two arrays
- Intersection of two arrays
- Find the "Kth" max and min element of an array
- Merge 2 sorted arrays without using extra space
- Find if there is any subarray with sum equal to 0
- Find the triplet that sum to a given value
- Find factorial of a large number
- Find longest consecutive subsequence
- Find all elements that appear more than " n/k " times
- Smallest Subarray with sum greater than a given value
Hard Level
08_Matrix
Easy Level
- Print a Matrix in Row-Major Order
- Print a Matrix in Column-Major Order
- Transpose of a Matrix
- Search Element in a Matrix
- Check if Matrix is Symmetric
- Sum of All Elements in a Matrix
Medium Level
- Rotate Matrix by 90 Degrees (Clockwise/Anti-Clockwise)
- Spiral Traversal of Matrix
- Diagonal Traversal of Matrix
- Boundary Traversal of Matrix
- Find Saddle Point in Matrix
- Matrix Multiplication
- Check Identity Matrix
Hard Level
09_String
Easy
- Check whether a String is Palindrome
- Remove duplicate characters from string
- First non-repeating character
- Count vowels, consonants, digits, and special characters
- Anagram check for two strings
- Check whether one string is a rotation of another
- Longest Common Prefix using Sorting
- Check if two strings are isomorphic
Medium
- Roman to Integer Conversion
- Decimal to Roman Numeral (1 to 3999)
- Print all Subsequences of a string
- Print all Permutations of a string
- Balanced Parenthesis Problem
- Group Anagrams
- Longest Substring Without Repeating Characters
- Check if a string is a valid shuffle
Hard
10_Bit_Manipulation
- Python 3.x
- Basic knowledge of Python syntax
More topics like Sorting, Searching, Linked Lists, Stacks, Queues, and Trees will be added soon.
Stay tuned for more! 🚀
Happy Coding! 💻✨