// 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.
Which C++ standard does this page assume?
Standard C++17. C++ began as C with Classes in 1979 and first shipped commercially in 1985; what a compiler flag actually selects today is one of the ISO revisions below, and the committee has published a new one every 3 years since 2011. Build these listings with -std=c++17 and they compile as written.
| Revision | Published as | What it changes for the code on this page |
|---|---|---|
| C++98 | ISO/IEC 14882:1998 | The first ISO C++, and the dialect most data-structures courses still teach from: templates, the STL containers, and raw pointers doing the work. |
| C++03 | ISO/IEC 14882:2003 | A defect-fix revision. Nothing on these pages depends on it, and nothing on these pages is broken by it. |
| C++11 | ISO/IEC 14882:2011 | Where nullptr, auto, range-based for, move semantics and the unordered containers arrive. Every listing here writes nullptr rather than NULL because of it. |
| C++14 | ISO/IEC 14882:2014 | A small revision: generic lambdas and std::make_unique. Used only where it makes ownership clearer. |
| C++17 | ISO/IEC 14882:2017 | What every listing on StuHub targets and was compiled against. If you build these files, build them with -std=c++17. |
| C++20 | ISO/IEC 14882:2020 | Concepts, ranges and std::midpoint. Flagged in the prose where it offers a shorter correct form, never assumed by the code. |
| C++23 | ISO/IEC 14882:2024 | Not used here. Named so you can tell whether a snippet you found elsewhere will compile on a lab machine that predates it. |
Common questions
What is StuHub?
A free C++ data-structures reference published by DUOCODE TECHNOLOGY alongside APRide: 20 topics covering arrays and linked lists, stacks and queues, trees, graphs, sorting and searching — with traced examples, code that was compiled before publishing, and answers that were checked.
How much of it is there?
About 372 minutes of reading at 200 words per minute across the 20 topics, and 79 questions with worked solutions. Nobody is expected to read it end to end — it is written to be entered from a search result at the section you are stuck on.
Which C++ standard do the examples target?
Standard C++17 — ISO/IEC 14882:2017. Every listing was compiled with -std=c++17 and -Wall -Wextra before publication, and the linked-structure examples were also run under AddressSanitizer. Where C++20 offers a shorter correct form, the prose says so rather than quietly using it.
Is StuHub free, and do I need an account?
It is free and there is nothing to sign in to. No login, account or payment is required to read any of it. APRide's ride board has accounts; StuHub does not use them.
Can I use this code in my assignment?
Treat it as a reference, not as an answer key. StuHub is educational material only, it is not coursework, and your own submission rules decide what you may reuse. Every listing was compiled and run before publication, and you should still compile and test anything you take.
Is StuHub connected to Asia Pacific University?
No. It is an independent reference published by DUOCODE TECHNOLOGY, not affiliated with or endorsed by Asia Pacific University or any other institution. It was written for APU students because that is who asked for it, and it is open to anyone.
Where should I check what the standard library really guarantees?
cppreference for the day-to-day answer, and the WG21 working drafts when the exact wording matters — both are linked below. Compiler documentation settles the rest: a warning you cannot explain is usually the compiler being right.
Why is everything written in C++ rather than pseudocode?
Because most of the mistakes worth catching are C++ mistakes, not algorithm mistakes: a lost pointer, a destructor that never runs, an index that underflows because it was unsigned. Pseudocode hides exactly the layer where a data-structures assignment is actually failed.
Where can I check this against the language itself?
Nothing on this page outranks the standard or the library reference. When this page and one of these disagree, they are right and we want to know.
- cppreference — the C++ standard library referenceThe fastest correct answer for what a container or algorithm actually guarantees.
- isocpp.org — the Standard C++ FoundationThe FAQ and the core guidelines, written by the people who define the language.
- ISO/IEC JTC1/SC22/WG21 — the C++ standards committeeWorking drafts of the standard itself, free to read, when the wording is the question.
- GCC online documentationWhat -Wall, -Wextra and the sanitizers used on these listings actually check.
- Microsoft Learn — C++ language documentationThe MSVC view, for readers whose lab machines build with Visual Studio.
Published 2026-07-20 · updated 2026-08-27 · DUOCODE TECHNOLOGY