Topics/Data Structures

Data Structures

312 articles

Core Memory Layouts & Abstract Data Types

Data structures are the foundational building blocks of software engineering. Understanding how data is stored, referenced, and accessed in memory enables you to write code that runs efficiently at scale.

Level: Foundational to Advanced
9 Core Subtopics

Track Curriculum

Subtopics & Modules

9 Modules Available
Module 01
3 Q&A
Beginner

Arrays & Dynamic Arrays

Contiguous memory layout, dynamic sizing, element access, and memory alignment.

15 min readStart Guide
Module 02
3 Q&A
Beginner

Strings & String Manipulation

Immutability vs mutability, pattern matching, StringBuilder, and encoding.

18 min readStart Guide
Module 03
3 Q&A
Intermediate

Linked Lists (Singly, Doubly, & Circular)

Node pointers, dynamic memory allocation, cycle detection, and LRU cache implementation.

22 min readStart Guide
Module 04
3 Q&A
Intermediate

Stacks & Queues

LIFO vs FIFO semantics, monotonic stacks, double-ended queues (deque), and call stack tracking.

20 min readStart Guide
Module 05
3 Q&A
Intermediate

Trees & Binary Search Trees

Hierarchical structures, BFS/DFS traversals, BST balancing, and tree recursion.

25 min readStart Guide
Module 06
3 Q&A
Intermediate

Heaps & Priority Queues

Min-heaps, max-heaps, heapify operations, median maintenance, and Top-K element tracking.

20 min readStart Guide
Module 07
3 Q&A
Advanced

Graphs & Representations

Adjacency matrix vs adjacency list, directed/undirected graphs, Union-Find, and topological sort.

30 min readStart Guide
Module 08
3 Q&A
Intermediate

Hash Tables & Hashing

Hash functions, collision resolution (chaining vs open addressing), load factor, and dynamic rehashing.

20 min readStart Guide
Module 09
3 Q&A
Intermediate

Tries & Prefix Trees

Prefix matching, autocomplete systems, dictionary search, and Trie node structures.

22 min readStart Guide
Track Question Bank
27 Questions Across Modules

Interview Questions by Module Topic

Select a module to view its related questions, or explore all modules organized by seniority level

Filter by Module Topic:
01
Module Topic•3 Questions under this topic

Arrays & Dynamic Arrays

Full Guide & Mechanics

Why does an array provide O(1) random access, and why does dynamic array resizing maintain amortized O(1) append time instead of O(n)?

In-Depth Technical Answer

Arrays store elements in contiguous physical memory slots. Because each slot has a fixed byte width (e.g., 4 bytes for 32-bit integers), the memory controller calculates the target address instantly using arithmetic: Address = Base_Address + (Index * Element_Size). This pointer offset computation is a single CPU instruction, achieving O(1) time regardless of index size. When a dynamic array (like C++ `std::vector`, Java `ArrayList`, or Python `list`) exceeds its capacity, it allocates a new buffer double the current size, copies all existing N elements over, and frees the old buffer (an O(N) operation). However, doubling the capacity means that after copying N items, the next N inserts require no reallocation whatsoever. Summing all doubling operations across N appends yields (1 + 2 + 4 + ... + N) ≈ 2N total copy operations. Dividing 2N total operations by N total inserts yields 2 operations per append on average: O(1) Amortized Time.

Practical Code Exampledynamic_array_amortized.cpp
C++
#include <iostream>
#include <vector>

int main() {
    std::vector<int> numbers;
    
    // Tracking capacity doublings
    for (int i = 1; i <= 16; i++) {
        numbers.push_back(i);
        std::cout << "Element " << i 
                  << " | Size: " << numbers.size() 
                  << " | Capacity: " << numbers.capacity() << "\n";
    }
    return 0;
}

🔍 Code Mechanics (C++): Notice how capacity doubles from 1 -> 2 -> 4 -> 8 -> 16. Each expensive doubling step pays for the subsequent series of instant O(1) pushes, maintaining amortized O(1) complexity.

Senior Architectural TakeawayRandom access is O(1) because memory is contiguous. Capacity doubling ensures reallocations become exponentially rarer, yielding amortized O(1) push operations.

How do you implement the Two-Pointer Dutch National Flag algorithm to sort an array containing 0s, 1s, and 2s in-place with O(n) time and O(1) auxiliary space?

How does CPU cache line architecture (L1/L2 cache spatial locality) impact array traversal performance versus pointer-based structures, and how do you prevent false sharing in concurrent array access?

02
Module Topic•3 Questions under this topic

Strings & String Manipulation

Full Guide & Mechanics

Why are strings immutable in languages like Java and Python, and why does concatenating strings inside a loop cause O(n²) memory overhead?

How do you solve 'Longest Substring Without Repeating Characters' in O(n) time using the Sliding Window pattern and direct character index mapping?

How does the Rabin-Karp Rolling Hash algorithm achieve O(n + m) average pattern matching, and how do you handle hash collisions and modular overflow?

03
Module Topic•3 Questions under this topic

Linked Lists (Singly, Doubly, & Circular)

Full Guide & Mechanics

What are the core performance and memory trade-offs between an Array and a Linked List?

How does Floyd's Cycle-Finding Algorithm (Tortoise and Hare) detect a cycle in a linked list in O(n) time and O(1) space, and how do you locate the exact entry node of the cycle?

How do you architect a high-performance Least Recently Used (LRU) Cache combining a Doubly Linked List and a Hash Map with guaranteed O(1) get and put operations?

04
Module Topic•3 Questions under this topic

Stacks & Queues

Full Guide & Mechanics

How do you implement a FIFO Queue using two LIFO Stacks with amortized O(1) enqueue and dequeue operations?

How does a Monotonic Stack solve the 'Largest Rectangle in Histogram' problem in linear O(n) time instead of O(n²)?

How do you architect a lock-free Single-Producer Single-Consumer (SPSC) Ring Buffer Queue in low-latency systems without mutex contention?

05
Module Topic•3 Questions under this topic

Trees & Binary Search Trees

Full Guide & Mechanics

What are the differences between Preorder, Inorder, and Postorder traversals, and why does Inorder traversal of a Binary Search Tree (BST) produce strictly sorted values?

How do you find the Lowest Common Ancestor (LCA) in a general Binary Tree (not a BST) in O(n) time without storing parent pointers?

Why does the Linux kernel (CFS Scheduler, epoll) and database storage engines prefer Red-Black Trees over AVL Trees despite AVL having stricter height balancing?

06
Module Topic•3 Questions under this topic

Heaps & Priority Queues

Full Guide & Mechanics

How is a Binary Heap stored in a contiguous 1D array, and why is Build-Heap O(n) instead of O(n log n)?

How do you solve the 'Top K Frequent Elements' problem using a Min-Heap of size K in O(n log k) time instead of O(n log n)?

How do you architect a real-time streaming Median Tracker supporting O(log n) insertions and instant O(1) median retrieval using Dual Balanced Heaps?

07
Module Topic•3 Questions under this topic

Graphs & Representations

Full Guide & Mechanics

What are the space and time trade-offs between an Adjacency Matrix and an Adjacency List representation of a graph?

How do you detect cycles in a directed graph using Kahn's Algorithm (BFS In-Degree Topological Sort)?

How does Disjoint Set Union (Union-Find) with Path Compression and Union by Rank achieve near O(1) amortized inverse Ackermann time, and how does it power Kruskal's Minimum Spanning Tree?

08
Module Topic•3 Questions under this topic

Hash Tables & Hashing

Full Guide & Mechanics

What causes a Hash Collision, and what are the operational differences between Separate Chaining and Open Addressing?

Why must custom objects override BOTH equals() and hashCode() together, and what disastrous bugs occur if you only implement one?

Why did Java 8 modify HashMap to convert linked list buckets into Red-Black Trees (TreeBins) when bucket length exceeds 8, and how does this defend against HashDoS attacks?

09
Module Topic•3 Questions under this topic

Tries & Prefix Trees

Full Guide & Mechanics

What is a Trie (Prefix Tree), how does it store strings, and why does search complexity depend strictly on word length L rather than dictionary size N?

How do you design a high-throughput Autocomplete / Typeahead suggestion engine using a Trie augmented with Top-K recommendation caches?

What is a Compressed Trie (Radix Tree / Patricia Trie), and why is it preferred in Linux kernel page caches and IP routing tables over standard Tries?