1. Dynamic Arrays
A dynamic array grows automatically when it runs out of space. Watch what happens when the capacity (initially 4) is reached!
Current Capacity: 4 | Elements: 0
Real-World Examples:
- Shopping Carts: E-commerce sites use dynamic arrays to store items in your cart because they don’t know how many items you will add.
- Social Media Feeds: As you scroll down Twitter or Instagram, new posts are appended to a dynamic array in memory.
- Text Editors: The characters you type into a document are often stored in dynamic arrays that resize as the document gets longer.
2. Singly Linked Lists
Unlike arrays, linked lists aren’t stored in continuous memory. Each “node” holds data and a pointer (arrow) directing you to the next node.
Head is null…
Real-World Examples:
- Music Playlists: A simple playlist acts like a linked list. The current song contains a “pointer” to play the next song in the queue.
- Image Galleries: When you click “Next” on an image viewer, it traverses to the next node in the sequence.
- Turn-Based Games: In multiplayer games (like Monopoly), player turns can be managed in a circular linked list (Player A points to B, B to C, C back to A).
3. Multi-Dimensional Arrays
Think of a 2D array as a grid or a table. Click the button to simulate a loop traversing through the rows and columns (Row-Major Order).
Real-World Examples:
- Digital Images: Every image on your screen is a 2D array of pixels, where each cell represents a specific color (RGB value).
- Board Games: Chessboards, Sudoku puzzles, and Tic-Tac-Toe grids are perfectly represented by 2D arrays (e.g., an 8×8 grid for chess).
- Spreadsheets: Excel and Google Sheets are massive 2D arrays organized by rows and columns to store distinct pieces of data.
Recommended Reading