Flashcard Deck · 20 cards · Public

Stanford CS106B - Programming Abstractions & Data Structures in C++

Master C++ programming abstractions, recursive problem-solving, pointer mechanics, and fundamental data structures with this high-yield Stanford CS106B flashcard deck.

Cards in this deck

(20 cards)

Preview terms and definitions before starting your study session.

#1
Term
Pass-by-Value vs. Pass-by-Reference in C++
Definition
Pass-by-Value (void fn(int x)) creates a full copy of the variable, leaving the original caller variable unchanged.
Pass-by-Reference (void fn(int& x)) passes an alias to the original memory location, allowing direct modification.
Const Reference (void fn(const Vector<int>& v)) avoids copying large data structures while preventing modifications.
#2
Term
Base Case vs. Recursive Step
Definition
Every valid recursive function requires:
1. Base Case: The simplest terminal condition that solves the problem directly without recursive calls.
2. Recursive Step: Breaks the problem into smaller self-similar subproblems and advances toward the base case.
#3
Term
Recursive Backtracking Core Template
Definition
The canonical pattern for exploring all choices (e.g., N-Queens, Sudoku, Subsets):
c++13 lines
void solve(State& state) {
    if (isSolution(state)) {
        process(state);
        return;
    }
    for (Choice choice : choices) {
        if (isValid(choice)) {
            makeChoice(state, choice);   // Choose
            solve(state);               // Explore
            undoChoice(state, choice);   // Unchoose
        }
    }
}
#4
Term
Raw Pointer vs. Reference Syntax & Behavior
Definition
  • Reference (int& ref = x;): Must be initialized upon declaration, cannot be reassigned to point elsewhere, and cannot be nullptr.
  • Pointer (int* ptr = &x;): Variables storing memory addresses. Can be reassigned, set to nullptr, and manipulated using pointer arithmetic.
#5
Term
Dynamic Memory Allocation: new and delete
Definition
Allocates and frees memory manually on the Heap (Free Store):
  • Single element: int* p = new int(10); -> freed via delete p;
  • Dynamically sized array: int* arr = new int[size]; -> freed via delete[] arr;
Rule: Every call to new/new[] must have a corresponding call to delete/delete[] to prevent memory leaks.
#6
Term
Dangling Pointer vs. Memory Leak
Definition
  • Memory Leak: Heap memory is allocated with new, but all pointers referencing it are lost before calling delete. The memory remains inaccessible until program exit.
  • Dangling Pointer: A pointer that points to a memory address that has already been deallocated using delete.
#7
Term
Big-O Formal Definition
Definition
A function is if there exist positive constants and such that:
It establishes an upper bound on time or space complexity in the worst-case scenario as input size grows toward infinity.
#8
Term
Amortized Time Complexity (Dynamic Array Expansion)
Definition
When a custom Vector fills its underlying array, it allocates a new array of double the size and copies elements ( cost).
Because doubling occurs infrequently (after insertions), the total cost of pushes is , making the amortized cost per push .
Showing 8 of 20 cards in this deck.
Study All Now

Related Flashcard Sets

Explore similar study materials created by the community

Browse community decks
Deck · 25 cards

STANFORD CS106B - Programming Abstractions & Recursive Problem Solving

Unlock the power of C++ programming with this comprehensive flashcard deck for Stanford CS106B. Master advanced data structures, recursive backtracking, memory management, and Big-O complexity for robust problem-solving.

Study flashcards Study set
Deck · 25 cards

TypeScript - Advanced Type Systems, Generics & Design Patterns

Master advanced TypeScript features like generics, conditional types, and mapped types to build robust, scalable applications. This deck covers essential utility types, type narrowing techniques, discriminated unions, and the nuances between interfaces and type aliases, empowering you to write highly maintainable and type-safe code.

Study flashcards Study set
Deck · 25 cards

Harvard ECON1011 - Intermediate Microeconomics: Game Theory & Market Structures

Master key concepts in intermediate microeconomics with this comprehensive flashcard deck. Dive deep into game theory, market structures, strategic pricing, and general equilibrium models, perfect for Harvard ECON1011 students and anyone aiming to ace microeconomics.

Study flashcards Study set
Deck · 21 cards

MIT 18.03 - Differential Equations: Ordinary Differential Equations, Laplace & Fourier

Master MIT 18.03 Differential Equations with high-yield flashcards covering first and second-order ODEs, Laplace transforms, Fourier series, and matrix exponential state-space systems.

Study flashcards Study set