π’ Array β Complete Topic Index
Parent: DSA Master Index
π¦ Subtopics
| # | Subtopic | File | Key Concepts |
| 1 | Array Basics | 01-basics/ | Declaration, traversal, CRUD, memory |
| 2 | PHP Array Functions | 02-php-array-functions/ | map, filter, reduce, sort + when to use |
| 3 | Sorting Algorithms | 03-sorting/ | All 12 algorithms, complexity, use cases |
| 4 | Searching | 04-searching/ | Linear search, binary search, patterns |
| 5 | Two Pointers | 05-two-pointers/ | Pair problems, duplicates, reverse |
| 6 | Sliding Window | 06-sliding-window/ | Fixed/variable window, subarray problems |
| 7 | Prefix Sum | 07-prefix-sum/ | Range queries, running totals |
| 8 | Interview Questions | 08-interview-questions/ | Top 30 questions with solutions |
π§ Array β Big Picture
Array
βββ Static Operations β Access O(1), Insert/Delete O(n)
βββ Traversal Patterns β Single loop, nested loop, while
βββ Sorting β 12 algorithms (see subtopic 3)
βββ Searching β Linear O(n), Binary O(log n)
βββ Two Pointers β O(n) solutions for O(nΒ²) problems
βββ Sliding Window β Subarray / substring problems
βββ Prefix Sum β Precompute for O(1) range queries
β±οΈ Time Complexity Cheat Sheet
| Operation | Array | Notes |
| Access by index | O(1) | Direct memory address |
| Search (unsorted) | O(n) | Linear scan |
| Search (sorted) | O(log n) | Binary search |
| Insert at end | O(1) amortized | PHP arrays are dynamic |
| Insert at middle | O(n) | Shift elements |
| Delete at middle | O(n) | Shift elements |
| Sort | O(n log n) | Best general-purpose |
π― Interview Pattern Recognition
See these keywords β Think this:
| Keyword in Question | Technique to Use |
| "subarray of size k" | Sliding Window (Fixed) |
| "longest subarray with..." | Sliding Window (Variable) |
| "pair that sums to X" | Two Pointers |
| "duplicates" | Hash Map or Two Pointers |
| "sorted array, find..." | Binary Search |
| "range sum", "prefix" | Prefix Sum |
| "sort this array" | Quick Sort / PHP sort() |
| "frequency of elements" | Counting Sort / Hash Map |
| "rotate array" | Two Pointers (reverse trick) |
| "merge two sorted arrays" | Merge Sort technique |