Book
Data Structure
Data Structure with C++, Java and Python — Every program you have ever used keeps something: a list of songs, a queue of messages, a map of streets, a catalog of books. How it keeps those things — side by side in a row, linked one to the next, arranged as a tree, scattered into numbered buckets — decides whether the same program answers in a blink or makes you wait.
Overview
Chapters 1 to 3 build the ground: how memory holds data, a C++ refresher from zero, arrays in depth and a first taste of complexity, and a full set-up of VS Code for C++, Java and Python on Windows, macOS and Linux; then searching, from sequential search and its sentinel to binary, interpolation and jump search; then sorting, from bubble, selection and insertion sort through Shell sort, merge sort and quicksort to counting and radix sort, all measured on real data. Chapters 5 to 7 add structures that grow and shrink: stacks and queues with their classic applications — matching brackets, undo and redo, infix to postfix, the function call stack, the circular queue and the deque; pointers, references and functions, with dynamic memory, nullptr, const and smart pointers, and what Java references and Python names do instead; and singly linked lists, with head and tail pointers, dummy head nodes, circular lists and a proof that no memory leaks. Chapters 9 to 11 go further along the links: doubly and circular linked lists with sentinels, a deque and a “recently used” list; recursion, followed frame by frame on the call stack through factorial, Fibonacci, Euclid’s algorithm, fast exponentiation and the Towers of Hanoi, down to the depth limits of each language; and trees and binary search trees, with every traversal, balanced and degenerate shapes and a first look at self-balancing trees. Chapters 13 to 15 finish the journey: graphs, with their representations, breadth-first and depth-first search, connected components, topological sort and a gentle Dijkstra; heaps and priority queues, from sift-up and sift-down to building a heap in linear time, heap sort and top-k; and hashing, with hash functions, collisions and the birthday bound, separate chaining, open addressing, load factor and rehashing measured, and a look inside std::unordered_map, Java’s HashMap and Python’s dict.
Chapters 4, 8, 12 and 16 are Evaluation and Discussion chapters. Each closes one quarter of the book by solving complete problems in full — every problem restated, designed on paper, programmed, tested, run, and explained — with the tempting wrong solution shown and taken apart, and a “check yourself” variant at the end of every problem. The last of them ends by choosing the right data structure for one catalog and measuring every structure of the book against it.
Throughout, one small library grows chapter by chapter: Pustaka Ceria, Indonesian for “Cheerful Library”, a campus library that opens with eight books piled on the floor and a year later owns eighty thousand. Its catalog is stored in an array, searched and sorted; its book-return cart is a stack and its cataloging line a queue; its records are linked, arranged into search trees and hashed by title; its campus map is a graph and its hold requests a heap. Beside it runs Profitina Laundry, the small laundry business that is the hands-on case study of the Profitina books: its day’s orders sorted heaviest first, its regular and express queues, its weekly totals, its service menu as a tree, its website as a graph and its service desk built from a hash map and a priority queue. Each chapter also has a Profitina in Practice section that shows where the same ideas appear in a real product.
Every program in this book was run before its output was printed. The programs are collected, chapter by chapter, in the accompanying Code folder, each chapter with its cpp, java and python versions side by side and a README that explains how to build and run each one in a terminal and in VS Code on Windows, macOS and Linux. Every listing in the book is the file in that folder, character for character.
Inside the Book
- Foundations: C++ Refresher, Memory, and Arrays
- Searching
- Sorting
- Evaluation and Discussion I: Arrays, Searching and Sorting, Solved Step by Step
- Stacks and Queues
- Pointers, References, and Functions
- Singly Linked Lists
- Evaluation and Discussion II: Stacks, Pointers, and Linked Lists at Work
- Doubly and Circular Linked Lists
- Recursion
- Trees and Binary Search Trees
- Evaluation and Discussion III: Recursion at Work on Lists and Trees
- Graphs
- Heaps and Priority Queues
- Hashing and Hash Tables
- Evaluation and Discussion IV: Graphs, Heaps, and Hash Tables at Work
Profitina · profitina.com

