Learning Tools / CMPS 2020

CMPS 2020 Learning

Interactive lessons that go with the course, in a suggested learning order. Start at the top, or jump to any topic below or in the sidebar.

C++

1 Functions

Step through calls and returns and watch the call stack grow and shrink: frames, parameters, return values, pass by value vs by reference, overloading and default arguments.

2 Function Calls

Under the hood of a function call: watch the program counter jump into a function and back, and each call’s stack frame (arguments, return address, saved frame pointer, locals) get pushed and popped in memory, including what is left behind when it returns.

3 Arrays

See an array as a row of memory cells with real addresses: loop over it step by step, watch a[i] become *(a + i), break the bounds on purpose, and see how a 2D array is really stored.

4 Pointers

Watch memory as your code runs: every pointer is drawn as an arrow to what it points at. Step through &, *, pointer arithmetic, nullptr, new/delete, leaks and dangling pointers, then run your own statements in a sandbox.

5 Templates

Write code once for any type: step through the compiler instantiating maxOf<T> once per type, try calls that fail to deduce, see why Stack<int> and Stack<std::string> are different classes, and write specializations: a maxOf for C strings, and full vs partial specializations of a class template.

6 Exception Handling

Follow a throw as it unwinds the call stack to the nearest matching catch, then build your own exception hierarchy and handle every type with one polymorphic handler.

OOP

7 Access Levels

public, private and protected, visualized: see which code can reach which members, from inside the class, from a friend, from a derived class, and from outside.

8 Setters & Getters

Encapsulation in practice: keep data private and control every change through member functions that validate it, side by side with a class whose public data ends up in an impossible state.

9 Constructors

Watch objects come to life: default, parameterized and delegating constructors, member initializer lists, the order members are built in, and explicit.

10 Destructors

See when objects die: scope exit, delete, and reverse order of destruction, and how destructors free resources (RAII).

11 Copy Constructors

Copy an object that owns memory and watch a shallow copy share (and double-free) the same buffer, then fix it with a deep copy and the rule of three.

12 Friend Functions

Grant one outside function access to a class’s private members: toggle the friend declaration on and off, step through a member call (with its hidden this) next to a friend call, and see why operator<< and 5 + m need friends.

13 Friend Classes

Give a whole class access with friend class: switch the friend line in Node on and off and see LinkedList’s code break, then use the rules explorer to find out why friendship is one-way, not transitive and not inherited, and when to trust just one member function.

14 Operator Overloading

Give a Fraction class +, ==, ++, = and <<: see the function call the compiler turns each expression into, member vs non-member side by side, then step through a chained cout << a << b as the same stream is passed from call to call, and break operator<< on purpose to see why its signature looks the way it does.

15 Inheritance

Build class hierarchies and see how derived objects contain their base part, which members they can reach, and watch constructors run through three levels of inheritance: calls go down to the base, bodies run back up.

16 Polymorphism

Call the same function on different objects through a base pointer, and see virtual functions and the vtable pick the right version at run time.

17 Multiple Inheritance

A class with two bases: step through how a TA object is built from a Student part and an Employee part, untangle an ambiguous getId(), then watch the diamond problem’s two Person parts merge into one with virtual inheritance.

Data Structures

18 Stacks

Push, pop and peek on an animated stack, with array and linked-list versions running side by side, then use a stack to check whether brackets are balanced.

19 Queues

Enqueue and dequeue on an animated queue, see the circular array wrap around, find out why a full queue and an empty one look the same, and compare it with a linked-list queue.

20 Linked Lists

Insert, delete, search and reverse while the pointers rewire before your eyes, in singly and doubly linked lists, and see the two classic bugs that lose nodes and leak memory.

21 Linked List – Stacks

A stack built from a linked list that pushes and pops at the head: every pointer (head, newNode, temp) is its own colored box holding a made-up address, so you can watch each new node get created, linked in and later deleted line by line, then break the code on purpose to see leaks, dangling pointers and crashes.

22 RPN Calculator

Watch a stack evaluate a Reverse Polish Notation expression token by token, and convert ordinary infix expressions to RPN with the Shunting-yard algorithm.

Algorithms

23 Recursion

See recursive calls pile up on the call stack and unwind again: factorial, Fibonacci (plain vs memoized), power, Towers of Hanoi and a missing base case, each drawn as a live call tree.

24 Hash Tables

Insert, search and delete keys and watch collisions happen, then resolve them with chaining, linear probing, quadratic probing or double hashing: probe paths, clusters, tombstones, load factor and rehashing.

25 Binary Search

Halve the search range each step: low, mid and high pointers on a sorted array, raced against a linear search, in iterative, recursive and lower_bound versions, plus what goes wrong on an unsorted array.

26 Quick Sort

Pick a pivot, partition, recurse: watch quick sort split the array step by step, see the recursion as a partition tree, and trigger its O(n²) worst case.

27 Shell Sort

Insertion sort with shrinking gaps: see elements jump long distances early so the final pass has almost nothing left to do.

28 Heap Sort

Build a max-heap and watch the array and the tree move together as values swap, then repeatedly move the largest value to the end and sift down.

29 Binary Search Trees

Insert, search and delete in a binary search tree, and walk it in pre-order, in-order, post-order and level order.

30 AVL Trees

Keep a search tree balanced: watch balance factors change and single or double rotations fix the tree after each insert or delete.

31 Red-Black Trees

Insert keys and watch recoloring and rotations restore the red-black rules, with every rule checked live after each step.