// STUHUB · STUDY NOTES
StuHub: study notes, written by a student who sat the same papers
Free study notes for APU students, open to anyone. The first subject is C++ data structures: arrays and linked lists, stacks and queues, trees, graphs, sorting and searching — with worked traces, code that was compiled before publishing, and answers that were checked.
Direct answer
StuHub is a free set of study notes — no login, no account, no payment. It starts with C++ data structures, the subject its author needed most, and grows as more gets written. Every page gives you a worked step-by-step trace, C++ that was compiled and run before it was published, the complexity with the reasoning behind it, the mistakes that actually cost marks, and exercises with full solutions.
Guide index
Arrays in Memory, Parameters, and Structs vs Classes: the C++ Layer Under Every Data Structure
Arrays in memory, what a function really receives when you pass one, and the struct-versus-class rules the rest of these pages assume you already know.
C++ Pointers: The Three-Level Memory Model
A pointer is three separate things: its own address, the address inside it, and the data there. Get that straight and Node* versus Node*& stops being mysterious.
Linked List vs Array: Memory, Access Cost, and Insert/Delete
Contiguous memory versus pointer chains: where O(1) indexing comes from, what insert and delete really cost, and the new/delete rules.
Doubly and Circular Linked Lists in C++: Pointer-Write Order and Termination
Four pointer writes whose order decides whether you lose the rest of the list, and why a circular list cannot be walked with the null test you have been using.
Stacks in C++: Array vs Linked Implementation, Overflow, Underflow, and Balanced Parentheses
Building the stack the other pages borrow: where top points, why pop must save before it decrements, and the two conditions that are overflow and underflow.
Circular Queue Wraparound and Linked-List Queue Pointers in C++
False overflow, modulo wraparound, telling full from empty, and the front/rear pointer pair that dangles when the last node leaves.
Infix to Postfix Conversion and Postfix Evaluation with a Stack (C++)
Shunting-yard conversion traced character by character, then postfix evaluation — including the operand-order bug that returns plausible wrong answers.
Tree Terminology and Binary Tree Shapes: Depth, Height, Full vs Complete
Depth, height, degree and level, the shape vocabulary from full to degenerate, and the counting formulas — including the edges-versus-nodes clash that makes two correct answers differ by one.
BST Traversals: Inorder, Preorder, Postorder (and Rebuilding the Tree)
Inorder, preorder and postorder: why inorder sorts, why postorder is the only safe teardown, and how to rebuild a tree from two traversals.
Representing a Graph in C++: Adjacency Matrix vs Adjacency List, and Degree in Directed Graphs
Building a graph before traversing one: matrix against list, the space and lookup trade-off behind every O(V+E), and in-degree versus out-degree on a directed edge.
BFS vs DFS: Graph Traversal Traced Step by Step
One labelled graph, both traversals traced step by step, and the mark-on-push versus mark-on-pop choice that changes the answer.
Dijkstra, Prim, Kruskal and Topological Sort: Choosing the Right Graph Algorithm
Four algorithms that look alike and are not: smallest cumulative distance versus smallest single edge, one growing tree versus a merging forest, and when BFS already is the shortest path.
Identifying Sorting Algorithms from a Snapshot, and the Big-O Cheat Sheet
Name the sort from one mid-run array, derive the Big-O class from the shape of the work, and write a binary search that cannot overflow.
C++ Data Structure Drills: Fill in the Blank
Twenty short drills with the lines blanked out — and for each answer, why the tempting wrong one fails.
Data Structures Exam Cheat Sheet (C++ Quick Reference)
Every structure on one screen: declarations, the operations that get asked, the rule that decides the answer, and worked traces for the three that are hardest under time pressure.
Binary Search: Invariants, Off-By-One Bugs, and the Exact Loop That Never Fails
The loop invariant, the three classic off-by-one bugs, and the lower-bound variant — the version you can reproduce under exam pressure.
Hash Tables: Hashing, Collisions, Load Factor, and Open Addressing vs Chaining
Key to slot in three stages, chaining versus open addressing, load factor, rehashing, and the tombstone trap in deletions.
Recursion vs Iteration: Call-Stack Traces, Base Cases, and the Exam Bugs Between Them
Base cases, progress, frame-by-frame call-stack traces, tail calls, and the four planted bugs that tracing questions love.
Binary Heaps and Priority Queues: Sift Up, Sift Down, and Build-Heap
A complete tree inside a plain array: sift up for insert, sift down with the smaller child, and the build-heap argument for O(n).
AVL Tree Rotations: Balance Factors, LL/RR/LR/RL, Traced Step by Step
Balance factors within ±1, the LL/RR/LR/RL repair table, both single rotations traced pointer by pointer, and the update-before-judge trap.
What StuHub is, and what it is not yet
StuHub is a study section on a student product, written by someone taking the same subjects. Right now it covers one subject properly — C++ data structures — rather than covering several badly. Other subjects get added when there is something worth reading, not to fill out a menu.
It is not affiliated with any university and publishes no course material: no past papers, no lecture slides, no revision booklets. Everything here is written from scratch, which is also why the code can be compiled and the answers checked.
Within data structures, StuHub collects the topics that students get asked about most and that hand-written notes usually get subtly wrong: the queue that reports overflow with an empty buffer, the traversal whose answer changes depending on when you mark a vertex visited, the postfix evaluator that returns a plausible number for the wrong reason.
Each article follows the same shape. A direct explanation of the idea, a step-by-step trace on one small fixed example, a complete C++ implementation, the complexity with an argument rather than an assertion, a catalogue of the mistakes that actually happen, and exercises with worked solutions.
How to use it
Read the trace before the code. The tables show the container contents after every single step, which is what a written exam actually asks you to reproduce and what a debugger would otherwise have to tell you.
Then attempt each exercise before opening its solution. The solutions are written out in full — including why a wrong version still compiles, still terminates, and still prints something believable — because that is the failure mode worth recognising.
Scope and honesty about it
The code targets standard C++17 and uses the standard library where a real program would. Where a hand-rolled structure is shown, it is shown with its destructor and its copy rules, because that is where the interesting bugs live.
StuHub is study material, not a substitute for your own course notes or for reading the standard library documentation. Anything you copy from here should be compiled and tested in your own project first.
Published and updated 2026-07-20 · DUOCODE TECHNOLOGY