CT 301 Final Exam - Study Guide (main)
Final Exam - Study Guide
The final is cumulative: it draws on everything from Exam 1 and Exam 2, with a heavy emphasis on the two homeworks. It tells you what is on the exam, where each topic is explained in detail, how the pieces connect across the course, and how to study given that you may bring one cheat sheet.
- Guide 1 = the Exam 1 Study Guide (Lectures 1, 2, 3, 5, 6 and HW#1). Foundations, functions, classes, inheritance, ownership, smart pointers.
- Guide 2 = the Exam 2 Study Guide (Lectures 7, 8, 9, 10 and HW#2). The free store, arrays/pointers, copy/move, templates/exceptions, and the hand-built
ct::Vector.
0. How to use this guide
Study in three passes:
- This guide, top to bottom. Get the shape of the whole course and how the two homeworks tie it together.
- Guide 1 and Guide 2, section by section, using the coverage map below to see what carries the most weight. Work the small code examples in your head or on paper.
- The Practice Problems (Exam 1 and Exam 2 practice sets) to gauge understanding. Do not read practice answers first: you will memorize answers instead of learning concepts, and the exam uses different code for the same concepts.
1. The final at a glance
| Item | Detail |
|---|---|
| When | July 10, 2026, 8:00 am - 8:00 pm Mountain Time (one attempt inside that window) |
| Length | 120 minutes, once you start |
| Weight | 200 points, in its own assignment group |
| Coverage | Cumulative: Lectures 1-3 and 5-10, HW#1, HW#2. Everything from Exam 1 and Exam 2, plus a few questions that tie ideas across the course. |
| Format | The same question types as Exam 1 and Exam 2: true/false, multiple choice, and select all that apply. No fill-in-the-blank, no coded responses. |
| Proctoring | Respondus LockDown Browser + Webcam required (same as Exam 1 and Exam 2). |
| Notes | One cheat sheet (you may use both sides). You may also keep up to 6 sheets of scratch paper, but they must start blank - hold each one up to the webcam before you begin so the proctor can see it is empty. |
2. How to use a cheat sheet on this exam
Because you can bring notes, the questions are not recall. Almost every one shows a short piece of code and asks what actually happens - what it prints, which line compiles, what the capacity becomes, which exception is thrown. A sheet that lists rules will not answer these for you; you have to apply the rule to the specific code in front of you.
So practice tracing code, not memorizing facts. Put the things you might blank on onto your sheet - the growth rule, the rule-of-five checklist, which operations throw which exception, const-pointer vs pointer-const - but spend your study time reading and predicting code. Good candidates for the sheet:
- Growth policy:
new_cap = (capacity == 0) ? 8 : capacity * 2(0 → 8, then doubles). - Rule of five: destructor, copy ctor, copy assignment, move ctor, move assignment - a class that owns a raw buffer needs all five; a class whose members already manage themselves needs none (rule of zero).
- Exceptions:
at()throwsstd::out_of_range;reserve/resizethrowstd::length_error;operator[]does not check. const int*(cannot write through) vsint* const(cannot repoint).enum classis scoped and does not convert toint; a plainenumdoes.
3. Coverage map - where every topic lives
The HW#1 and HW#2 material (and the lectures that feed them) carries the most weight, so study those hardest. The table routes each area to its detailed section in Guide 1 or Guide 2. This is a possible breakdown; the numbers are estimates and may change.
| Area | Weight (est.) | Lectures | Read in detail |
|---|---|---|---|
| HW#1 area foundations, classes, ownership | ~35% | L1, L2, L3, L5, L6 | Guide 1 §1-§6 + Pointers Guide |
| HW#2 area free store, the Vector, templates | ~35% | L7, L8, L9, L10 | Guide 2 §1-§5 |
| Broader foundations streams, functions, std library | ~20% | L1-L6 | Guide 1 §1-§5 |
| Transfer / integrative cross-course reasoning | ~10% | whole course | Section 5 below |
4. How the course fits together
The two homeworks draw on most of the course. How the parts relate:
- Types and values (L1) and functions, pointers, references (L2) are the vocabulary.
auto, initialization and narrowing,const, references vs pointers. - User-defined types (L3) and classes (L5, L6) let you build your own abstractions: interface vs implementation,
constmembers, operator overloading, inheritance and virtual functions. - HW#1 puts that together: an
Inventoryof polymorphicItems, moved between states, owned safely withunique_ptr(the rule of zero). Ownership without writing any destructor. - The free store (L7) and copy/move (L9) work at a lower level: raw
new/delete, allocation separated from construction, deep vs shallow copy, and moving instead of copying. - HW#2: you build
ct::Vectorby hand - a growable container that owns a raw buffer and therefore must obey the rule of five. Growth, deep copy, move, iterators, exceptions, and templates in one class.
There are two ways to own a resource: let the library do it (HW#1, unique_ptr, rule of zero) or do it by hand (HW#2, raw buffer, rule of five). Most of the other material supports one of these two.
5. Transfer topics (the cross-course questions)
A few questions tie two parts of the course together. These are the connections to have straight; they are not in Guide 1 or Guide 2 by themselves.
Rule of Zero vs Rule of Five - which applies?
- Rule of Zero: if every member already manages itself (a
std::string, astd::vector, aunique_ptr), write none of the special members - the compiler's are correct. HW#1Inventoryis the example: itsvector<unique_ptr<Item>>members make it move-only for free. - Rule of Five: if the class owns a raw resource (a
new[]buffer), you must write all five, or a shallow copy will leave two objects trying to free the same buffer. HW#2ct::Vectoris the example. - Question shape: given three classes (an
Inventory-like one, a raw-buffer one, and a plain-data one), say which must write the special members and which must write none.
Two ways to own memory - unique_ptr vs a raw buffer
unique_ptrfrees automatically at end of scope (RAII), is move-only, and nulls its source on a move. This is HW#1's model.- A raw owning buffer must be freed by a hand-written destructor, or it leaks. This is HW#2's model.
- Both are RAII: the object's lifetime controls the resource. The difference is who writes the cleanup - the library, or you.
The Vector idea generalizes
- A hand-built growable container - allocate raw storage, construct in place, grow by doubling, deep-copy, move, free in the destructor - is a pattern, not just
ct::Vector. The same reasoning applies to any owning container (for example aStack<T>built on the same idea). If it owns a raw buffer, it needs the rule of five and the same growth and copy behavior.
Memory safety across the course
- A container that owns a heap buffer frees it in its destructor - so a local
ct::Vectoror anInventoryneeds no manualdelete(RAII). A class thatnew[]s a buffer but writes no destructor leaks. - Know the difference between size and capacity, and that a reallocation invalidates iterators, pointers, and references into the old buffer.
6. The must-know from each homework (the 70%)
HW#1 (see Guide 1 §6)
- Abstract base
Itemwith pure virtual functions; derivedEquipment/Consumable/Borrowedoverride behavior (e.g. what may be loaned or sold). Polymorphic dispatch through a base pointer or reference, including virtual destructors and one non-memberoperator<<that calls a virtualprintTo. enum classstates; anInventorythat owns items invector<unique_ptr<Item>>and returns non-owningItem*views; the rule of zero; moving ownership between states.
HW#2 (see Guide 2 §5)
- Manual memory: allocation (
::operator new) separate from construction (placementnew); the destructor destroys elements then frees the buffer. - Growth 0 → 8 → double;
sizevscapacity;reservevsresize; reallocation invalidates handles. - Deep-copy copy constructor and buffer-stealing move constructor (the rule of five); iterators as raw pointers;
at()vsoperator[]and the exceptions; templates and CTAD.
7. How the exam is structured
- True/false, multiple choice, and select all that apply - the same formats you saw on Exam 1 and Exam 2.
- For a "select all that apply" question, read every option before you answer.
- Some questions show code and ask what happens; trace it. The answer is in the code, not in your memory.
- Cumulative: anything from the coverage map is fair game, including topics inside this scope that did not happen to appear on Exam 1 or Exam 2.
8. Practice, and the night before
Practice with these three
- Quiz 6 - tests cumulative knowledge across the whole course.
- Lab 6 - working through it will help you prepare for the exam.
- "Practice Questions for Exam" - a final practice set.
Do not memorize the questions; learn the concepts behind them. The exam's questions will likely be different and may test other aspects of the same idea. Do these practice items and Quiz 6 after you have finished the largest part of your studying, not before.
- Sleep. You will think more clearly than after one more hour of cramming.