-
Notifications
You must be signed in to change notification settings - Fork 0
README
krishanthan4 edited this page Dec 16, 2025
·
1 revision
Complete guide to all algorithms and data structures in this repository.
- ArrayList - Dynamic array implementation
- LinkedList - Singly linked list
- Stack - LIFO data structure
- Queue - FIFO data structure
- Binary Search Tree - Ordered binary tree
- Min Heap - Priority queue (min at top)
- Max Heap - Priority queue (max at top)
- Trie - Prefix tree for strings
- Graph - Vertex and edge relationships
- HashMap - Hash table with collision handling
- LRU Cache - Least Recently Used cache
- Linear Search - Sequential search
- Binary Search - Divide and conquer search
- Depth First Search - Graph traversal (deep first)
- Breadth First Search - Graph traversal (level-wise)
- Bubble Sort - Simple comparison sort
- Selection Sort - In-place comparison sort
- Insertion Sort - Adaptive comparison sort
- Merge Sort - Divide and conquer sort
- Quick Sort - Efficient in-place sort
- In-Order Traversal - Left → Root → Right
- Pre-Order Traversal - Root → Left → Right
- Post-Order Traversal - Left → Right → Root
- Dijkstra's Algorithm - Shortest path (weighted)
- Topological Sort - DAG ordering
- Fibonacci - Classic DP problem
- 0/1 Knapsack - Optimization problem
- Longest Common Subsequence - String problem
- Start with ArrayList and LinkedList
- Then Stack and Queue
- Move to Linear Search and Binary Search
- Practice simple sorting: Bubble Sort, Insertion Sort
- Binary Search Tree and Heaps
- DFS and BFS
- Merge Sort and Quick Sort
- Graph implementation
- Trie and advanced trees
- LRU Cache and HashMap
- Dijkstra's Algorithm
- Dynamic Programming problems
| Structure | Access | Search | Insert | Delete | Space |
|---|---|---|---|---|---|
| ArrayList | O(1) | O(n) | O(n) | O(n) | O(n) |
| LinkedList | O(n) | O(n) | O(1) | O(1) | O(n) |
| Stack | O(1) | O(n) | O(1) | O(1) | O(n) |
| Queue | O(1) | O(n) | O(1) | O(1) | O(n) |
| BST (avg) | O(log n) | O(log n) | O(log n) | O(log n) | O(n) |
| Heap | O(n) | O(n) | O(log n) | O(log n) | O(n) |
| Hash Table | O(1) | O(1) | O(1) | O(1) | O(n) |
| Algorithm | Best | Average | Worst | Space |
|---|---|---|---|---|
| Linear | O(1) | O(n) | O(n) | O(1) |
| Binary | O(1) | O(log n) | O(log n) | O(1) |
| DFS | O(V+E) | O(V+E) | O(V+E) | O(V) |
| BFS | O(V+E) | O(V+E) | O(V+E) | O(V) |
| Algorithm | Best | Average | Worst | Space | Stable |
|---|---|---|---|---|---|
| Bubble | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Selection | O(n²) | O(n²) | O(n²) | O(1) | No |
| Insertion | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Merge | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
| Quick | O(n log n) | O(n log n) | O(n²) | O(log n) | No |
ArrayList vs LinkedList:
- Use ArrayList for random access
- Use LinkedList for frequent insertions/deletions at beginning
Stack vs Queue:
- Use Stack for LIFO (undo, backtracking)
- Use Queue for FIFO (scheduling, BFS)
Binary Search:
- Only works on sorted arrays
- Much faster than linear search for large datasets
Sorting Algorithms:
- Bubble/Selection/Insertion: Simple, good for small or nearly sorted data
- Merge Sort: Guaranteed O(n log n), stable, uses extra space
- Quick Sort: Usually fastest in practice, in-place but not stable
Graph Traversal:
- DFS: Path finding, cycle detection, topological sort
- BFS: Shortest path (unweighted), level-order traversal
- Understand before implementing - Read the guide thoroughly
- Draw it out - Visualize on paper
- Think about edge cases - Empty, single element, duplicates
- Analyze complexity - Time and space
- Test incrementally - One method at a time
Data Structures (Must Know):
- Arrays and Strings
- Linked Lists
- Stacks and Queues
- Hash Tables
- Trees (especially BST)
- Heaps
- Graphs
Algorithms (Must Know):
- Binary Search
- DFS and BFS
- Sorting algorithms
- Basic Dynamic Programming
- Two Pointers
- Sliding Window
- Master one topic at a time
- Do 5-10 problems per topic
- Review and redo difficult problems
- Time yourself after comfortable with concepts
- Practice explaining solutions out loud
Each wiki guide includes:
- Problem description
- Complexity analysis
- How it works
- Implementation hints
- Common pitfalls
- Practice problems
- Related topics
Remember: Don't look at solutions immediately! Struggle is part of learning.
Happy Learning! 🚀