Real-life uses of stack, queue, heap, graph, array and tree
Filed under Oracle
Free read 1 of 3Stack (LIFO): undo/redo, browser back button, call stack and recursion, bracket matching and expression evaluation. Queue (FIFO): print spooler, task and message queues, CPU scheduling, BFS traversal.
The question
Give real-world applications of common data structures: stack, queue, heap, graph, array and tree.
Approach
Stack (LIFO): undo/redo, browser back button, call stack and recursion, bracket matching and expression evaluation. Queue (FIFO): print spooler, task and message queues, CPU scheduling, BFS traversal.
A heap (priority queue) powers task schedulers by priority, Dijkstra's shortest path, finding top-K items, merging K sorted lists, and median maintenance with two heaps.
Graphs: social networks, maps and routing, dependency resolution, web crawling. Trees: file systems, HTML DOM, database indexes (B-trees), autocomplete (tries), decision trees, parsing (syntax trees).
Arrays give O(1) indexed access and cache-friendly memory: image pixels, lookup tables, buffers, and the base for hash tables, heaps and dynamic lists. Always tie each structure to the operation that makes it a good fit.
Tips
- What they are testing: Linking each data structure to the access pattern it optimises rather than listing generic examples.
- Common mistake: Giving one-word answers with no reason, or mixing up stack and queue use cases.
Related Oracle questions
Collected from public candidate posts and coding forums. Updated Nov 2026.