Quiz 2
quiz2-week-content.json
json Container
READ_ONLY_ACCESS
{ "courses": [ { "courseId": "maths1", "folder": "Maths 1", "label": "Mathematics I", "prepGuideId": "may-2026-maths-quiz-2-weeks-1-8-prep", "weeks": [ { "week": 1, "title": "Sets, number systems & functions", "focus": "sets, logic, relations, function test", "noteId": "may-2026-maths-week-1-sets-and-logic", "skipIfExists": true, "content": { "map": "Objects → membership rules → relations → function test (vertical line)", "concepts": "- **Set vs element:** distinguish $x \\in A$ from $\\{x\\} \\subseteq A$; state the universal set before complements.\n- **Operations:** union, intersection, difference, complement, and Cartesian product as membership filters.\n- **Relations:** domain, codomain, range; reflexive/symmetric/transitive checks on small finite sets.\n- **Functions:** every input in the domain maps to exactly one output; use the vertical-line test on graphs.", "notation": "| Symbol | Meaning |\n| --- | --- |\n| $A \\cup B$ | elements in A or B |\n| $A \\cap B$ | elements in both |\n| $A \\setminus B$ | in A but not B |\n| $A^c$ | in U but not A |\n| $f: D \\to C$ | function from domain D to codomain C |", "patterns": [ { "level": "Easy", "name": "Membership checklist", "body": "List elements of a small universal set and two subsets. For each element, decide membership in union, intersection, or difference by asking one yes/no question per operation. Write the resulting set without treating order as significant." }, { "level": "Medium", "name": "Relation or function?", "body": "Given a table or arrow diagram between two finite sets, identify domain, codomain, and range. Check whether any domain element has two images or a missing image. If every domain element has exactly one arrow, classify as a function and name the range as the set of actual outputs." }, { "level": "Hard", "name": "Counterexample vs proof", "body": "For a quantified claim about sets or functions, state the universe first. To refute \"for all,\" find one witness outside the claimed property; to support \"there exists,\" give one explicit example. Do not confuse converse and contrapositive when the claim uses implication." } ], "traps": [ "Treating $2 \\in \\{1,2,3\\}$ and $\\{2\\} \\subseteq \\{1,2,3\\}$ as the same type of statement.", "Computing $A^c$ without fixing the universal set.", "Calling a relation a function when one input has two outputs.", "Using range when the question asks for codomain." ], "retrieval": [ "What membership question defines $A \\cap B$ in one sentence?", "How do you test a graph for being a function?", "What is the difference between codomain and range?" ], "compressed": "ℕ⊆ℤ⊆ℚ⊆ℝ → sets → relations → function test (one output per input).", "chain": [ { "label": "Membership", "expression": "x ∈ A", "when": "x is an element of set A" }, { "label": "Subset", "expression": "B ⊆ A", "when": "every element of B is in A" }, { "label": "Union / intersection", "expression": "A∪B, A∩B", "when": "OR vs AND on membership" }, { "label": "Power set size", "expression": "|𝒫(A)| = 2^|A|", "when": "counting subsets" }, { "label": "Function rule", "expression": "f: D→C, each d∈D has exactly one f(d)", "when": "vertical line test on graphs" } ], "deepStudy": "# Mathematics I · Week 1 — Sets, relations, and functions\n\nDeep study for Quiz 2 weeks 1–4. Build vocabulary first, then pattern recognition, then mixed traps.\n\n## Week map\n\nSet language → roster and interval notation → subset and power set → relations as cross-products → function as special relation → domain, codomain, range → injective / surjective / bijective sketches.\n\n## Set notation (learn the symbols before the rules)\n\n- $A$ → “set $A$” → collection of distinct objects → $A = \\{2, 5, 7\\}$.\n- $\\{x : \\text{condition}\\}$ → “set builder” → all $x$ satisfying the condition → $\\{x : x \\in \\mathbb{Z}, -2 < x < 4\\} = \\{-1,0,1,2,3\\}$.\n- $x \\in A$ → “$x$ belongs to $A$” → membership test → $3 \\in \\{1,3,5\\}$ is true.\n- $A \\subseteq B$ → “$A$ is a subset of $B$” → every element of $A$ is in $B$ → $\\{2,4\\} \\subseteq \\{1,2,3,4\\}$.\n- $A \\cup B$ → “union” → elements in $A$ or $B$ (or both) → $\\{1,2\\} \\cup \\{2,3\\} = \\{1,2,3\\}$.\n- $A \\cap B$ → “intersection” → elements in both → $\\{1,2\\} \\cap \\{2,3\\} = \\{2\\}$.\n- $A^c$ or $A'$ → “complement” → elements in universal set $U$ not in $A$ → if $U=\\{1,2,3,4\\}$, then $\\{1,3\\}^c = \\{2,4\\}$.\n- $|A|$ → “cardinality” → number of elements → $|\\{a,b,c\\}| = 3$.\n\n### Roster vs interval on the line\n\nFinite sets use braces: $\\{-1, 0, 1\\}$. Intervals on $\\mathbb{R}$ use parentheses/brackets:\n\n- $(a,b)$ → open interval → $a < x < b$ → $(2,5)$ excludes endpoints.\n- $[a,b]$ → closed interval → $a \\le x \\le b$.\n- $(-\\infty, b]$ → unbounded left → all $x \\le b$.\n\n**Trap:** $\\{2\\}$ is a set containing one element; $2$ is not a set. $\\emptyset$ and $\\{\\emptyset\\}$ differ: the second has one element (the empty set).\n\n## Relations\n\nA **relation** $R$ from set $A$ to set $B$ is any subset of $A \\times B$ (ordered pairs).\n\nExample: $A = \\{1,2,3\\}$, $B = \\{0,1\\}$. Define $R = \\{(1,0), (2,0), (3,1)\\}$. Then $2\\,R\\,0$ is true (pair $(2,0)$ is in $R$).\n\n### Relation properties (when $R$ is on $A \\times A$)\n\n- **Reflexive:** every element pairs with itself → $(a,a) \\in R$ for all $a \\in A$.\n- **Symmetric:** swapping order keeps membership → if $(a,b) \\in R$ then $(b,a) \\in R$.\n- **Transitive:** chains close → if $(a,b) \\in R$ and $(b,c) \\in R$ then $(a,c) \\in R$.\n\nMini-example: On $\\{1,2,3\\}$, let $R = \\{(1,1),(2,2),(3,3),(1,2),(2,1)\\}$. Reflexive yes; symmetric yes; transitive yes (only chain $1 \\to 2 \\to 1$ closes).\n\n## Functions\n\nA **function** $f : A \\to B$ is a relation where each input in **domain** $A$ has exactly one output in **codomain** $B$.\n\n- **Range** → actual outputs hit → subset of codomain.\n- $f(x)$ → value at $x$ → unique output rule.\n\nNon-function example on $\\{1,2\\}$: pairs $\\{(1,0),(1,1),(2,0)\\}$ — input $1$ has two outputs.\n\n### Injective, surjective, bijective\n\n- **Injective (one-to-one):** different inputs → different outputs. Fail if two inputs share an output.\n- **Surjective (onto):** every codomain element is hit. Fail if some $b \\in B$ never appears.\n- **Bijective:** both injective and surjective — inputs and outputs pair perfectly.\n\nMini-example: $f : \\{1,2,3\\} \\to \\{10,20,30\\}$ with $f(1)=10, f(2)=20, f(3)=30$ is bijective (finite sets, equal size, all distinct).\n\n## Pattern families\n\n### Easy — Membership and operations\n\n- List elements after union/intersection/complement with universal set stated.\n- Convert roster to set-builder when pattern is clear (even integers between 0 and 10).\n- Count $|A|$ after combining sets; use inclusion when asked “how many in $A$ or $B$ but not both”: $|A \\cup B| - |A \\cap B|$ for symmetric difference size.\n\n### Medium — Subset and power set\n\n- List all subsets of a small set; confirm $2^n$ count for $n$ elements.\n- Decide whether $X \\subseteq Y$ from explicit rosters or interval containment.\n- Given $U$ and $A$, describe $A^c$ in roster form.\n\n### Hard — Relation vs function and mapping type\n\n- From a table of pairs, mark function or not; identify domain and range.\n- Decide injective/surjective from arrow diagram or table without computing formula.\n- Combine set ops with function definition: e.g. domain restricted to $A \\cap B$.\n\n## Worked mini-examples\n\n**Example 1 — Union and complement.** $U = \\{1,2,3,4,5\\}$, $A = \\{1,3,5\\}$, $B = \\{2,3,4\\}$.\n\n$A \\cup B = \\{1,2,3,4,5\\}$, $A \\cap B = \\{3\\}$, $(A \\cup B)^c = \\emptyset$, $A \\setminus B = \\{1,5\\}$.\n\n**Example 2 — Power set size.** $S = \\{a,b,c\\}$. $|S| = 3$, so $|\\mathcal{P}(S)| = 2^3 = 8$ subsets (including $\\emptyset$ and $S$).\n\n**Example 3 — Function check.** Rule $g(x) = \\sqrt{x}$ with domain $\\{0,1,4,9\\}$ and codomain $\\{0,1,2,3\\}$: $g(0)=0, g(1)=1, g(4)=2, g(9)=3$ — function, bijective on these finite sets.\n\n**Example 4 — Not injective.** $h : \\{1,2,3\\} \\to \\{5,6\\}$ with $h(1)=5, h(2)=5, h(3)=6$. Function yes; not injective ($1$ and $2$ collide).\n\n## Traps\n\n- Confusing $\\in$ (element) with $\\subseteq$ (subset). $\\{1\\} \\subseteq \\{1,2\\}$ but $\\{1\\} \\notin \\{1,2\\}$ as an element (unless nested).\n- Forgetting $\\emptyset$ is subset of every set.\n- Calling a relation a function when one input has two outputs in the table.\n- Range vs codomain: codomain is declared; range is what actually occurs.\n- Power set of $\\{a\\}$ is $\\{\\emptyset, \\{a\\}\\}$ — two elements, not one.\n\n## Diagnostic (try yourself)\n\n1. Let $U = \\{1,2,3,4,5,6\\}$, $P = \\{2,4,6\\}$, $Q = \\{1,2,3\\}$. List all elements of $(P \\cup Q)^c$.\n\n2. How many subsets does $\\{w,x,y,z\\}$ have? How many of those subsets contain $w$?\n\n3. A relation on $\\{0,1,2\\}$ is given by pairs $\\{(0,0),(1,0),(1,1),(2,2)\\}$. Is it a function from $\\{0,1,2\\}$ to $\\{0,1,2\\}$? If not, which input fails?\n\n4. Define $f : \\{1,2,3,4\\} \\to \\{5,6,7\\}$ by $f(1)=5, f(2)=6, f(3)=7, f(4)=5$. Is $f$ injective? Surjective? Bijective?\n\n5. Express in roster form: $\\{x \\in \\mathbb{Z} : x^2 < 10\\}$.", "chattyReferenceId": "maths1-week1-reference", "chattyDeepDiveId": "maths1-week1-deep-dive", "procedure": "Identify number-system membership.", "variations": "Combine set reasoning + relation reasoning.", "recognition": "Ask: What membership question defines $A \\cap B$ in one sentence?" } }, { "week": 2, "title": "Coordinate system & straight lines", "focus": "slope, line equations, parallel & perpendicular", "noteId": "may-2026-maths-week-2-lines-and-slope", "skipIfExists": false, "content": { "map": "Points → slope → line forms → parallel/perpendicular → applications", "concepts": "- **Slope** as rise over run; undefined slope for vertical lines; zero slope for horizontal.\n- **Forms:** point-slope $y - y_1 = m(x - x_1)$, slope-intercept $y = mx + c$, general $ax + by + c = 0$.\n- **Parallel lines** share slope; **perpendicular** slopes multiply to $-1$ (when neither is vertical).\n- **Intercepts:** $x$-intercept where $y=0$; $y$-intercept where $x=0$.", "notation": "| Item | Formula |\n| --- | --- |\n| Slope | $m = \\frac{y_2 - y_1}{x_2 - x_1}$ |\n| Distance | $d = \\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$ |\n| Parallel | $m_1 = m_2$ |\n| Perpendicular | $m_1 m_2 = -1$ |", "patterns": [ { "level": "Easy", "name": "Slope from two points", "body": "Subtract coordinates in the same order for both numerator and denominator. Simplify the fraction and state whether the line rises, falls, or is constant. If $x_1 = x_2$, report undefined slope and write $x = k$." }, { "level": "Medium", "name": "Line through point with condition", "body": "Start from point-slope form when a point and slope are known. For parallel to a given line, copy its slope; for perpendicular, use the negative reciprocal. Convert to the form requested (slope-intercept or general)." }, { "level": "Hard", "name": "Geometry with lines", "body": "Combine distance formula with line equations to find intersection or verify perpendicularity via slopes. Sketch roughly to catch sign errors. Check feasibility: perpendicular slope to a horizontal line is undefined (vertical)." } ], "traps": [ "Mixing up $(y_2-y_1)/(x_2-x_1)$ with reversed differences inconsistently.", "Using $m_1 m_2 = -1$ when one line is horizontal and the other should be vertical.", "Forgetting that parallel vertical lines both have undefined slope.", "Confusing intercept $c$ in $y=mx+c$ with constant term in $ax+by+c=0$." ], "retrieval": [ "What slope characterizes a line perpendicular to $y = 3x - 2$?", "How do you write the equation of a vertical line through $(4,-1)$?", "When are two lines parallel in slope-intercept form?" ], "compressed": "Δx, Δy → slope m → line forms → parallel (same m) vs perpendicular (m₁m₂=−1).", "chain": [ { "label": "Change", "expression": "Δx = x₂−x₁, Δy = y₂−y₁", "when": "before plugging into formulas" }, { "label": "Slope", "expression": "m = Δy/Δx", "when": "two distinct points" }, { "label": "Point-slope", "expression": "y−y₁ = m(x−x₁)", "when": "point + slope known" }, { "label": "Slope-intercept", "expression": "y = mx + c", "when": "c is y-intercept at x=0" }, { "label": "Perpendicular", "expression": "m₂ = −1/m₁", "when": "non-vertical lines" } ], "deepStudy": "# Mathematics I · Week 2 — Lines and slope\n\nCoordinate plane tools for reading graphs, writing equations, and checking parallelism.\n\n## Week map\n\nPoints and distance → slope as rate of change → point-slope and slope-intercept → general form → parallel and perpendicular → intercepts and applications.\n\n## Coordinate notation\n\n- $(x,y)$ → ordered pair → horizontal then vertical → $(3,-2)$ is 3 right, 2 down.\n- $m$ → slope → rise over run → $m = \\frac{y_2 - y_1}{x_2 - x_1}$.\n- $\\Delta y$ → change in $y$ → vertical difference → if $y$ goes from 4 to 7, $\\Delta y = 3$.\n- $\\Delta x$ → change in $x$ → horizontal difference → keep subtraction order consistent with $y$.\n\n### Reading slope\n\n- $m > 0$ → line rises left to right.\n- $m < 0$ → line falls.\n- $m = 0$ → horizontal; equation $y = k$.\n- Undefined slope → vertical; equation $x = k$ (not $y = mx + b$ form).\n\nMini-example: Through $(1,4)$ and $(5,10)$: $m = \\frac{10-4}{5-1} = \\frac{6}{4} = \\frac{3}{2}$. Rise 3 per run 2.\n\n## Line equations\n\n### Point-slope form\n\n$y - y_1 = m(x - x_1)$ — use when point and slope known.\n\nThrough $(2,-1)$ with $m = -3$: $y + 1 = -3(x - 2)$ → $y = -3x + 5$.\n\n### Slope-intercept form\n\n$y = mx + c$ — $c$ is **$y$-intercept** (value when $x=0$).\n\n### General form\n\n$ax + by + c = 0$ — useful for parallel/perpendicular via coefficients; slope $m = -\\frac{a}{b}$ when $b \\neq 0$.\n\n**Trap:** In $3x + 2y - 8 = 0$, the $y$-intercept is not $-8$; solve: $2y = -3x + 8$, $y = -\\frac{3}{2}x + 4$, intercept $4$.\n\n## Parallel and perpendicular\n\n- **Parallel:** same slope $m_1 = m_2$ (including both vertical).\n- **Perpendicular (neither vertical):** $m_1 m_2 = -1$ → $m_2 = -\\frac{1}{m_1}$.\n\nMini-example: Line with $m = \\frac{2}{5}$. Perpendicular slope is $-\\frac{5}{2}$. Parallel slope stays $\\frac{2}{5}$.\n\nVertical ⊥ horizontal always. Two vertical lines are parallel; vertical ⊥ horizontal with undefined vs 0 slope — do not apply $m_1 m_2 = -1$ blindly.\n\n## Intercepts and distance\n\n- **$x$-intercept:** set $y=0$, solve for $x$.\n- **$y$-intercept:** set $x=0$, solve for $y$.\n- **Distance** between $(x_1,y_1)$ and $(x_2,y_2)$: $d = \\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$.\n\nMini-example: Line $y = 2x - 6$. $x$-intercept: $0 = 2x - 6$, $x = 3$. Point $(3,0)$. $y$-intercept: $(0,-6)$.\n\n## Pattern families\n\n### Easy — Slope from two points\n\n- Compute $m$ with consistent $\\Delta y / \\Delta x$.\n- State rise/run interpretation in words.\n- Identify horizontal/vertical from equal $x$ or equal $y$ coordinates.\n\n### Medium — Equation from conditions\n\n- Line through one point with given slope → point-slope, simplify.\n- Line parallel/perpendicular to known line through a point → copy or negate-reciprocal slope first.\n- Convert between forms as requested.\n\n### Hard — Geometry with lines\n\n- Find intersection by solving linear system (substitution).\n- Verify perpendicularity via slopes after finding both lines.\n- Distance from point to point combined with intercept puzzles.\n\n## Worked mini-examples\n\n**Example 1 — Slope and intercept.** Points $(-2,5)$ and $(4,1)$: $m = \\frac{1-5}{4-(-2)} = \\frac{-4}{6} = -\\frac{2}{3}$. Using point $(4,1)$: $y - 1 = -\\frac{2}{3}(x - 4)$.\n\n**Example 2 — Parallel line.** Given $2x - 5y + 10 = 0$, slope $m = \\frac{2}{5}$. Line through $(0,3)$ parallel: $y - 3 = \\frac{2}{5}x$ → $y = \\frac{2}{5}x + 3$.\n\n**Example 3 — Perpendicular.** Slope of $y = 4x + 1$ is $4$. Perpendicular slope $-\\frac{1}{4}$. Through $(8,2)$: $y - 2 = -\\frac{1}{4}(x - 8)$.\n\n**Example 4 — Distance.** $(1,2)$ to $(4,6)$: $d = \\sqrt{(4-1)^2 + (6-2)^2} = \\sqrt{9+16} = 5$.\n\n## Traps\n\n- Inconsistent difference order: $\\frac{y_2-y_1}{x_2-x_1}$ not mixed with $\\frac{y_1-y_2}{x_2-x_1}$ wrongly.\n- Using $m_1 m_2 = -1$ when one line is horizontal.\n- Confusing general-form constant with intercept.\n- Assuming lines with different slopes must intersect off-screen — they intersect somewhere unless parallel.\n\n## Diagnostic (try yourself)\n\n1. Find the slope of the line through $(5,-1)$ and $(-3,7)$.\n\n2. Write the equation of the line with slope $-\\frac{3}{4}$ passing through $(12,5)$ in slope-intercept form.\n\n3. Line $L$ has equation $3x + y = 9$. Write an equation for the line through $(2,1)$ perpendicular to $L$.\n\n4. Where does the line $4x - 2y = 12$ cross the $x$-axis and the $y$-axis?\n\n5. Are the lines $y = 5x - 2$ and $5x - y = 7$ parallel, perpendicular, or neither?", "chattyReferenceId": "maths1-week2-reference", "recognition": "- Two points → find line.", "procedure": "Subtract coordinates in the same order for both numerator and denominator. Simplify the fraction and state whether the line rises, falls, or is constant. If $x_1 = x_2$, report undefined slope and write $x = k$.", "variations": "Watch for: Mixing up $(y_2-y_1)/(x_2-x_1)$ with reversed differences inconsistently." } }, { "week": 3, "title": "Quadratic functions", "focus": "roots, vertex, discriminant, graph ↔ algebra", "noteId": "may-2026-maths-week-3-quadratics", "skipIfExists": false, "content": { "map": "Standard form → factoring/roots → vertex → discriminant → graph features", "concepts": "- **Standard form** $f(x) = ax^2 + bx + c$; parabola opens up if $a>0$, down if $a<0$.\n- **Roots** from factoring, completing the square, or quadratic formula $x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$.\n- **Vertex** $(h,k)$ from $h = -b/(2a)$, $k = f(h)$; vertex form $a(x-h)^2 + k$.\n- **Discriminant** $D = b^2 - 4ac$: positive two real roots, zero one repeated, negative no real roots.", "notation": "| Form | Use |\n| --- | --- |\n| $ax^2+bx+c$ | coefficients, discriminant |\n| $a(x-h)^2+k$ | vertex, transformations |\n| $D=b^2-4ac$ | root count (real) |", "patterns": [ { "level": "Easy", "name": "Factor simple quadratics", "body": "Look for two numbers that multiply to $ac$ and add to $b$ when $a=1$. Set each factor to zero. Verify by substitution. If monic and prime over integers, state that and switch to formula." }, { "level": "Medium", "name": "Vertex and axis", "body": "Compute $h = -b/(2a)$ and evaluate $f(h)$ for vertex. Axis of symmetry is vertical line $x=h$. Compare vertex $y$-value with roots to sketch direction and width from $a$." }, { "level": "Hard", "name": "Parameter in discriminant", "body": "Set discriminant condition for desired root type: $D>0$, $D=0$, or $D<0$. Solve inequality for parameter $k$. Boundary cases $D=0$ often mark transition points—test them separately." } ], "traps": [ "Sign error in $h = -b/(2a)$ when $b$ is negative.", "Confusing vertex $(h,k)$ with roots.", "Using quadratic formula without checking for factorization first on easy integers.", "Assuming two roots always means positive discriminant without checking reality." ], "retrieval": [ "What does $D=0$ imply about the graph?", "How do you convert $f(x)=x^2-6x+5$ to vertex form?", "Which direction opens for $f(x)=-2x^2+3x$?" ], "compressed": "f(x)=ax²+bx+c → roots via factor/formula → Δ=b²−4ac → vertex xᵥ=−b/(2a).", "chain": [ { "label": "Standard form", "expression": "f(x) = ax² + bx + c, a≠0", "when": "identify quadratic" }, { "label": "Discriminant", "expression": "Δ = b² − 4ac", "when": "count real roots" }, { "label": "Quadratic formula", "expression": "x = (−b ± √Δ)/(2a)", "when": "factoring hard" }, { "label": "Vertex x", "expression": "xᵥ = −b/(2a)", "when": "turning point" }, { "label": "Opening", "expression": "a>0 cup (min), a<0 cap (max)", "when": "graph sketch" } ], "deepStudy": "# Mathematics I · Week 3 — Quadratic functions\n\nParabolas link algebra (polynomial degree 2), graphs (vertex and symmetry), and root-finding.\n\n## Week map\n\nStandard form $ax^2+bx+c$ → graph shape → factoring and roots → quadratic formula → vertex and axis → discriminant → parameter problems.\n\n## Quadratic notation\n\n- $f(x) = ax^2 + bx + c$ → standard quadratic → $a \\neq 0$ → $f(x) = 2x^2 - 4x + 1$.\n- $a$ → leading coefficient → sign sets cup up ($a>0$) or down ($a<0$).\n- **Root / zero** → input where $f(x)=0$ → solve $ax^2+bx+c=0$.\n- $h = -\\frac{b}{2a}$ → $x$-coordinate of vertex → axis of symmetry vertical line $x=h$.\n- $D = b^2 - 4ac$ → discriminant → classifies real roots.\n\n### Vertex form\n\n$f(x) = a(x-h)^2 + k$ → vertex $(h,k)$ → graph shifts $h$ horizontal, $k$ vertical.\n\nMini-example: $f(x) = 3(x-2)^2 - 5$ has vertex $(2,-5)$, opens upward ($a=3>0$).\n\n## Roots and the discriminant\n\n| $D$ | Real roots |\n| --- | --- |\n| $D > 0$ | two distinct |\n| $D = 0$ | one repeated (touch axis) |\n| $D < 0$ | none (no horizontal crossing) |\n\n**Quadratic formula:** $x = \\frac{-b \\pm \\sqrt{D}}{2a}$ when solving $ax^2+bx+c=0$.\n\nMini-example: $x^2 - 5x + 6 = 0$. Factor $(x-2)(x-3)=0$ → roots $2,3$. Check $D = 25-24 = 1 > 0$.\n\n## Factoring strategy (monic $a=1$)\n\nFind integers $p,q$ with $pq = c$ and $p+q = b$ for $x^2+bx+c$.\n\n$x^2 + x - 12$: need product $-12$, sum $1$ → $4$ and $-3$ → $(x+4)(x-3)$.\n\nIf no integer pair works, use formula or completing the square.\n\n### Completing the square sketch\n\n$x^2 + 6x + 1 = (x^2+6x+9) - 9 + 1 = (x+3)^2 - 8$. Vertex $(-3,-8)$.\n\n## Graph features\n\n- **Axis of symmetry:** $x = h$.\n- **$y$-intercept:** $f(0) = c$.\n- **Direction:** min value at vertex if $a>0$; max if $a<0$.\n- **Width:** larger $|a|$ → narrower parabola.\n\n## Pattern families\n\n### Easy — Factor and solve\n\n- Monic quadratics with integer roots.\n- Read vertex from $(x-h)^2+k$ when given.\n- State $y$-intercept from $c$.\n\n### Medium — Vertex and transformation\n\n- Convert standard to vertex form by completing square or formula for $h,k$.\n- Given roots, write quadratic in factored form $a(x-r_1)(x-r_2)$.\n- Use symmetry: roots equidistant from axis at $h$.\n\n### Hard — Discriminant parameters\n\n- Find values of $k$ so $x^2 + kx + 9 = 0$ has exactly one real root → $D=0$.\n- Inequalities on $D$ for “no real roots” or “two real roots”.\n- Word constraints linking vertex height to domain (e.g. minimum cost).\n\n## Worked mini-examples\n\n**Example 1 — Factoring.** $2x^2 - 8x + 6 = 0$. Divide 2: $x^2 - 4x + 3 = 0$ → $(x-1)(x-3)=0$ → $x=1,3$.\n\n**Example 2 — Vertex.** $f(x) = -x^2 + 4x + 1$. $h = -4/(2\\cdot -1) = 2$. $f(2) = -4+8+1 = 5$. Vertex $(2,5)$, max (since $a=-1$).\n\n**Example 3 — Discriminant.** $3x^2 - 2x + k = 0$ has no real roots when $D = 4 - 12k < 0$ → $k > \\frac{1}{3}$.\n\n**Example 4 — From roots.** Roots $-2$ and $5$: $f(x) = a(x+2)(x-5)$. If $a=1$, $f(x) = x^2 - 3x - 10$. $c = -10$ is $y$-intercept.\n\n## Traps\n\n- Sign error in $h = -b/(2a)$ when $b$ negative.\n- Vertex $(h,k)$ confused with roots (zeros on $x$-axis).\n- Forgetting $a$ when using formula: divide by $2a$, not 2.\n- $D=0$ means one repeated root, not “no roots”.\n- Opening direction from sign of $a$, not $c$.\n\n## Diagnostic (try yourself)\n\n1. Solve $x^2 + 7x + 10 = 0$ by factoring.\n\n2. Find the vertex and axis of symmetry of $f(x) = 2x^2 - 12x + 5$.\n\n3. For what values of $m$ does $x^2 + mx + 16 = 0$ have exactly one real solution?\n\n4. A parabola has roots at $x = 1$ and $x = 9$ and passes through $(0, 18)$. Write $f(x)$ in standard form.\n\n5. Without fully solving, how many real roots does $2x^2 + 3x - 7 = 0$ have? Use the discriminant.", "chattyReferenceId": "maths1-week3-reference", "recognition": "Ask: What does $D=0$ imply about the graph?", "procedure": "Look for two numbers that multiply to $ac$ and add to $b$ when $a=1$. Set each factor to zero. Verify by substitution. If monic and prime over integers, state that and switch to formula.", "variations": "Watch for: Sign error in $h = -b/(2a)$ when $b$ is negative." } }, { "week": 4, "title": "Algebra of polynomials", "focus": "operations, factor theorem, multiplicity, end behaviour", "noteId": "may-2026-maths-week-4-polynomials", "skipIfExists": false, "content": { "map": "Term structure → operations → division → factor theorem → graph from factors", "concepts": "- **Polynomial:** sum of terms $a_n x^n$; degree is highest power with nonzero coefficient.\n- **Operations:** add/subtract like terms; multiply by distributing; long division for $p(x)/q(x)$.\n- **Factor theorem:** $(x-a)$ is a factor iff $p(a)=0$; multiplicity counts repeated roots.\n- **End behaviour:** dominated by leading term $a_n x^n$; sign of $a_n$ and parity of $n$ set both ends.", "notation": "| Idea | Rule |\n| --- | --- |\n| Degree | highest exponent with $a_n \\neq 0$ |\n| Remainder | degree of remainder $<$ degree of divisor |\n| Multiplicity $m$ | $(x-a)^m$ factor; graph touches/bounces at $a$ |", "patterns": [ { "level": "Easy", "name": "Evaluate and classify degree", "body": "Combine like terms to standard form. State degree and leading coefficient. Evaluate $p(a)$ by substitution—this is the hook for factor checks." }, { "level": "Medium", "name": "Factor using theorem", "body": "Test rational candidates $a$ where $p(a)=0$. Divide out $(x-a)$ to reduce degree. Repeat until linear or irreducible quadratic remains. State full factorization with multiplicities." }, { "level": "Hard", "name": "Sketch from factorization", "body": "Place zeros from factors; mark multiplicity for touch vs cross. End behaviour from leading term. Plot one or two interior points for scale. Do not assume symmetry unless degree and roots justify it." } ], "traps": [ "Dropping terms when adding polynomials.", "Confusing zero of function with $y$-intercept (evaluate $p(0)$).", "Single crossing at a double root—multiplicity 2 often touches axis.", "Wrong end behaviour when degree is even and leading coefficient negative." ], "retrieval": [ "What does factor theorem say in one line?", "How does multiplicity 3 affect graph at a zero?", "What determines end behaviour of a polynomial?" ], "compressed": "polynomial ops → f(a)=0 ⇔ (x−a) factor → multiplicity → end behaviour from degree.", "chain": [ { "label": "Factor theorem", "expression": "f(a)=0 ⇔ (x−a) | f(x)", "when": "root ↔ factor" }, { "label": "Remainder", "expression": "remainder ÷ (x−a) is f(a)", "when": "synthetic division check" }, { "label": "Degree", "expression": "highest power of x with nonzero coeff", "when": "classify polynomial" }, { "label": "Multiplicity", "expression": "(x−a)^k factor → k", "when": "touch vs cross at root" }, { "label": "End behaviour", "expression": "even degree: same ends; odd: opposite", "when": "leading coeff sign sets direction" } ], "deepStudy": "# Mathematics I · Week 4 — Polynomials\n\nBeyond quadratics: degree, operations, factor theorem, multiplicity, and end behaviour.\n\n## Week map\n\nPolynomial structure → degree and leading term → add/multiply/divide → remainder idea → factor theorem → zeros and multiplicity → sketch from factors.\n\n## Polynomial notation\n\n- $p(x) = a_n x^n + \\cdots + a_1 x + a_0$ → polynomial in $x$ → coefficients real → $p(x) = 3x^3 - 2x + 7$.\n- **Degree** $n$ → highest power with $a_n \\neq 0$ → $5x^2 - 9$ has degree 2.\n- **Leading term** $a_n x^n$ → dominates for large $|x|$ → end behaviour driver.\n- **Zero / root** $r$ → $p(r) = 0$ → $(x-r)$ is a factor (over reals, if fully factorable).\n\n### Multiplicity\n\nIf $(x-r)^m$ divides $p(x)$ with largest $m$, root $r$ has **multiplicity** $m$.\n\n- $m=1$ → graph crosses axis at $r$.\n- $m=2$ → often touches and turns (bounce).\n- $m=3$ → crosses but flattens (flattened S).\n\nMini-example: $p(x) = (x-1)^2(x+3)$. Zeros: $1$ (mult 2), $-3$ (mult 1). Degree 3.\n\n## Operations\n\n- **Add/subtract:** combine like terms only ($x^2$ with $x^2$, not with $x$).\n- **Multiply:** distribute each term; exponents add: $x^a \\cdot x^b = x^{a+b}$.\n- **Long division:** divide $p(x)$ by $(x-a)$; remainder degree less than divisor; if remainder 0, $(x-a)$ is factor.\n\nMini-example: $(2x^2 + 3x - 5) + (x^2 - 3x + 1) = 3x^2 - 4$.\n\nMultiply: $(x+2)(x^2 - x + 1) = x^3 + x^2 - x + 2$.\n\n## Factor theorem\n\n$(x - a)$ is a factor of $p(x)$ **iff** $p(a) = 0$.\n\nUseful workflow: test small integers for rational roots when leading coefficient is 1 or small.\n\nMini-example: $p(x) = x^3 - 4x^2 + x + 6$. Try $a=2$: $8-16+2+6=0$ → $(x-2)$ factor. Divide to get $x^2 - 2x - 3 = (x-3)(x+1)$. Full: $(x-2)(x-3)(x+1)$.\n\n## End behaviour\n\nFor large $|x|$, $p(x) \\approx a_n x^n$:\n\n| $n$ | $a_n > 0$ | $a_n < 0$ |\n| --- | --- | --- |\n| even | both ends up | both ends down |\n| odd | left down, right up | left up, right down |\n\nMini-example: $-2x^4 + \\cdots$ → even degree 4, negative leading → both ends down.\n\n## Pattern families\n\n### Easy — Degree and evaluation\n\n- Combine polynomials; state degree and leading coefficient.\n- Evaluate $p(2)$, $p(-1)$ by substitution.\n- Identify $y$-intercept as $p(0) = a_0$.\n\n### Medium — Factor using theorem\n\n- Test candidates; divide out linear factor; repeat.\n- Build polynomial from given zeros with multiplicity in factored form.\n- Expand factored form to standard when needed.\n\n### Hard — Graph reasoning\n\n- Sketch sign chart from factorization.\n- Relate multiplicity to touch/cross at each zero.\n- Parameter $k$ so $x-a$ divides $p(x)-k$ (horizontal shift of roots).\n\n## Worked mini-examples\n\n**Example 1 — Degree.** $p(x) = 7x^4 - x^7 + 2x$. Rewrite standard: $-x^7 + 7x^4 + 2x$. Degree 7, leading coeff $-1$.\n\n**Example 2 — Factor test.** $p(x) = x^3 - 6x^2 + 11x - 6$. $p(1)=0$, $p(2)=0$, $p(3)=0$ → $(x-1)(x-2)(x-3)$.\n\n**Example 3 — Multiplicity sketch.** $p(x) = x^2(x-4)^3$. Zeros: $0$ mult 2 (touch), $4$ mult 3 (cross flat). Degree 5. Ends: positive leading (implicit $x^5$) → left down, right up.\n\n**Example 4 — Remainder.** Divide $x^3 + 2x - 5$ by $(x-1)$: synthetic or long division gives remainder $-4$ (same as $p(1)$).\n\n## Traps\n\n- Degree of zero polynomial handled specially; constant nonzero has degree 0.\n- Dropping terms when adding — write all powers or use columns.\n- Confusing zero of function with $y$-intercept ($x=0$ input).\n- Assuming all even-multiplicity roots “bounce” without checking local shape — still need sign chart.\n- Wrong end behaviour when only middle terms given — identify leading term first.\n\n## Diagnostic (try yourself)\n\n1. What is the degree and leading coefficient of $p(x) = 4x - x^3 + 2x^5 - 7$?\n\n2. If $p(x) = (x+2)^2(x-5)$, list all real zeros and their multiplicities.\n\n3. Use the factor theorem to decide whether $(x+1)$ is a factor of $p(x) = x^3 + 3x^2 - x - 3$.\n\n4. Multiply and simplify: $(x^2 - 3)(2x^2 + x - 4)$.\n\n5. Describe end behaviour (left and right) of $f(x) = -3x^6 + 2x^2 - 1$ as $x \\to \\pm\\infty$.", "chattyReferenceId": "maths1-week4-reference", "recognition": "Ask: What does factor theorem say in one line?", "procedure": "Combine like terms to standard form. State degree and leading coefficient. Evaluate $p(a)$ by substitution—this is the hook for factor checks.", "variations": "Watch for: Dropping terms when adding polynomials." } }, { "week": 5, "title": "Functions & composition", "focus": "V/H line tests, composition, inverse, exponentials", "noteId": "may-2026-maths-week-5-composition-inverse", "skipIfExists": false, "content": { "map": "Function tests → composition order → inverse swap → exponential growth/decay", "concepts": "- **Vertical line test:** function iff no vertical line hits graph twice.\n- **Horizontal line test:** injective (one-to-one) iff no horizontal line hits twice—needed for invertible function.\n- **Composition** $(f \\circ g)(x) = f(g(x))$: inside function first.\n- **Inverse** $f^{-1}$ swaps domain/range; graph reflection over $y=x$. **Exponential** $a^x$, $a>0$, $a \\neq 1$.", "notation": "| Symbol | Meaning |\n| --- | --- |\n| $f \\circ g$ | apply $g$ then $f$ |\n| $f^{-1}(y)$ | input that $f$ sends to $y$ |\n| $y = a^x$ | exponential base $a$ |", "patterns": [ { "level": "Easy", "name": "Compose two formulas", "body": "Write $f(g(x))$ by substituting entire $g(x)$ into $f$. Simplify stepwise; watch parentheses when replacing $x$. Domain excludes values that break inside function." }, { "level": "Medium", "name": "Inverse of linear or simple rational", "body": "Swap $x$ and $y$, solve for $y$. State domain of inverse as range of original. Verify $f(f^{-1}(x))=x$ on valid domain." }, { "level": "Hard", "name": "One-to-one and invertible", "body": "Use horizontal line test or monotonicity argument. For restricted domains (e.g. $x \\geq 0$), justify injectivity before inverting. Composition with inverse can simplify to identity only on matched domains." } ], "traps": [ "Writing $f \\circ g$ as $f(x) \\cdot g(x)$.", "Inverse notation $f^{-1}$ as $1/f$.", "Domain of $f^{-1}$ taken as domain of $f$.", "Base of exponential confused with exponent in $x^a$." ], "retrieval": [ "Which test checks if a graph is a function?", "In $f(g(x))$, which function is applied first?", "What is the domain of $f^{-1}$ if $f$ maps $[1,5]$ to $[2,10]$?" ], "deepStudy": "# Mathematics I · Week 5 — Composition, inverse, and exponentials\n\nDeep study for Quiz 2 week 5. Master composition order first, then invertibility, then exponential growth rules.\n\n## Week map\n\nVertical/horizontal line tests → composition $(f \\circ g)$ → inverse $f^{-1}$ → exponential $a^x$ → domain discipline throughout.\n\n## Composition notation\n\n- $(f \\circ g)(x)$ → “$f$ composed with $g$ at $x$” → apply $g$ first, then $f$ → $(f \\circ g)(x) = f(g(x))$.\n- $f(g(x))$ → inner function output becomes outer input → parentheses matter when substituting.\n- **Domain of composition** → all $x$ where $g(x)$ is in domain of $f$.\n\nMini-example: $f(x) = 2x + 1$, $g(x) = x^2$. Then $(f \\circ g)(3) = f(g(3)) = f(9) = 19$. But $(g \\circ f)(3) = g(f(3)) = g(7) = 49$ — order changes the answer.\n\n### Vertical and horizontal line tests\n\n- **Vertical line test:** graph is a function iff no vertical line hits twice.\n- **Horizontal line test:** function is injective (one-to-one) iff no horizontal line hits twice — needed for invertible function on its domain.\n\n## Inverse notation\n\n- $f^{-1}(y)$ → input that $f$ sends to $y$ → not the same as $1/f(x)$.\n- **Inverse swaps roles:** if $f(a) = b$ then $f^{-1}(b) = a$.\n- **Domain of $f^{-1}$** = range of $f$; **range of $f^{-1}$** = domain of $f$.\n- Graph of $f^{-1}$ reflects graph of $f$ over line $y = x$.\n\nMini-example: $f(x) = 3x - 2$ on $\\mathbb{R}$. Swap: $x = 3y - 2$, solve $y = \\frac{x+2}{3}$. So $f^{-1}(x) = \\frac{x+2}{3}$. Check: $f^{-1}(5) = 7/3$ and $f(7/3) = 5$.\n\n## Exponential notation\n\n- $y = a^x$ → exponential with base $a$ → $a > 0$, $a \\neq 1$.\n- $a^0 = 1$ for any valid base; $a^{m+n} = a^m \\cdot a^n$; $(a^m)^n = a^{mn}$.\n- $a^x > 0$ always — range is $(0, \\infty)$.\n\nMini-example: $2^3 = 8$; $2^{-1} = 1/2$; $(1/2)^2 = 1/4$. Base between 0 and 1 gives decay; base $> 1$ gives growth.\n\n**Trap:** $x^a$ (power function) vs $a^x$ (exponential) — variable position differs.\n\n## Pattern families\n\n### Easy — Evaluate composition\n\nSubstitute entire inner expression into outer. Simplify stepwise. Watch signs when replacing $x$ inside $f$.\n\n### Medium — Find inverse of linear or simple rational\n\nSwap $x$ and $y$, solve for $y$. State domain of inverse explicitly. Verify $f(f^{-1}(x)) = x$ on valid domain.\n\n### Hard — Invertibility and restricted domains\n\nUse horizontal line test or monotonicity. Square root and squaring need domain restriction ($x \\geq 0$) for bijection. Composition with inverse simplifies to identity only on matched domains.\n\n## Worked mini-examples\n\n**Example 1 — Composition order.**\n\n$f(x) = x + 4$, $g(x) = 2x$. $(f \\circ g)(5) = f(10) = 14$. $(g \\circ f)(5) = g(9) = 18$.\n\n**Example 2 — Nested formula.**\n\n$f(x) = x^2 + 1$, $g(x) = x - 3$. $(f \\circ g)(x) = (x-3)^2 + 1 = x^2 - 6x + 10$.\n\n**Example 3 — Inverse of linear.**\n\n$f(x) = \\frac{x-1}{2}$. Swap: $x = \\frac{y-1}{2}$ → $2x = y - 1$ → $f^{-1}(x) = 2x + 1$.\n\n**Example 4 — Exponential evaluation.**\n\n$3^{2} = 9$; $3^{-2} = 1/9$; $3^{1/2} = \\sqrt{3}$.\n\n**Example 5 — Not invertible without restriction.**\n\n$f(x) = x^2$ on all $\\mathbb{R}$ fails horizontal line test ($f(2) = f(-2) = 4$). Restrict to $x \\geq 0$ to define inverse $f^{-1}(x) = \\sqrt{x}$.\n\n## Traps\n\n- Writing $(f \\circ g)(x)$ as $f(x) \\cdot g(x)$.\n- Treating $f^{-1}$ as $1/f(x)$.\n- Taking domain of $f^{-1}$ equal to domain of $f$.\n- Applying outer function before inner in composition.\n- Confusing exponential base with exponent: $2^x$ vs $x^2$.\n\n## Diagnostic (try yourself)\n\n1. If $f(x) = 3x - 1$ and $g(x) = x^2$, find $(g \\circ f)(2)$ and $(f \\circ g)(2)$.\n\n2. Find $f^{-1}(x)$ for $f(x) = 5x + 4$. What is the domain of $f^{-1}$ if domain of $f$ is $\\mathbb{R}$?\n\n3. Is $f(x) = |x|$ injective on $\\mathbb{R}$? What restriction makes it bijective from $\\mathbb{R}$ to $[0,\\infty)$?\n\n4. Simplify $(f \\circ g)(x)$ when $f(x) = \\sqrt{x}$ and $g(x) = x + 5$. State the domain of the composition.\n\n5. Evaluate $2^{3}$ and $3^{2}$. Which is larger? What is $2^{-3}$?", "compressed": "domain/range → (f∘g)(x)=f(g(x)) → inverse swaps x↔y → exp growth vs decay.", "chain": [ { "label": "Composition", "expression": "(f∘g)(x) = f(g(x))", "when": "inside-out evaluation order" }, { "label": "Inverse", "expression": "f⁻¹(f(x))=x on domain", "when": "one-to-one functions only" }, { "label": "Horizontal line test", "expression": "no horizontal hits twice", "when": "invertible on interval" }, { "label": "Exponential", "expression": "f(x)=a^x, a>0, a≠1", "when": "growth (a>1) vs decay (0<a<1)" }, { "label": "Domain of composite", "expression": "x ∈ dom(g) and g(x) ∈ dom(f)", "when": "before plugging in" } ], "chattyReferenceId": "maths1-week5-reference", "recognition": "Ask: Which test checks if a graph is a function?", "procedure": "Write $f(g(x))$ by substituting entire $g(x)$ into $f$. Simplify stepwise; watch parentheses when replacing $x$. Domain excludes values that break inside function.", "variations": "Watch for: Writing $f \\circ g$ as $f(x) \\cdot g(x)$." } }, { "week": 6, "title": "Logarithmic functions", "focus": "log laws, log ↔ exp, solving log equations", "noteId": "may-2026-maths-week-6-logarithms", "skipIfExists": false, "content": { "map": "Exp inverse → log definition → laws → solve → domain restrictions", "concepts": "- **Definition:** $y = \\log_a x$ means $a^y = x$, with $a>0$, $a\\neq 1$, $x>0$.\n- **Common laws:** $\\log_a(xy)=\\log_a x + \\log_a y$; $\\log_a(x^n)=n\\log_a x$; change of base.\n- **Graph:** reflection of exponential over $y=x$; vertical asymptote $x=0$.\n- **Solving:** isolate log or exponent; check solutions in original domain.", "notation": "| Law | Form |\n| --- | --- |\n| Product | $\\log(xy)=\\log x+\\log y$ |\n| Power | $\\log(x^n)=n\\log x$ |\n| Change of base | $\\log_a x = \\frac{\\log_b x}{\\log_b a}$ |", "patterns": [ { "level": "Easy", "name": "Evaluate simple logs", "body": "Rewrite as exponent question: \"what power of base gives this number?\" Use $\\log_a 1 = 0$, $\\log_a a = 1$. For base 10 or $e$, connect to familiar values." }, { "level": "Medium", "name": "Expand or condense", "body": "Apply product and power rules in the direction requested. Factor arguments before splitting sums. Condense only when arguments share the same base." }, { "level": "Hard", "name": "Log equation with domain", "body": "Combine logs to single logarithm or exponentiate both sides. Solve resulting equation. Discard extraneous values that make any original log argument nonpositive." } ], "traps": [ "Using $\\log(x+y) = \\log x + \\log y$ (false).", "Forgetting $x>0$ in $\\log x$.", "Exponentiating without applying to entire side.", "Change-of-base with inverted fraction." ], "retrieval": [ "What does $\\log_2 8$ ask in words?", "Why must log arguments be positive?", "How do you solve $2^x = 10$ using logs?" ], "deepStudy": "# Mathematics I · Week 6 — Logarithms\n\nDeep study for Quiz 2 week 6. Logarithm is the inverse operation of exponentiation — every log question hides an exponent question.\n\n## Week map\n\nLog as inverse of exp → definition and domain → log laws → change of base → solve log equations → check solutions.\n\n## Logarithm notation\n\n- $\\log_a x$ → “log base $a$ of $x$” → the exponent $y$ such that $a^y = x$ → requires $a > 0$, $a \\neq 1$, $x > 0$.\n- $\\ln x$ → natural log → base $e$ → $\\ln x = \\log_e x$.\n- $\\log_{10} x$ or $\\log x$ → common log (context-dependent).\n\nMini-example: $\\log_2 8 = 3$ because $2^3 = 8$. $\\log_5 1 = 0$ because $5^0 = 1$. $\\log_3 3 = 1$.\n\n### Key identities\n\n- $a^{\\log_a x} = x$ for $x > 0$.\n- $\\log_a(a^x) = x$ for all real $x$.\n- $\\log_a 1 = 0$; $\\log_a a = 1$.\n\n## Log laws\n\n- **Product:** $\\log_a(xy) = \\log_a x + \\log_a y$.\n- **Quotient:** $\\log_a(x/y) = \\log_a x - \\log_a y$.\n- **Power:** $\\log_a(x^n) = n \\log_a x$.\n- **Change of base:** $\\log_a x = \\frac{\\log_b x}{\\log_b a}$ for any valid base $b$.\n\nMini-example: $\\log_2(16 \\cdot 4) = \\log_2 16 + \\log_2 4 = 4 + 2 = 6$. Check: $2^6 = 64 = 16 \\cdot 4$.\n\n### Graph features\n\n- Domain $(0, \\infty)$; vertical asymptote at $x = 0$.\n- Passes through $(1, 0)$ and $(a, 1)$.\n- Reflection of $y = a^x$ over $y = x$.\n\n## Pattern families\n\n### Easy — Evaluate simple logs\n\nRewrite as “what power of base gives this number?” Use $\\log_a 1 = 0$, $\\log_a a = 1$. Connect base-10 and natural logs to familiar values.\n\n### Medium — Apply log laws\n\nExpand or condense expressions. Split products into sums; bring exponents down. Change base to evaluate unfamiliar logs.\n\n### Hard — Solve log and exponential equations\n\nIsolate log or exponent; convert between forms. Always check solutions in original equation — extraneous values appear when domain violated.\n\n## Worked mini-examples\n\n**Example 1 — Definition.**\n\n$\\log_3 81 = ?$ → $3^y = 81 = 3^4$ → answer 4.\n\n**Example 2 — Product law.**\n\n$\\log_{10} 50 + \\log_{10} 2 = \\log_{10} 100 = 2$.\n\n**Example 3 — Power law.**\n\n$\\log_2(x^5) = 5 \\log_2 x$.\n\n**Example 4 — Change of base.**\n\n$\\log_4 8 = \\frac{\\ln 8}{\\ln 4} = \\frac{3\\ln 2}{2\\ln 2} = 3/2$.\n\n**Example 5 — Solve.**\n\n$\\log_2(x - 1) = 3$ → $x - 1 = 2^3 = 8$ → $x = 9$. Check: $\\log_2 8 = 3$ ✓. Domain requires $x - 1 > 0$, so $x > 1$ — satisfied.\n\n## Traps\n\n- Taking $\\log$ of negative number or zero — undefined.\n- Using $\\log(x + y) = \\log x + \\log y$ — false; product law only.\n- Forgetting $0!$-style edge: $\\log_a 1 = 0$, not undefined.\n- Dividing logs incorrectly: $\\log x / \\log y \\neq \\log(x/y)$.\n- Accepting solution that makes log argument $\\leq 0$.\n\n## Diagnostic (try yourself)\n\n1. Evaluate $\\log_5 125$ and $\\log_3(1/9)$.\n\n2. Expand $\\log_2(8x^3)$ using log laws.\n\n3. Use change of base to express $\\log_8 4$ as a fraction.\n\n4. Solve $\\log_{10}(x) = 2$. State the domain condition.\n\n5. True or false: $\\ln(e^5) = 5$? What is $\\ln 1$?", "compressed": "log = inverse of exp → log laws → change of base → solve log equations.", "chain": [ { "label": "Definition", "expression": "y=log_a(x) ⇔ a^y=x", "when": "a>0, a≠1, x>0" }, { "label": "Product", "expression": "log(ab)=log a + log b", "when": "same base" }, { "label": "Quotient", "expression": "log(a/b)=log a − log b", "when": "same base" }, { "label": "Power", "expression": "log(a^k)=k log a", "when": "pull exponent out" }, { "label": "Change of base", "expression": "log_a b = log_c b / log_c a", "when": "calculator base" } ], "chattyReferenceId": "maths1-week6-reference", "recognition": "Ask: What does $\\log_2 8$ ask in words?", "procedure": "Rewrite as exponent question: \"what power of base gives this number?\" Use $\\log_a 1 = 0$, $\\log_a a = 1$. For base 10 or $e$, connect to familiar values.", "variations": "Watch for: Using $\\log(x+y) = \\log x + \\log y$ (false)." } }, { "week": 7, "title": "Sequences, limits & continuity", "focus": "sequence limits, one-sided limits, continuity", "noteId": "may-2026-maths-week-7-limits-continuity", "skipIfExists": false, "content": { "map": "Sequence terms → limit intuition → one-sided limits → continuity at a point", "concepts": "- **Sequence limit:** terms $a_n$ approach $L$ as $n$ grows; not every sequence converges.\n- **Function limit at $a$:** value approached as $x \\to a$ (may differ from $f(a)$).\n- **One-sided:** $\\lim_{x \\to a^-} f(x)$ and $\\lim_{x \\to a^+} f(x)$.\n- **Continuous at $a$:** $\\lim_{x \\to a} f(x) = f(a)$; all three must agree.", "notation": "| Term | Meaning |\n| --- | --- |\n| $\\lim_{n\\to\\infty} a_n = L$ | sequence converges to L |\n| $\\lim_{x\\to a} f(x)$ | two-sided limit |\n| Discontinuity | limit exists but $\\neq f(a)$, or limit fails |", "patterns": [ { "level": "Easy", "name": "Sequence pattern", "body": "Write first several terms from formula. Describe trend: increasing, decreasing, bounded. Guess limit by table or simplifying $a_n$ for large $n$ (e.g. divide numerator and denominator by highest power)." }, { "level": "Medium", "name": "Limit by algebra", "body": "Factor rational functions to cancel hole-causing terms. For piecewise functions, match one-sided limits at junction. If left $\\neq$ right, two-sided limit does not exist." }, { "level": "Hard", "name": "Continuity classification", "body": "Evaluate $f(a)$, left limit, right limit. Removable if limits agree but $f(a)$ wrong or missing. Jump if one-sided limits differ. Infinite if unbounded approach." } ], "traps": [ "Assuming limit equals function value without checking.", "Ignoring one-sided limits at piecewise knots.", "Sequence index $n$ vs function variable $x$.", "Thinking oscillation implies convergence." ], "retrieval": [ "What three conditions define continuity at $a$?", "When does a two-sided limit fail to exist?", "How do you find $\\lim_{n\\to\\infty} \\frac{3n+1}{n}$?" ], "deepStudy": "# Mathematics I · Week 7 — Limits and continuity\n\nDeep study for Quiz 2 week 7. Limits describe approaching behavior; continuity requires the approach to match the actual value.\n\n## Week map\n\nSequence terms → limit intuition → one-sided limits → two-sided limit → continuity at a point → types of discontinuity.\n\n## Limit notation\n\n- $\\lim_{x \\to a} f(x) = L$ → “limit of $f(x)$ as $x$ approaches $a$ is $L$” → value $f$ tends toward near $a$, not necessarily at $a$.\n- $\\lim_{x \\to a^-} f(x)$ → left-hand limit → approach from values less than $a$.\n- $\\lim_{x \\to a^+} f(x)$ → right-hand limit → approach from values greater than $a$.\n- $\\lim_{x \\to a} f(x)$ exists iff left and right limits exist and are equal.\n\nMini-example: $f(x) = \\frac{x^2 - 1}{x - 1}$ for $x \\neq 1$. Near $x = 1$: factor to $x + 1$, so $\\lim_{x \\to 1} f(x) = 2$, even though $f(1)$ is undefined.\n\n### Sequence limits\n\n- $\\lim_{n \\to \\infty} a_n = L$ → terms $a_n$ get arbitrarily close to $L$ as $n$ grows.\n- For rational sequences, divide numerator and denominator by highest power of $n$ to guess limit.\n\nMini-example: $a_n = \\frac{3n + 1}{n + 2}$. Divide top and bottom by $n$: $\\frac{3 + 1/n}{1 + 2/n} \\to 3$ as $n \\to \\infty$.\n\n## Continuity notation\n\n- **Continuous at $a$:** $\\lim_{x \\to a} f(x) = f(a)$ — limit exists, function defined, and they agree.\n- **Removable discontinuity:** limit exists but $f(a)$ missing or wrong — “hole” in graph.\n- **Jump discontinuity:** left and right limits exist but differ.\n- **Infinite discontinuity:** limit blows up to $\\pm\\infty$.\n\nMini-example: $f(x) = |x|/x$ at $x = 0$. Left limit $-1$, right limit $+1$ — jump discontinuity.\n\n## Pattern families\n\n### Easy — Sequence pattern\n\nWrite first several terms from formula. Describe trend. Guess limit by table or simplifying for large $n$.\n\n### Medium — One-sided and two-sided limits\n\nEvaluate limits from graphs. Identify left vs right behavior at breakpoints, absolute value corners, piecewise joins.\n\n### Hard — Continuity classification\n\nDecide if function is continuous at a point. Identify discontinuity type. State what value would make function continuous (removable case).\n\n## Worked mini-examples\n\n**Example 1 — Direct substitution.**\n\n$\\lim_{x \\to 3} (2x + 5) = 11$ — polynomial, no issue.\n\n**Example 2 — Cancel factor.**\n\n$\\lim_{x \\to 2} \\frac{x^2 - 4}{x - 2} = \\lim_{x \\to 2} (x + 2) = 4$.\n\n**Example 3 — One-sided.**\n\n$f(x) = \\begin{cases} x+1 & x < 0 \\\\ x^2 & x \\geq 0 \\end{cases}$. Left at 0: $1$; right at 0: $0$. Two-sided limit does not exist.\n\n**Example 4 — Sequence.**\n\n$a_n = \\frac{1}{n} \\to 0$ as $n \\to \\infty$.\n\n**Example 5 — Removable.**\n\n$f(x) = \\frac{\\sin x}{x}$ for $x \\neq 0$, $f(0) = 0$. $\\lim_{x \\to 0} \\frac{\\sin x}{x} = 1 \\neq f(0)$ — removable if redefine $f(0) = 1$.\n\n## Traps\n\n- Assuming $\\lim_{x \\to a} f(x) = f(a)$ without checking.\n- Ignoring one-sided limits at piecewise boundaries.\n- Thinking limit at infinity means function equals that value.\n- Canceling $(x - a)$ without noting hole at $x = a$.\n- Sequence limit confused with finite term value.\n\n## Diagnostic (try yourself)\n\n1. Find $\\lim_{x \\to 5} (x^2 - 3x)$.\n\n2. Evaluate $\\lim_{x \\to 1} \\frac{x^2 - 1}{x - 1}$.\n\n3. For $f(x) = \\frac{|x|}{x}$, what are the left and right limits at $x = 0$?\n\n4. Sequence $a_n = \\frac{2n}{n + 5}$: what value does $a_n$ approach as $n \\to \\infty$?\n\n5. A function has $\\lim_{x \\to 2} f(x) = 7$ but $f(2) = 3$. Is it continuous at 2? What type of issue is this?", "compressed": "sequence aₙ → limit L → one-sided limits → continuity at a point.", "chain": [ { "label": "Sequence limit", "expression": "aₙ → L as n→∞", "when": "terms approach L" }, { "label": "Left / right limit", "expression": "lim_{x→a⁻} f, lim_{x→a⁺} f", "when": "piecewise or endpoints" }, { "label": "Limit exists", "expression": "left = right = L", "when": "two-sided limit at a" }, { "label": "Continuity", "expression": "lim_{x→a} f(x) = f(a)", "when": "no jump/hole at a" }, { "label": "Standard limits", "expression": "lim sin x/x = 1 (x→0)", "when": "squeeze / known forms" } ], "chattyReferenceId": "maths1-week7-reference", "recognition": "Ask: What three conditions define continuity at $a$?", "procedure": "Write first several terms from formula. Describe trend: increasing, decreasing, bounded. Guess limit by table or simplifying $a_n$ for large $n$ (e.g. divide numerator and denominator by highest power).", "variations": "Watch for: Assuming limit equals function value without checking." } }, { "week": 8, "title": "Derivatives & critical points", "focus": "derivative rules, tangents, extrema, L’Hôpital", "noteId": "may-2026-maths-week-8-derivatives", "skipIfExists": false, "content": { "map": "Derivative as rate → rules → tangent line → critical points → optimization sketch", "concepts": "- **Derivative** $f'(x)$: instantaneous rate of change; slope of tangent at $x$.\n- **Rules:** power, sum, product, quotient, chain for compositions.\n- **Tangent line:** $y - f(a) = f'(a)(x-a)$.\n- **Critical points:** $f'(x)=0$ or undefined; test max/min with sign chart or second derivative.", "notation": "| Rule | Formula |\n| --- | --- |\n| Power | $(x^n)' = nx^{n-1}$ |\n| Chain | $(f(g(x)))' = f'(g(x))g'(x)$ |\n| Tangent | slope $m = f'(a)$ at $x=a$ |", "patterns": [ { "level": "Easy", "name": "Power and sum rule", "body": "Differentiate term by term. Constants vanish; bring down exponent for powers. Rewrite roots and reciprocals as powers before differentiating." }, { "level": "Medium", "name": "Tangent line problem", "body": "Find $f'(a)$ and $f(a)$. Plug into point-slope form. Simplify to slope-intercept if needed. Domain of tangent matches domain of derivative." }, { "level": "Hard", "name": "Critical points and shape", "body": "Solve $f'(x)=0$ on domain. Classify with sign chart of $f'$ or $f''$. State intervals of increase/decrease. For Quiz 2 scope, justify max/min in words from derivative sign change." } ], "traps": [ "Forgetting chain rule on $(3x+1)^5$.", "Critical point where derivative undefined (corner, vertical tangent).", "Confusing $f'(x)=0$ with always a max.", "Quotient rule order in denominator squared term." ], "retrieval": [ "What does $f'(2)$ represent geometrically?", "How do you find critical numbers of $f$?", "When is L'Hôpital's rule relevant at a limit?" ], "deepStudy": "# Mathematics I · Week 8 — Derivatives and critical points\n\nDeep study for Quiz 2 week 8. Derivative measures instantaneous rate of change; critical points locate where slope is zero or undefined.\n\n## Week map\n\nDerivative as slope → differentiation rules → tangent line → critical points → increasing/decreasing → local extrema sketch.\n\n## Derivative notation\n\n- $f'(x)$ or $\\frac{dy}{dx}$ → derivative of $f$ at $x$ → instantaneous rate of change → slope of tangent line at $x$.\n- $(x^n)' = nx^{n-1}$ → power rule → bring exponent down, reduce power by one.\n- $(cf)' = c \\cdot f'$ → constant multiple.\n- $(f + g)' = f' + g'$ → sum rule.\n\nMini-example: if $f(x) = x^3 - 2x$, then $f'(x) = 3x^2 - 2$. At $x = 1$: $f'(1) = 1$ — tangent slope is 1.\n\n### Chain and product (when needed)\n\n- **Chain:** $(f(g(x)))' = f'(g(x)) \\cdot g'(x)$ — derivative of outside × derivative of inside.\n- **Product:** $(fg)' = f'g + fg'$.\n\nMini-example: $(3x^2 + 1)^4$ — outer power 4, inner $3x^2+1$. Derivative $= 4(3x^2+1)^3 \\cdot 6x$.\n\n## Tangent line\n\n- Line through $(a, f(a))$ with slope $m = f'(a)$: $y - f(a) = f'(a)(x - a)$.\n- Tangent approximates curve locally near $x = a$.\n\nMini-example: $f(x) = x^2$, $a = 3$. $f(3) = 9$, $f'(x) = 2x$, $f'(3) = 6$. Tangent: $y - 9 = 6(x - 3)$ → $y = 6x - 9$.\n\n## Critical points\n\n- **Critical point** → where $f'(x) = 0$ or $f'(x)$ undefined.\n- **First derivative test:** sign of $f'$ changes from $+$ to $-$ at critical point → local max; $-$ to $+$ → local min.\n- **Increasing:** $f' > 0$; **decreasing:** $f' < 0$.\n\nMini-example: $f(x) = x^2 - 4x + 3$. $f'(x) = 2x - 4 = 0$ → $x = 2$. $f'$ negative before 2, positive after → local min at $x = 2$.\n\n## Pattern families\n\n### Easy — Power and sum rule\n\nDifferentiate term by term. Constants vanish. Rewrite roots and reciprocals as powers first: $\\sqrt{x} = x^{1/2}$, $1/x = x^{-1}$.\n\n### Medium — Tangent line and evaluate derivative\n\nFind $f'(a)$, write tangent equation. Interpret $f'(a)$ as rate (velocity, marginal cost) in word problems.\n\n### Hard — Critical points and extrema\n\nSolve $f'(x) = 0$. Build sign chart. Classify max/min. Sketch behavior without full graph.\n\n## Worked mini-examples\n\n**Example 1 — Power rule.**\n\n$\\frac{d}{dx}(5x^4 - 3x + 7) = 20x^3 - 3$.\n\n**Example 2 — Rewrite then differentiate.**\n\n$f(x) = \\frac{1}{x^2} = x^{-2}$ → $f'(x) = -2x^{-3} = -2/x^3$.\n\n**Example 3 — Tangent.**\n\n$f(x) = x^3$, $a = 1$. $f(1) = 1$, $f'(1) = 3$. Tangent: $y = 3x - 2$.\n\n**Example 4 — Critical point.**\n\n$f(x) = -x^2 + 6x$. $f'(x) = -2x + 6 = 0$ → $x = 3$. Max (parabola opens down).\n\n**Example 5 — Chain rule.**\n\n$f(x) = (2x + 1)^3$. $f'(x) = 3(2x+1)^2 \\cdot 2 = 6(2x+1)^2$.\n\n## Traps\n\n- Forgetting to multiply by inner derivative in chain rule.\n- Critical point assumed to be max/min without sign test.\n- Tangent uses wrong point — must pass through $(a, f(a))$.\n- $(fg)' written as $f'g'$ — product rule differs.\n- Derivative of constant not zero in long expressions.\n\n## Diagnostic (try yourself)\n\n1. Find $f'(x)$ for $f(x) = 4x^3 - 5x^2 + x - 9$.\n\n2. Differentiate $g(x) = \\sqrt{x} + 1/x$ (rewrite powers first).\n\n3. Find the equation of the tangent line to $f(x) = x^2$ at $x = -2$.\n\n4. For $f(x) = x^3 - 3x$, find all critical points.\n\n5. If $f'(x) > 0$ on an interval, is $f$ increasing or decreasing there?", "compressed": "f′(x)=limit of difference quotient → power/rule derivatives → f′=0 critical → max/min.", "chain": [ { "label": "Definition", "expression": "f′(x)=lim_{h→0}(f(x+h)−f(x))/h", "when": "from first principles" }, { "label": "Power rule", "expression": "d/dx x^n = n x^{n−1}", "when": "polynomial terms" }, { "label": "Tangent slope", "expression": "m_tan = f′(a)", "when": "slope at x=a" }, { "label": "Critical point", "expression": "f′(x)=0 or undefined", "when": "candidate extrema" }, { "label": "L'Hôpital", "expression": "lim f/g = lim f′/g′", "when": "0/0 or ∞/∞ indeterminate" } ], "chattyReferenceId": "maths1-week8-reference", "recognition": "Ask: What does $f'(2)$ represent geometrically?", "procedure": "Differentiate term by term. Constants vanish; bring down exponent for powers. Rewrite roots and reciprocals as powers before differentiating.", "variations": "Watch for: Forgetting chain rule on $(3x+1)^5$." } } ] }, { "courseId": "python", "folder": "Python", "label": "Programming in Python", "prepGuideId": "may-2026-python-quiz-2-weeks-1-8-prep", "weeks": [ { "week": 1, "title": "Introduction to algorithms", "focus": "types, expressions, tracing state", "noteId": "may-2026-python-week-1-algorithms", "skipIfExists": false, "content": { "map": "Algorithm idea → types → expressions → trace variable updates", "concepts": "- **Algorithm:** ordered steps that transform input to output; state is values in memory at each step.\n- **Types:** int, float, bool, str; type tells which operations are legal.\n- **Expressions** evaluate to a value; **statements** change state (assignment).\n- **Tracing:** follow line order; update variables; print shows current value.", "notation": "| Type | Literal examples |\n| --- | --- |\n| int | `42`, `-7` |\n| float | `3.14`, `-0.5` |\n| bool | `True`, `False` |\n| str | `\"hello\"` |", "patterns": [ { "level": "Easy", "name": "Predict final value", "body": "Execute assignments top to bottom without skipping. When a variable is reassigned, old value is lost. For expressions, apply operator precedence before assignment." }, { "level": "Medium", "name": "Type of expression", "body": "Identify operand types first. Mixed int/float often yields float in Python 3. Division `/` is float; `//` is floor division. Comparison expressions yield bool." }, { "level": "Hard", "name": "Trace with dependencies", "body": "When later lines use earlier variables, build a small table: line number, variable, new value. Watch order: RHS fully evaluated before LHS update." } ], "traps": [ "Using `=` for comparison instead of `==`.", "Assuming `/` returns int in Python 3.", "Reading code bottom-up when state evolves top-down.", "Ignoring that strings concatenate with `+`, not add numerically." ], "retrieval": [ "What is stored after `x = 3` then `x = x + 2`?", "What type is `3 / 2` in Python 3?", "Difference between expression and statement?" ], "compressed": "Trace types → evaluate expressions with precedence → assignment updates bindings.", "chain": [ { "label": "Types", "expression": "int, float, str, bool", "when": "before any operator" }, { "label": "Precedence", "expression": "**, *, /, //, %, +, -", "when": "mixed arithmetic" }, { "label": "Division", "expression": "/ → float, // → floor", "when": "Python 3" }, { "label": "Assignment", "expression": "name = expression", "when": "RHS fully evaluated first" }, { "label": "Comparison", "expression": "==, !=, <, chained: a<b<c", "when": "yields bool" } ], "deepStudy": "# Programming in Python · Week 1 — Algorithms and types\n\nFirst-week Python is about **predictable state change**: what each line does to memory, and which types allow which operations.\n\n## Week map\n\nAlgorithm as ordered steps → variables and assignment → built-in types → expressions vs statements → operator precedence → tracing print output.\n\n## Type notation\n\n- `int` → integer type → whole numbers → `17`, `-4`, `0`.\n- `float` → floating type → decimal approximations → `3.0`, `-0.25`, `2.718`.\n- `bool` → boolean type → truth values → `True`, `False` only.\n- `str` → string type → text sequence → `\"score\"`, `'A'`.\n- `type(x)` → returns type of value → `type(3/2)` is `float` in Python 3.\n\n### Literals and assignment\n\n- `x = 5` → assignment statement → bind name `x` to value 5 → later `x` reads 5 until reassigned.\n- `=` is not equality test; equality is `==`.\n\nMini-trace:\n\n```python\na = 10\nb = a + 3\na = 2\nprint(b)\n```\n\n`b` becomes 13 before `a` changes; prints `13`.\n\n## Expressions and operators\n\n| Operator | Meaning | Example result |\n| --- | --- | --- |\n| `+` | add / concat | `3+4` → 7; `\"ab\"+\"c\"` → `\"abc\"` |\n| `-` | subtract | `7-2` → 5 |\n| `*` | multiply / repeat | `3*4` → 12; `\"ha\"*3` → `\"hahaha\"` |\n| `/` | true division (float) | `7/2` → 3.5 |\n| `//` | floor division | `7//2` → 3 |\n| `%` | remainder | `7%2` → 1 |\n| `**` | power | `2**3` → 8 |\n\n**Precedence:** parentheses, then `**`, then `* / // %`, then `+ -`.\n\nMini-example: `2 + 3 * 4` → `2 + 12` → `14`. Not `20`.\n\n## Algorithm tracing habit\n\nColumns: line | variables after line | output.\n\n```python\nx = 4\ny = x * 2\nx = y - 1\nprint(x + y)\n```\n\n| line | x | y | notes |\n| --- | --- | --- | --- |\n| 1 | 4 | — | |\n| 2 | 4 | 8 | |\n| 3 | 7 | 8 | |\n| 4 | | | prints 15 |\n\n## Pattern families\n\n### Easy — Final value prediction\n\n- Straight-line assignments without branches.\n- Single `print` of expression or variable.\n- Identify type of literal or simple expression.\n\n### Medium — Mixed-type expressions\n\n- Division always float in Python 3.\n- Floor division and mod with negatives (know course convention; often positive mod for quiz).\n- String `+` vs numeric `+` — types must match for numeric add.\n\n### Hard — Multi-variable dependency chains\n\n- Reassignment overwrites; old value gone unless another name still references it (week 1 usually one name per value).\n- Expression on RHS fully evaluated before LHS update.\n- `print` with comma-separated items vs concatenation.\n\n## Worked mini-examples\n\n**Example 1 — Division types.**\n\n```python\na = 9 / 2 # 4.5 float\nb = 9 // 2 # 4 int\nc = 9 % 2 # 1\n```\n\n**Example 2 — String vs int.**\n\n```python\nn = 7\nmsg = \"Level \" + str(n) # \"Level 7\"\n# \"Level \" + n would error\n```\n\n**Example 3 — Precedence.**\n\n```python\nresult = 10 - 2 ** 3 + 1 # 10 - 8 + 1 = 3\n```\n\n**Example 4 — Reassignment chain.**\n\n```python\np = 1\nq = p + 4 # q = 5\np = q # p = 5\nq = p + 2 # q = 7\n# p is 5, q is 7\n```\n\n## Traps\n\n- Using `=` in a condition (week 2 topic, but appears early in distractors).\n- Assuming `/` gives integer quotient in Python 3.\n- Concatenating str with int without `str()`.\n- Reading code bottom-up when state evolves top-down.\n- Confusing `//` with `/`.\n\n## Diagnostic (try yourself)\n\n1. What is printed?\n\n```python\nx = 8\ny = x // 3\nx = y * 5\nprint(x)\n```\n\n2. What is the type of `3 + 2.0`? What is the type of `4 / 2`?\n\n3. What is the value of `10 - 3 ** 2 + 1`?\n\n4. After `a = 6`, `b = a`, `a = 10`, what are `a` and `b`?\n\n5. Write one expression that produces `\"Go\" + \"Go\"` using only the integer `2` and string operations (no quotes in the expression except on `\"Go\"`).", "chattyReferenceId": "python-week1-reference", "recognition": "Ask: What is stored after `x = 3` then `x = x + 2`?", "procedure": "Execute assignments top to bottom without skipping. When a variable is reassigned, old value is lost. For expressions, apply operator precedence before assignment.", "variations": "Watch for: Using `=` for comparison instead of `==`." } }, { "week": 2, "title": "Conditionals", "focus": "if/elif/else, predicates, truthiness", "noteId": "may-2026-python-week-2-conditionals", "skipIfExists": false, "content": { "map": "Predicate → branch choice → elif chain → else default", "concepts": "- **if / elif / else:** exactly one branch runs when predicates are tested in order.\n- **Predicate:** expression with bool result; comparisons and ==, !=, <, >, <=, >=.\n- **Truthiness:** empty string, 0, empty list are falsy; most other values truthy.\n- **Indentation** defines block body—must be consistent.", "notation": "| Construct | Role |\n| --- | --- |\n| `if cond:` | first test |\n| `elif cond:` | alternate test |\n| `else:` | fallback when all tests false |", "patterns": [ { "level": "Easy", "name": "Which branch runs?", "body": "Evaluate only until first true predicate. Skip remaining elif/else. If none true, only else runs—or no branch if else missing." }, { "level": "Medium", "name": "Boundary comparisons", "body": "Check inclusive vs exclusive bounds carefully. Chain of elif is not independent if-tests; earlier true branch blocks later ones even if they would also be true." }, { "level": "Hard", "name": "Truthiness trap", "body": "Nonzero numbers and non-empty strings are truthy. `if x:` differs from `if x == True`. Empty input string may be valid data—decide policy before condensing to truthiness." } ], "traps": [ "elif after a true if still evaluated (it is skipped).", "Confusing `is` with `==` for value equality.", "Missing else when all paths must assign a variable.", "Off-by-one on inclusive `<=` vs exclusive `<`." ], "retrieval": [ "When does elif run relative to if?", "Which values are falsy in Python?", "What prints if all if/elif tests fail and there is no else?" ], "compressed": "predicate → if/elif/else (first true wins) → and/or short-circuit.", "chain": [ { "label": "Branch", "expression": "if cond: ... elif: ... else:", "when": "at most one block runs" }, { "label": "and", "expression": "A and B", "when": "both must be true" }, { "label": "or", "expression": "A or B", "when": "at least one true" }, { "label": "Equality", "expression": "== vs =", "when": "compare vs assign" }, { "label": "Truthiness", "expression": "0, \"\", [], None → falsy", "when": "if without explicit bool" } ], "deepStudy": "# Programming in Python · Week 2 — Conditionals\n\nBranching chooses **one path** based on predicates. Quiz items reward exact knowledge of evaluation order and truth values.\n\n## Week map\n\nBoolean predicates → `if` / `elif` / `else` → first-match wins → truthiness → comparison operators → common boundary bugs.\n\n## Conditional notation\n\n- `if cond:` → conditional block → runs body only when `cond` is `True`.\n- `elif cond:` → else-if → tested only if all prior branches failed.\n- `else:` → fallback → runs when every test above was false.\n- `cond` → predicate → expression with boolean result → `x >= 10`, `name == \"Ada\"`.\n\n### Comparison operators\n\n| Op | Meaning | Example true when |\n| --- | --- | --- |\n| `==` | equal value | `5 == 5` |\n| `!=` | not equal | `3 != 7` |\n| `<`, `>` | strict less/greater | `2 < 9` |\n| `<=`, `>=` | inclusive | `4 <= 4` |\n\n**Trap:** `is` tests identity (same object), not numeric equality for large ints in advanced contexts; week 2 quizzes usually want `==` for value compare.\n\n## Truthiness\n\nIn `if x:`, Python treats values as:\n\n- **Falsy:** `0`, `0.0`, `False`, `None`, `\"\"`, `[]`, `{}`, `()`.\n- **Truthy:** most other values, including nonzero numbers and non-empty strings.\n\n`if 3:` runs. `if \"\":` skips.\n\nMini-example:\n\n```python\nscore = 0\nif score:\n print(\"played\")\nelse:\n print(\"skipped\")\n```\n\nPrints `skipped` because `0` is falsy — even though zero may be a valid score in real life.\n\n## Branch selection rules\n\n1. Evaluate `if` condition. If true, run its block and **skip all** `elif` and `else`.\n2. Else evaluate first `elif`. If true, run it and skip rest.\n3. If none true, run `else` if present; if no `else`, no block runs.\n\n```python\nn = 14\nif n < 10:\n label = \"low\"\nelif n < 20:\n label = \"mid\"\nelse:\n label = \"high\"\n# label is \"mid\"\n```\n\n`n < 20` is true but never tested because `n < 10` was false and `n < 20` is the first true `elif`.\n\n## Pattern families\n\n### Easy — Which branch runs?\n\n- Single `if` / `else` with numeric compare.\n- Predict print output from one predicate.\n- Identify when `else` runs.\n\n### Medium — `elif` chains and boundaries\n\n- Inclusive vs exclusive thresholds (`<=` vs `<`).\n- Overlapping conditions — only first true branch executes.\n- Assign variable in branches; trace final value.\n\n### Hard — Truthiness and edge inputs\n\n- Empty string vs `\"0\"` string (truthy).\n- `if x:` vs `if x == True` (usually prefer explicit compare for clarity).\n- Multiple variables set in different branches — know which path ran.\n\n## Worked mini-examples\n\n**Example 1 — First match.**\n\n```python\nx = 25\nif x > 30:\n print(\"A\")\nelif x > 20:\n print(\"B\")\nelif x > 10:\n print(\"C\")\nelse:\n print(\"D\")\n```\n\nPrints `B` only.\n\n**Example 2 — Missing else.**\n\n```python\nk = 3\nif k > 5:\n t = 1\n# no else\n# t may not exist — NameError if referenced\n```\n\n**Example 3 — Boundary.**\n\n```python\nage = 18\nif age >= 18:\n status = \"adult\"\nelse:\n status = \"minor\"\n# status = \"adult\" (18 counts)\n```\n\n**Example 4 — Truthiness.**\n\n```python\nname = \"\"\nif name:\n print(\"hi\")\nelse:\n print(\"empty\")\n# prints empty\n```\n\n## Traps\n\n- `elif` still evaluated mentally when `if` was true — it is skipped entirely.\n- Off-by-one on inclusive bounds.\n- Assigning in one branch but using variable assuming another branch ran.\n- `== True` with integers: only `1` equals `True` oddly; prefer `if flag:` or `if flag is True` rarely.\n- Dangling logic: two separate `if` statements both may run — different from `if` / `elif`.\n\n## Diagnostic (try yourself)\n\n1. What is printed?\n\n```python\nv = 12\nif v > 15:\n print(\"X\")\nelif v > 8:\n print(\"Y\")\nelse:\n print(\"Z\")\n```\n\n2. After this code, what is `w`?\n\n```python\nw = 5\nif w < 3:\n w = 10\nelif w < 7:\n w = 20\nelse:\n w = 30\n```\n\n3. What is printed?\n\n```python\nflag = 0\nif flag:\n print(\"on\")\nelse:\n print(\"off\")\n```\n\n4. Rewrite using only `if` and `else` (no `elif`): assign `\"pass\"` when `score >= 40`, else `\"fail\"`. Variable `score` already exists.\n\n5. Two separate `if` statements both test `x > 0`. First prints `\"A\"`, second prints `\"B\"`. If `x = 5`, what prints? If `x = -1`, what prints?", "chattyReferenceId": "python-week2-reference", "recognition": "Ask: When does elif run relative to if?", "procedure": "Evaluate only until first true predicate. Skip remaining elif/else. If none true, only else runs—or no branch if else missing.", "variations": "Watch for: elif after a true if still evaluated (it is skipped)." } }, { "week": 3, "title": "Conditionals continued", "focus": "nested branches, and/or, decision tables", "noteId": "may-2026-python-week-3-conditionals-nested", "skipIfExists": false, "content": { "map": "Compound predicates → nested if → decision table → de Morgan", "concepts": "- **and / or / not:** and needs both true; or needs at least one; not flips.\n- **Nested if:** inner test only when outer is true; scope of each block matters.\n- **Decision table:** rows are cases; columns are conditions; one action column.\n- **De Morgan:** not (A and B) equals not A or not B; not (A or B) equals not A and not B.", "notation": "| Operator | True when |\n| --- | --- |\n| `A and B` | both A and B true |\n| `A or B` | at least one true |\n| `not A` | A is false |", "patterns": [ { "level": "Easy", "name": "Compound predicate", "body": "Evaluate and/or left to right with short-circuit: `and` stops at first false; `or` stops at first true. Parentheses override default grouping." }, { "level": "Medium", "name": "Nested branch trace", "body": "Outer false skips entire inner block. Draw indentation levels on paper. Each level has its own else paired with nearest if." }, { "level": "Hard", "name": "Decision table to code", "body": "List mutually exclusive cases. Encode as if/elif chain or nested structure. Verify every input row maps to exactly one outcome; add else for uncovered cases." } ], "traps": [ "and/or confused with mathematical inequalities.", "Dangling else attaching to wrong if.", "not (x > 0 and x < 10) mishandled without de Morgan.", "Treating or as exclusive (Python or allows both true)." ], "retrieval": [ "When does `A or B` short-circuit?", "Rewrite `not (p and q)` without not on and.", "How does nesting change which else runs?" ], "deepStudy": "# Programming in Python · Week 3 — Nested conditionals\n\nCompound predicates and nested blocks combine simple tests into **structured decisions** — the quiz tests scope, pairing, and logical operators.\n\n## Week map\n\n`and` / `or` / `not` → short-circuit evaluation → nested `if` → indentation scope → de Morgan rewrites → decision tables → exclusive cases.\n\n## Logical operator notation\n\n- `A and B` → both must be true → `x > 0 and x < 10` true only inside (0,10).\n- `A or B` → at least one true → `day == \"Sat\" or day == \"Sun` for weekend.\n- `not A` → negation → `not (x == 5)` same as `x != 5` for values.\n- **Short-circuit:** `False and f()` does not call `f()`; `True or g()` skips `g()`.\n\n### Truth tables (mini)\n\n| A | B | A and B | A or B |\n| --- | --- | --- | --- |\n| T | T | T | T |\n| T | F | F | T |\n| F | T | F | T |\n| F | F | F | F |\n\n## De Morgan’s laws\n\n- `not (A and B)` ≡ `not A or not B`\n- `not (A or B)` ≡ `not A and not B`\n\nMini-example: “not (teen and student)” → `not teen or not student`.\n\nUseful for simplifying negated compound conditions without bracket errors.\n\n## Nested `if` structure\n\nOuter `if` false → entire inner block skipped.\n\n```python\nx = 6\ny = 2\nif x > 5:\n if y > 5:\n print(\"both\")\n else:\n print(\"outer only\")\nelse:\n print(\"neither\")\n```\n\nPrints `outer only` because inner `y > 5` fails.\n\n**Else pairing:** `else` attaches to the nearest unmatched `if` at same indentation.\n\n## Pattern families\n\n### Easy — Compound predicate\n\n- Evaluate `and`/`or` on two compares.\n- Predict result of `not` on simple inequality.\n- Short-circuit: second operand may not run.\n\n### Medium — Nested branch trace\n\n- Two-level nesting with prints in each block.\n- Identify which `else` runs.\n- Convert word problem “if A and B then … else if C …” to code shape.\n\n### Hard — Decision table to code\n\n- Mutually exclusive cases as `if` / `elif` chain.\n- Negated compound conditions via de Morgan.\n- Equivalent rewrites: nested `if` vs single compound predicate.\n\n## Worked mini-examples\n\n**Example 1 — and gate.**\n\n```python\ntemp = 22\nhumid = 80\nif temp > 18 and humid < 70:\n comfort = \"dry warm\"\nelse:\n comfort = \"other\"\n# comfort = \"other\" (humid fails)\n```\n\n**Example 2 — or weekend.**\n\n```python\nd = \"Sat\"\nif d == \"Fri\" or d == \"Sat\" or d == \"Sun\":\n kind = \"off\"\nelse:\n kind = \"work\"\n# kind = \"off\"\n```\n\n**Example 3 — de Morgan.**\n\n```python\nage = 16\nlicensed = False\n# not (age >= 18 and licensed)\nif not (age >= 18 and licensed):\n can_drive = False\nelse:\n can_drive = True\n# can_drive False\n```\n\n**Example 4 — nested.**\n\n```python\na, b = 3, 3\nif a > 0:\n if b > 0:\n sign = \"++\"\n else:\n sign = \"+-\"\nelse:\n sign = \"-\"\n# sign = \"++\"\n```\n\n## Traps\n\n- `and` confused with “between” — need two inequalities: `low <= x and x <= high`.\n- Dangling `else` paired with wrong `if` after editing indentation.\n- `or` is inclusive — both true still satisfies `or`.\n- Negating without parentheses: `not x > 5` parses as `(not x) > 5` — wrong; use `not (x > 5)`.\n- Nested structure duplicated work — two separate `if x>0` and `if y>0` differ from `if x>0 and y>0`.\n\n## Diagnostic (try yourself)\n\n1. What is `result`?\n\n```python\nn = 7\nif n % 2 == 0 and n > 5:\n result = \"A\"\nelif n % 2 == 1 and n > 5:\n result = \"B\"\nelse:\n result = \"C\"\n```\n\n2. Rewrite without `not ( ... and ... )` using de Morgan:\n\n```python\nif not (x < 0 or x > 100):\n ok = True\n```\n\n3. What prints?\n\n```python\np, q = 2, 10\nif p > 0:\n if q < 5:\n print(1)\n else:\n print(2)\nelse:\n print(3)\n```\n\n4. For integers `a` and `b`, write one `if` condition that is true exactly when both are positive.\n\n5. `if True or expensive():` — is `expensive()` called? Why?", "compressed": "nested if → decision table → and/or precedence → elif ladder order.", "chain": [ { "label": "Nested if", "expression": "if A: if B: ...", "when": "compound conditions" }, { "label": "and/or precedence", "expression": "and before or", "when": "use parentheses when unsure" }, { "label": "elif chain", "expression": "first true branch wins", "when": "mutually exclusive cases" }, { "label": "Boolean ops", "expression": "not, and, or", "when": "combine predicates" }, { "label": "Decision table", "expression": "rows = cases, cols = outcomes", "when": "trace before coding" } ], "chattyReferenceId": "python-week3-reference", "recognition": "Ask: When does `A or B` short-circuit?", "procedure": "Evaluate and/or left to right with short-circuit: `and` stops at first false; `or` stops at first true. Parentheses override default grouping.", "variations": "Watch for: and/or confused with mathematical inequalities." } }, { "week": 4, "title": "Iterations & ranges", "focus": "for, while, range(), accumulation", "noteId": "may-2026-python-week-4-iterations", "skipIfExists": false, "content": { "map": "Loop choice → range endpoints → accumulator → termination", "concepts": "- **for loop:** iterate over sequence or range(start, stop, step); stop is exclusive.\n- **while loop:** repeat while condition true; needs progress toward false to avoid infinite loop.\n- **Accumulator:** variable updated each iteration (total += x).\n- **Loop variable** takes each value in turn; may be unused with for _ in range(n).", "notation": "| Loop | Typical use |\n| --- | --- |\n| `for i in range(n):` | counted repetition |\n| `while cond:` | repeat until condition fails |\n| `range(a,b)` | integers from a up to but not b |", "patterns": [ { "level": "Easy", "name": "Count iterations", "body": "range(5) gives 0..4 (five values). range(2,7) gives 2..6. Step defaults to 1; negative step counts down when start > stop." }, { "level": "Medium", "name": "Accumulator trace", "body": "Initialize before loop. Each pass updates from current value. Print after loop if question asks final total—not inside unless printing each step." }, { "level": "Hard", "name": "while with guard", "body": "Identify condition and what changes each iteration. Check invariant: condition eventually false. Common pattern: read until sentinel value." } ], "traps": [ "range(1, n) vs range(n) off-by-one.", "Forgetting to initialize accumulator.", "Modifying loop variable expecting to change range length.", "while True without break exit path." ], "retrieval": [ "How many values does `range(3, 8)` produce?", "Where must an accumulator be initialized?", "When prefer for over while?" ], "deepStudy": "# Programming in Python · Week 4 — Iterations and range\n\nLoops repeat work. Week 4 focuses on **counted** repetition (`for` + `range`) and **accumulators** — sums, counts, products.\n\n## Week map\n\nWhy loop → `for` over sequence → `range` start/stop/step → accumulator pattern → `while` guard → off-by-one discipline.\n\n## Loop notation\n\n- `for i in range(n):` → counted loop → `i` takes each value produced by `range` → body runs once per value.\n- `range(stop)` → integers `0, 1, …, stop-1` → `range(4)` → 0,1,2,3 (four values).\n- `range(start, stop)` → from `start` inclusive to `stop` exclusive → `range(2,6)` → 2,3,4,5.\n- `range(start, stop, step)` → step size → `range(0,10,2)` → 0,2,4,6,8.\n\n**Trap:** `stop` is never included. `range(1,5)` has 4 values, not 5.\n\n### Accumulator\n\n```python\ntotal = 0 # neutral for sum\nfor k in range(5):\n total = total + k\n# total = 0+1+2+3+4 = 10\n```\n\nInitialize **before** loop. Update **inside** loop.\n\n## `for` vs `while`\n\n- `for` — known iteration count or explicit sequence.\n- `while cond:` — repeat until `cond` false; must ensure progress toward termination.\n\nMini-`while`:\n\n```python\nn = 8\nwhile n > 0:\n n = n - 3\n# n goes 8→5→2→-1, stops; loop ran 3 times\n```\n\n## Pattern families\n\n### Easy — Count iterations\n\n- How many values does `range(a,b)` produce? → `max(0, b-a)` for step 1.\n- List indices visited: `range(len(s))` for string `s`.\n- Final loop variable value after `for` (last assigned value remains).\n\n### Medium — Accumulator trace\n\n- Sum 1..n, sum of squares, count positives in fixed list.\n- Product accumulator starts at 1, not 0.\n- Print once after loop vs each iteration.\n\n### Hard — Combined condition in loop\n\n- Sum only entries meeting predicate (`if x % 2 == 0` inside loop).\n- `while` with compound update; detect infinite loop risk if condition never changes.\n- Nested setup for week 5 preview: outer `i`, inner `j` — count pairs briefly.\n\n## Worked mini-examples\n\n**Example 1 — range count.**\n\n`range(3, 11)` → 3,4,5,6,7,8,9,10 → eight iterations.\n\n**Example 2 — Sum 1 to 10.**\n\n```python\ns = 0\nfor i in range(1, 11):\n s += i\n# s = 55\n```\n\n**Example 3 — Count evens.**\n\n```python\ndata = [4, 7, 2, 9, 0, 6]\nc = 0\nfor x in data:\n if x % 2 == 0:\n c += 1\n# c = 4\n```\n\n**Example 4 — while decay.**\n\n```python\nval = 20\nsteps = 0\nwhile val >= 10:\n val = val - 6\n steps += 1\n# val = 8, steps = 2\n```\n\n**Example 5 — step range.**\n\n```python\nt = 0\nfor j in range(0, 15, 3):\n t += j\n# j: 0,3,6,9,12 → t = 30\n```\n\n## Traps\n\n- `range(1, n)` vs `range(n)` — classic off-by-one.\n- Forgetting accumulator initialization (`total = 0` missing).\n- Modifying loop variable expecting to change how many iterations — `range` already fixed.\n- `while True` without `break` path.\n- Using `=` instead of `+=` in accumulation (`total = x` resets each time).\n\n## Diagnostic (try yourself)\n\n1. How many numbers does `range(5, 15)` generate? List them.\n\n2. What is the final value of `sum`?\n\n```python\nsum = 0\nfor i in range(2, 8):\n sum = sum + i\n```\n\n3. What is printed?\n\n```python\nprod = 1\nfor k in range(1, 5):\n prod = prod * 2\nprint(prod)\n```\n\n4. Write a loop that prints integers 10 down to 1 (inclusive) using `range` with a negative step.\n\n5. After this loop, what is `n`?\n\n```python\nn = 50\nwhile n > 1:\n n = n // 2\n```", "compressed": "for/while → range(start,stop,step) → accumulator → loop invariant.", "chain": [ { "label": "for loop", "expression": "for x in seq:", "when": "known iteration count" }, { "label": "while loop", "expression": "while cond:", "when": "stop when condition false" }, { "label": "range", "expression": "range(n), range(a,b), range(a,b,s)", "when": "0..n-1 or stepped" }, { "label": "Accumulator", "expression": "total = total + x", "when": "sum/count/product patterns" }, { "label": "Infinite loop trap", "expression": "cond never becomes false", "when": "check update inside while" } ], "chattyReferenceId": "python-week4-reference", "recognition": "Ask: How many values does `range(3, 8)` produce?", "procedure": "range(5) gives 0..4 (five values). range(2,7) gives 2..6. Step defaults to 1; negative step counts down when start > stop.", "variations": "Watch for: range(1, n) vs range(n) off-by-one." } }, { "week": 5, "title": "Iterations continued", "focus": "nested loops, search, min/max patterns", "noteId": "may-2026-python-week-5-iterations-nested", "skipIfExists": false, "content": { "map": "Outer loop → inner loop → search flag → running min/max", "concepts": "- **Nested loops:** inner completes fully for each outer step; total iterations = product of counts.\n- **Search:** boolean found flag or early break when target located.\n- **Min/max:** initialize with first element or float('inf'); update when comparison holds.\n- **break** exits innermost loop only unless labeled logic restructures.", "notation": "| Pattern | Template |\n| --- | --- |\n| Search | flag + break on match |\n| Max | `best = seq[0]` then compare |\n| Nested | outer drives rows, inner columns |", "patterns": [ { "level": "Easy", "name": "Nested count", "body": "Multiply outer and inner trip counts. Trace one outer step showing full inner run. Useful for tables and coordinate pairs." }, { "level": "Medium", "name": "Find in sequence", "body": "Linear search: compare each element. Set found True and break, or use for-else idiom. Report index if needed by tracking i." }, { "level": "Hard", "name": "Min with updates", "body": "Choose safe initializer. Update when current element beats best. For max of negatives, do not start at 0 unless 0 is in domain." } ], "traps": [ "break only leaves inner loop in nested structure.", "Max initialized to 0 fails for all-negative data.", "Off-by-one when using range(len) vs direct iteration.", "Variable reused name in inner loop shadows outer." ], "retrieval": [ "How many times runs inner if outer is 3 and inner is 4?", "Why initialize max carefully for negative inputs?", "What does break do inside nested loops?" ], "deepStudy": "# Programming in Python · Week 5 — Nested iterations\n\nDeep study for Quiz 2 week 5. Nested loops multiply work: outer drives rows, inner completes fully each time.\n\n## Week map\n\nOuter loop → inner loop completes per outer step → iteration count product → search flag → running min/max → break scope.\n\n## Nested loop notation\n\n- **Outer index** → often row or first coordinate → runs its full range once per “round.”\n- **Inner index** → completes entire range for each outer value → total body runs = outer count × inner count.\n- `break` → exits **innermost** loop only → outer continues unless restructured.\n\nMini-example:\n\n```python\ncount = 0\nfor i in range(3):\n for j in range(2):\n count += 1\n# count = 6 (3 × 2)\n```\n\n### Search pattern\n\n```python\nfound = False\nfor item in seq:\n if item == target:\n found = True\n break\n```\n\nSet flag, break on match. `for`/`else`: `else` runs only if loop did not break.\n\n### Min/max pattern\n\n```python\nbest = seq[0]\nfor x in seq[1:]:\n if x > best:\n best = x\n```\n\nInitialize from first element — not 0 when data may be all negative.\n\n## Pattern families\n\n### Easy — Nested count\n\nMultiply outer and inner trip counts. Trace one outer step showing full inner run. List final values of loop variables.\n\n### Medium — Search and index\n\nLinear search with flag or break. Track index with `enumerate` or manual counter. Report first match vs all matches.\n\n### Hard — Min/max with updates\n\nSafe initializer for negatives. Nested search: find max in each row, or best pair sum. `break` only leaves inner loop — trace carefully.\n\n## Worked mini-examples\n\n**Example 1 — Grid pairs.**\n\n```python\npairs = []\nfor i in range(2):\n for j in range(3):\n pairs.append((i, j))\n# 6 pairs: (0,0)..(1,2)\n```\n\n**Example 2 — Search.**\n\n```python\nnums = [4, 7, 2, 9]\ntarget = 7\nfound = False\nfor n in nums:\n if n == target:\n found = True\n break\n# found is True\n```\n\n**Example 3 — Max.**\n\n```python\ndata = [-3, -8, -1, -5]\nm = data[0]\nfor x in data:\n if x > m:\n m = x\n# m = -1\n```\n\n**Example 4 — break scope.**\n\n```python\nfor i in range(3):\n for j in range(3):\n if j == 1:\n break\n # inner breaks at j=1; outer continues\n# outer runs 3 times; inner runs 2 times each → 6 inner bodies\n```\n\n## Traps\n\n- `break` only leaves inner loop in nested structure.\n- Max initialized to 0 fails for all-negative data.\n- Off-by-one: `range(len)` vs direct iteration.\n- Inner variable shadows outer (`for i` inside `for i`).\n- Counting iterations as `n + m` instead of `n × m`.\n\n## Diagnostic (try yourself)\n\n1. How many times does the body run?\n\n```python\nfor a in range(4):\n for b in range(3):\n pass\n```\n\n2. After nested loops below, what is `j`?\n\n```python\nfor i in range(2):\n for j in range(5):\n pass\n```\n\n3. Write a loop that sets `found = True` and breaks when `target` appears in list `items`.\n\n4. Find max of `[-10, -3, -7]` — why should `best` not start at 0?\n\n5. In a 3×3 nested loop with `break` when `j == 0` in the inner loop, how many inner bodies execute per outer step?", "compressed": "outer×inner loops → O(n²) scans → search flag → min/max over grid.", "chain": [ { "label": "Nested for", "expression": "for i in ...: for j in ...:", "when": "pairs / grid traversal" }, { "label": "Iteration count", "expression": "outer × inner body runs", "when": "complexity estimate" }, { "label": "Search flag", "expression": "found = False; break inner", "when": "stop early on match" }, { "label": "Min/max scan", "expression": "if x < best: best = x", "when": "linear search" }, { "label": "Indentation", "expression": "body belongs to nearest for/while", "when": "trace nested blocks" } ], "chattyReferenceId": "python-week5-reference", "recognition": "Ask: How many times runs inner if outer is 3 and inner is 4?", "procedure": "Multiply outer and inner trip counts. Trace one outer step showing full inner run. Useful for tables and coordinate pairs.", "variations": "Watch for: break only leaves inner loop in nested structure." } }, { "week": 6, "title": "Basic collections", "focus": "lists, tuples, mutability, slicing", "noteId": "may-2026-python-week-6-collections-lists", "skipIfExists": false, "content": { "map": "Sequence types → indexing → slice → mutate list not tuple", "concepts": "- **List** []: ordered, mutable; **tuple** (): ordered, immutable.\n- **Indexing:** 0-based; negative indices from end; seq[i] one element.\n- **Slicing:** seq[start:end:step] copies subsequence; end exclusive.\n- **Methods:** append, pop; + concatenates sequences.", "notation": "| Operation | List | Tuple |\n| --- | --- | --- |\n| Mutate | yes | no |\n| `a[i]` | read/write | read only |\n| Slice | new list | new tuple |", "patterns": [ { "level": "Easy", "name": "Index and slice", "body": "Last element is index -1. Slice [1:4] takes indices 1,2,3. Step 2 skips every other. Empty slice when start >= end with positive step." }, { "level": "Medium", "name": "Mutate vs share", "body": "Assignment copies reference for lists—two names can point to same list. Slicing often creates new sequence. Tuple assignment unpacks length must match." }, { "level": "Hard", "name": "List algorithms trace", "body": "append grows end; pop removes indexed item. Track length inside loop. Slicing mid-loop uses updated list state." } ], "traps": [ "IndexError on len(seq) or -len-1.", "Confusing slice copy with alias mutation.", "Using tuple where list needed for append.", "Step 0 in slice is invalid." ], "retrieval": [ "What does `seq[-2]` return?", "Can you append to a tuple?", "Difference between `a = b` for lists vs `a = b[:]`?" ], "deepStudy": "# Programming in Python · Week 6 — Lists and tuples\n\nDeep study for Quiz 2 week 6. Lists are mutable sequences; tuples are immutable — choose based on whether data should change.\n\n## Week map\n\nList creation → indexing/slicing → mutation methods → traversal → tuple immutability → list vs tuple choice.\n\n## List notation\n\n- `lst = [1, 2, 3]` → ordered mutable sequence → elements accessible by index.\n- `lst[i]` → element at index `i` → 0-based → `lst[0]` is first.\n- `lst[-1]` → last element → negative index counts from end.\n- `lst[a:b]` → slice from `a` inclusive to `b` exclusive → `lst[1:3]` gives two elements.\n- `len(lst)` → number of elements.\n\nMini-example:\n\n```python\ncolors = [\"red\", \"green\", \"blue\"]\ncolors[1] = \"yellow\" # mutable\ncolors.append(\"black\") # [red, yellow, blue, black]\n```\n\n### Common list methods\n\n- `.append(x)` → add one item at end.\n- `.insert(i, x)` → insert at index `i`, shift right.\n- `.pop()` → remove and return last; `.pop(i)` at index.\n- `.remove(x)` → remove first occurrence of value `x`.\n- `lst + other` → concatenate → new list.\n- `lst * n` → repeat list `n` times.\n\n**Trap:** `append` adds one element; `extend` adds each element of iterable.\n\n## Tuple notation\n\n- `t = (1, 2, 3)` → ordered immutable sequence → cannot reassign elements.\n- `t = (42,)` → single-element tuple needs trailing comma.\n- `()` → empty tuple.\n- Tuples useful for fixed records: `(name, score)`, coordinates `(x, y)`.\n\nMini-example:\n\n```python\npoint = (3, 4)\nx, y = point # unpacking\n# point[0] = 5 # TypeError — immutable\n```\n\n### List vs tuple\n\n| Feature | List | Tuple |\n| --- | --- | --- |\n| Mutability | Yes | No |\n| Syntax | `[ ]` | `( )` |\n| Use case | Growing/changing data | Fixed bundles |\n\n## Pattern families\n\n### Easy — Index and slice\n\nAccess first, last, middle. Slice subsequence. Predict result of `lst[::2]` (every second element).\n\n### Medium — Mutate and traverse\n\nAppend, insert, pop in trace problems. Loop with `for x in lst` or index `for i in range(len(lst))`. Build new list by comprehension or loop.\n\n### Hard — Nested lists and aliasing\n\nList of lists — inner lists are references. `a = b` aliases same list; `a = b[:]` shallow copy. Modify inner list through one alias affects other.\n\n## Worked mini-examples\n\n**Example 1 — Slice.**\n\n```python\nnums = [10, 20, 30, 40, 50]\nnums[1:4] # [20, 30, 40]\nnums[-2:] # [40, 50]\n```\n\n**Example 2 — append vs insert.**\n\n```python\na = [1, 2]\na.append([3]) # [1, 2, [3]]\nb = [1, 2]\nb.insert(1, 99) # [1, 99, 2]\n```\n\n**Example 3 — Traverse and transform.**\n\n```python\nvals = [1, 2, 3]\ndoubled = []\nfor v in vals:\n doubled.append(v * 2)\n# [2, 4, 6]\n```\n\n**Example 4 — Tuple unpack.**\n\n```python\npair = (\"Alice\", 92)\nname, score = pair\n```\n\n**Example 5 — Aliasing trap.**\n\n```python\nrow = [0, 0]\ngrid = [row, row]\ngrid[0][0] = 1\n# grid is [[1, 0], [1, 0]] — both rows share row\n```\n\n## Traps\n\n- `t = (5)` is int 5, not tuple — need `(5,)`.\n- `append([x])` nests list; `extend([x])` adds element.\n- Slice copy is shallow — inner mutable objects still shared.\n- Modifying list while iterating forward can skip elements.\n- `lst.sort()` sorts in place; `sorted(lst)` returns new list.\n\n## Diagnostic (try yourself)\n\n1. What is `[\"a\", \"b\", \"c\"][1]`? What is `[-1]`?\n\n2. After `x = [1, 2]; x.append(3); x.insert(0, 0)`, what is `x`?\n\n3. Can you change `t[0]` if `t = (10, 20)`? Why or why not?\n\n4. What does `a = [1, 2] + [3]` produce? How is it different from `a.append(3)` starting from `[1, 2]`?\n\n5. `row = [0, 0]; m = [row, row]; m[1][1] = 9`. What is `m[0]`?", "compressed": "list mutable vs tuple immutable → indexing/slicing → append vs +.", "chain": [ { "label": "List literal", "expression": "[a, b, c]", "when": "ordered, mutable sequence" }, { "label": "Tuple literal", "expression": "(a, b, c)", "when": "ordered, immutable" }, { "label": "Index / slice", "expression": "L[i], L[a:b:c]", "when": "0-based, stop exclusive" }, { "label": "append", "expression": "L.append(x)", "when": "mutate in place" }, { "label": "Concatenate", "expression": "L + M → new list", "when": "does not mutate L" } ], "chattyReferenceId": "python-week6-reference", "recognition": "Ask: What does `seq[-2]` return?", "procedure": "Last element is index -1. Slice [1:4] takes indices 1,2,3. Step 2 skips every other. Empty slice when start >= end with positive step.", "variations": "Watch for: IndexError on len(seq) or -len-1." } }, { "week": 7, "title": "Collections continued", "focus": "dictionaries, frequency counting, grouping", "noteId": "may-2026-python-week-7-collections-dicts", "skipIfExists": false, "content": { "map": "Key-value map → lookup → count frequencies → iterate keys/values", "concepts": "- **Dict** maps hashable keys to values; literal {k: v} or dict().\n- **Lookup:** d[k] raises KeyError if missing; d.get(k, default) safe.\n- **Frequency:** loop items, counts[x] = counts.get(x, 0) + 1.\n- **Iteration:** d.keys(), d.values(), d.items() for pairs.", "notation": "| Access | Behavior |\n| --- | --- |\n| `d[k]` | value or KeyError |\n| `d.get(k,0)` | default if missing |\n| `k in d` | membership test |", "patterns": [ { "level": "Easy", "name": "Build small dict", "body": "Insert key-value pairs. Overwriting key updates value. Keys must be immutable (str, int, tuple of immutables)." }, { "level": "Medium", "name": "Frequency table", "body": "Initialize empty dict. For each item in data, increment count with get pattern. Result maps value → count." }, { "level": "Hard", "name": "Group or invert", "body": "Group by key: dict of lists. Invert when values unique: swap keys and values carefully—collisions mean inversion is not a dict." } ], "traps": [ "KeyError when key never inserted—use get or in.", "Lists as dict keys (unhashable).", "Iterating dict gives keys only by default in older mental models—use items for pairs.", "Assuming sorted order of keys without sorting." ], "retrieval": [ "How do you count occurrences with a dict?", "Difference between `d[k]` and `d.get(k)`?", "Why can’t a list be a dict key?" ], "deepStudy": "# Programming in Python · Week 7 — Dictionaries and frequency\n\nDeep study for Quiz 2 week 7. Dictionaries map keys to values — ideal for counting, lookup tables, and grouping.\n\n## Week map\n\nDict creation → key access → add/update → traversal → frequency counting → `get` and defaults.\n\n## Dictionary notation\n\n- `d = {\"a\": 1, \"b\": 2}` → mapping from keys to values → keys must be hashable (immutable types).\n- `d[key]` → lookup value → raises `KeyError` if key missing.\n- `d[key] = value` → insert or overwrite.\n- `key in d` → membership test → `True` if key exists.\n- `len(d)` → number of key-value pairs.\n\nMini-example:\n\n```python\nscores = {\"Ana\": 88, \"Ben\": 92}\nscores[\"Ana\"] # 88\nscores[\"Cal\"] = 75 # add new pair\n```\n\n### Safe access\n\n- `d.get(key)` → returns `None` if missing (or default: `d.get(key, 0)`).\n- `d.get(key, 0)` → frequency pattern starter — return 0 when key unseen.\n\nMini-example:\n\n```python\ncounts = {}\nword = \"aba\"\nfor ch in word:\n counts[ch] = counts.get(ch, 0) + 1\n# counts = {'a': 2, 'b': 1}\n```\n\n## Frequency counting pattern\n\n```python\nfreq = {}\nfor item in data:\n freq[item] = freq.get(item, 0) + 1\n```\n\nAlternative with `defaultdict` (if allowed) or `if item in freq` branch.\n\n### Traversal\n\n```python\nfor key in d:\n print(key, d[key])\n\nfor key, val in d.items():\n print(key, val)\n```\n\n`.keys()`, `.values()`, `.items()` return views of dict contents.\n\n## Pattern families\n\n### Easy — Lookup and update\n\nRead value by key. Add new key. Check membership with `in`. Predict `KeyError` vs `get`.\n\n### Medium — Frequency count\n\nCount occurrences in list or string. Find most common. Report keys with count above threshold.\n\n### Hard — Nested dict and grouping\n\nDict of dicts: `d[user][month] = score`. Group records by category. Merge counts from two sources.\n\n## Worked mini-examples\n\n**Example 1 — Basic build.**\n\n```python\ncapitals = {}\ncapitals[\"India\"] = \"New Delhi\"\ncapitals[\"France\"] = \"Paris\"\n```\n\n**Example 2 — Frequency.**\n\n```python\nvotes = [\"yes\", \"no\", \"yes\", \"yes\", \"no\"]\ntally = {}\nfor v in votes:\n tally[v] = tally.get(v, 0) + 1\n# {'yes': 3, 'no': 2}\n```\n\n**Example 3 — Max frequency key.**\n\n```python\nfreq = {\"a\": 3, \"b\": 7, \"c\": 2}\nbest_key = None\nbest_val = -1\nfor k, v in freq.items():\n if v > best_val:\n best_val = v\n best_key = k\n# best_key = 'b'\n```\n\n**Example 4 — Overwrite.**\n\n```python\nd = {\"x\": 1}\nd[\"x\"] = 10 # overwrite, not duplicate key\n# len(d) still 1\n```\n\n**Example 5 — Invalid key.**\n\n```python\n# d[[1, 2]] = 5 # TypeError — list not hashable\nd[(1, 2)] = 5 # OK — tuple is hashable\n```\n\n## Traps\n\n- Using `d[key]` when key may be absent — use `get` or check `in` first.\n- Lists as keys — not allowed.\n- Assuming dict preserves insertion order in very old Python mental models (3.7+ preserves order, but logic should not depend on order unless stated).\n- `freq[key] += 1` on missing key raises error — initialize first.\n- Confusing `.keys()` with values when iterating.\n\n## Diagnostic (try yourself)\n\n1. What does `{\"x\": 1, \"y\": 2}[\"y\"]` return? What happens for `[\"z\"]`?\n\n2. Count letters in `\"hello\"` using `get(key, 0) + 1` pattern. What is count of `'l'`?\n\n3. Write one line to check if `\"admin\"` is a key in dict `users`.\n\n4. After `d = {}; d[\"a\"] = 1; d[\"a\"] = 2`, what is `d` and `len(d)`?\n\n5. Why does `counts[word] = counts[word] + 1` fail on first sighting of `word` in an empty dict?", "compressed": "dict key→value → in keys → frequency via d[k]=d.get(k,0)+1.", "chain": [ { "label": "Dict literal", "expression": "{k: v, ...}", "when": "map keys to values" }, { "label": "Lookup", "expression": "d[key]", "when": "KeyError if missing" }, { "label": "get", "expression": "d.get(key, default)", "when": "safe lookup" }, { "label": "Frequency", "expression": "d[x] = d.get(x,0) + 1", "when": "count occurrences" }, { "label": "Iteration", "expression": "for k in d: / d.items()", "when": "keys vs key-value pairs" } ], "chattyReferenceId": "python-week7-reference", "recognition": "Ask: How do you count occurrences with a dict?", "procedure": "Insert key-value pairs. Overwriting key updates value. Keys must be immutable (str, int, tuple of immutables).", "variations": "Watch for: KeyError when key never inserted—use get or in." } }, { "week": 8, "title": "Collections & integration", "focus": "nested collections, mixed iteration patterns", "noteId": "may-2026-python-week-8-collections-mixed", "skipIfExists": false, "content": { "map": "Nested structures → layered loops → aggregate → choose right collection", "concepts": "- **Nested list:** matrix as list of rows; M[i][j] row then column.\n- **Dict of lists / list of dicts:** common record shapes.\n- **Mixed iteration:** outer over keys, inner over values or indices.\n- **Choose structure:** fast lookup → dict; ordered sequence → list; fixed record → tuple.", "notation": "| Structure | Example access |\n| --- | --- |\n| nested list | `grid[r][c]` |\n| dict of lists | `groups[k].append(x)` |\n| list of dicts | `records[i][\"name\"]` |", "patterns": [ { "level": "Easy", "name": "Access nested element", "body": "Identify outer index (row/key) then inner (col/subkey). Trace type at each level—dict vs list." }, { "level": "Medium", "name": "Double loop aggregate", "body": "Sum all cells: outer rows, inner columns. Or count per category using dict of counts inside loop over records." }, { "level": "Hard", "name": "Integrate prior patterns", "body": "Combine search, min/max, and frequency on nested data. State invariant: what each loop variable represents. Prefer clear names over i,j when semantic." } ], "traps": [ "Index order swapped in matrix access.", "Mutating shared inner list across dict keys unintentionally.", "Deep copy vs shallow when resetting rows.", "Wrong loop variable used in inner body." ], "retrieval": [ "How do you reach column j of row i in a matrix list?", "When use dict of lists vs list of dicts?", "What goes wrong if inner lists are aliased?" ], "deepStudy": "# Programming in Python · Week 8 — Mixed collections\n\nDeep study for Quiz 2 week 8. Real programs combine lists, tuples, dicts, and strings — know which structure fits each sub-problem.\n\n## Week map\n\nChoose structure → list of dicts → dict of lists → nested access → aggregate patterns → common mixed traces.\n\n## Mixed structure notation\n\n- **List of dicts** → table rows → `[{\"name\": \"A\", \"score\": 90}, ...]`.\n- **Dict of lists** → columns keyed by field → `{\"names\": [...], \"scores\": [...]}`.\n- **Dict of dicts** → nested lookup → `data[user][metric]`.\n- **Tuple in dict** → immutable key bundle → `{(x, y): value}` for grid cells.\n\nMini-example:\n\n```python\nstudents = [\n {\"id\": 1, \"grade\": 85},\n {\"id\": 2, \"grade\": 91},\n]\nstudents[1][\"grade\"] # 91\n```\n\n### Access chain\n\nRead inside-out: `container[index_or_key][next_key]...`\n\n```python\nmatrix = [[1, 2], [3, 4]]\nmatrix[1][0] # 3\n\nregistry = {\"team\": {\"lead\": \"Sam\", \"size\": 5}}\nregistry[\"team\"][\"lead\"] # 'Sam'\n```\n\n## Common mixed patterns\n\n### Filter and collect\n\n```python\nresults = []\nfor row in table:\n if row[\"score\"] >= 60:\n results.append(row[\"name\"])\n```\n\n### Group by key\n\n```python\ngroups = {}\nfor item in items:\n k = item[\"category\"]\n if k not in groups:\n groups[k] = []\n groups[k].append(item)\n```\n\n### Sort list of dicts (concept)\n\nSort by field: `sorted(rows, key=lambda r: r[\"score\"])`. Know that `key` picks comparison field.\n\n## Pattern families\n\n### Easy — Nested access\n\nOne or two-level lookup. Predict type after access: list element, dict value, character in string.\n\n### Medium — Build mixed structure\n\nConstruct list of dicts from parallel lists. Update nested value. Count items matching condition across records.\n\n### Hard — Aggregate over mixed data\n\nAverage scores per category. Find record with max field. Merge two list-of-dict sources by shared key.\n\n## Worked mini-examples\n\n**Example 1 — List of dicts.**\n\n```python\nbooks = [{\"title\": \"A\", \"pages\": 200}, {\"title\": \"B\", \"pages\": 150}]\ntotal = 0\nfor b in books:\n total += b[\"pages\"]\n# total = 350\n```\n\n**Example 2 — Dict of lists.**\n\n```python\ndata = {\"x\": [1, 2], \"y\": [3, 4]}\ndata[\"x\"].append(5) # {\"x\": [1, 2, 5], \"y\": [3, 4]}\n```\n\n**Example 3 — Filter names.**\n\n```python\nrows = [{\"n\": \"a\", \"ok\": True}, {\"n\": \"b\", \"ok\": False}]\npassed = [r[\"n\"] for r in rows if r[\"ok\"]]\n# ['a']\n```\n\n**Example 4 — Tuple key.**\n\n```python\ngrid = {}\ngrid[(0, 0)] = \"start\"\ngrid[(1, 0)] = \"path\"\ngrid[(0, 0)] # 'start'\n```\n\n**Example 5 — Type discipline.**\n\n```python\nrecord = {\"tags\": [\"py\", \"stats\"]}\nrecord[\"tags\"].append(\"ml\") # list inside dict — mutable\nrecord[\"tags\"][0] # 'py'\n```\n\n## Traps\n\n- Wrong bracket type: `d[\"key\"]` vs `lst[0]`.\n- Shallow copy of list-of-lists shares inner lists.\n- Iterating dict gives keys, not values — use `.values()` or `.items()`.\n- Assuming all rows have same keys — missing key raises `KeyError`.\n- Modifying list while iterating — use new list or iterate copy.\n\n## Diagnostic (try yourself)\n\n1. Given `d = {\"a\": [1, 2], \"b\": [3]}`, what is `d[\"a\"][1]`?\n\n2. Build a list of dicts with keys `\"name\"` and `\"age\"` from `names = [\"Kim\", \"Lee\"]` and `ages = [20, 22]`.\n\n3. From `records = [{\"v\": 3}, {\"v\": 7}, {\"v\": 5}]`, how would you find the dict with largest `\"v\"`?\n\n4. What is `data[0][\"x\"]` if `data = [{\"x\": 10}, {\"x\": 20}]`?\n\n5. Why might `groups[key].append(item)` require checking `if key not in groups` first?", "compressed": "list of dicts → nested loops over collections → mixed indexing.", "chain": [ { "label": "List of dicts", "expression": "[{...}, {...}]", "when": "records / rows" }, { "label": "Nested access", "expression": "rows[i][\"key\"]", "when": "index then key" }, { "label": "Enumerate", "expression": "for i, x in enumerate(L):", "when": "need index + value" }, { "label": "Zip", "expression": "zip(a, b)", "when": "parallel iteration" }, { "label": "Copy trap", "expression": "shallow copy shares inner refs", "when": "mutating nested structures" } ], "chattyReferenceId": "python-week8-reference", "recognition": "Ask: How do you reach column j of row i in a matrix list?", "procedure": "Identify outer index (row/key) then inner (col/subkey). Trace type at each level—dict vs list.", "variations": "Watch for: Index order swapped in matrix access." } } ] }, { "courseId": "computationalthinking", "folder": "CT", "label": "Computational Thinking", "prepGuideId": "may-2026-ct-quiz-2-weeks-1-8-prep", "weeks": [ { "week": 1, "title": "Variables & representation", "focus": "state, iterators, datatypes, flowcharts", "noteId": "may-2026-ct-week-1-variables", "skipIfExists": false, "content": { "map": "Problem → variables → datatype → flowchart boxes → trace state", "concepts": "- **Variable** names a value that can change; **iterator** often counts or walks a collection.\n- **Datatypes:** number, string, boolean, list—operations depend on type.\n- **Flowchart:** start/end ovals, process boxes, decision diamonds, arrows show order.\n- **State snapshot:** all variable values at one step.", "notation": "| Flowchart | Meaning |\n| --- | --- |\n| Rectangle | process / assign |\n| Diamond | decision |\n| Parallelogram | input/output |", "patterns": [ { "level": "Easy", "name": "Read flowchart step", "body": "Follow arrows from Start. At diamond, one branch taken. Update variables in rectangles before next decision." }, { "level": "Medium", "name": "Choose representation", "body": "Pick variable names for quantities in word problem. Decide int vs float vs list based on whether fractional, textual, or collective data." }, { "level": "Hard", "name": "State table trace", "body": "Columns for each variable; rows for each step. Decision rows branch—duplicate state only along taken path." } ], "traps": [ "Skipping decision branch label (Y/N).", "Same variable name for different concepts.", "Flowchart arrow bypassing a required update.", "Confusing iterator index with value stored." ], "retrieval": [ "What does a diamond represent in a flowchart?", "What is a state snapshot?", "When represent data as list vs single variable?" ], "deepStudy": "# Computational Thinking · Week 1 — Variables and state\n\nCT week 1 builds **representations**: naming quantities, picking datatypes, and tracing state through flowcharts or pseudocode.\n\n## Week map\n\nProblem → variables as named state → datatypes → iterators → flowchart symbols → state snapshots → input/output boxes.\n\n## Representation notation\n\n- **Variable** → name bound to a value that may change → `count`, `total`, `name`.\n- **State** → all current variable values at one instant → snapshot table one row per step.\n- **Iterator** → variable stepping through a sequence or count → `i` from 0 to n-1.\n- **Datatype** → kind of value → determines legal operations → number vs string vs list.\n\n### Flowchart symbols\n\n| Shape | Role | Example action |\n| --- | --- | --- |\n| Oval | start / end | Start, Stop |\n| Rectangle | process | `total ← total + price` |\n| Diamond | decision | `score ≥ 50?` |\n| Parallelogram | input / output | `Read age`, `Print sum` |\n\nArrow direction defines order. At a diamond, follow **one** branch label (Y/N or T/F).\n\n## Choosing a representation\n\nAsk three questions:\n\n1. **Single vs collection?** One score → number; list of scores → list.\n2. **Fraction allowed?** Integer count vs float average.\n3. **Text vs number?** ID as string even if digits; phone codes not for arithmetic.\n\nMini-example: Track 5 quiz scores → list `scores` length 5, not five unrelated names unless table fixed.\n\n## State snapshot tracing\n\nProblem: start `x=3`, `y=1`. Process: `y ← x + y`, then `x ← y - 2`.\n\n| step | x | y |\n| --- | --- | --- |\n| init | 3 | 1 |\n| after 1st | 3 | 4 |\n| after 2nd | 2 | 4 |\n\nRead as: assignment uses **current** values when evaluating right-hand side.\n\n## Pattern families\n\n### Easy — Read flowchart step\n\n- Follow arrows; update rectangles; branch at diamond once.\n- Identify start/end and missing arrow bugs in diagrams.\n- Match parallelogram to Read/Print in trace.\n\n### Medium — Choose datatype and names\n\n- From word problem, list variables and types.\n- Distinguish index (position) vs value at index.\n- Flowchart with two variables swapping — track both columns.\n\n### Hard — Full state table\n\n- Multi-step with decision: duplicate row only along taken branch.\n- Iterator introduced mid-flow: when does `i` increment?\n- Detect unreachable rectangle (no arrow in).\n\n## Worked mini-examples\n\n**Example 1 — Simple trace.**\n\nStart `a=10`, `b=2`. `a ← a - b` → `a=8`. `b ← a + b` → `b=10`.\n\n**Example 2 — Decision.**\n\n`n=7`. Diamond: `n > 5?` Yes → `msg ← \"big\"`. Else branch skipped. `msg` is `\"big\"`.\n\n**Example 3 — Iterator intro.**\n\n`i=0`, `sum=0`. Loop body: `sum ← sum + i`, `i ← i + 1`, repeat while `i < 4`.\n\n| i | sum after step |\n| --- | --- |\n| 0 | 0 |\n| 1 | 0 |\n| 2 | 1 |\n| 3 | 3 |\n| 4 | 6 |\n\nLoop stops when `i` becomes 4.\n\n**Example 4 — Wrong type choice.**\n\nStoring `price = \"12.50\"` then `total = price + 5` concatenates strings in Python-like semantics — representation error if numeric total intended.\n\n## Traps\n\n- Skipping decision branch label — both paths mentally.\n- Same name for two concepts (`total` for both count and sum).\n- Using value before rectangle that assigns it.\n- Iterator confused with stored data value (`i` vs `item[i]`).\n- Flowchart arrow bypassing update rectangle.\n\n## Diagnostic (try yourself)\n\n1. Start `p=5`, `q=3`. Execute `p ← p + q` then `q ← p - q`. What are final `p` and `q`?\n\n2. A flowchart diamond asks `x < 0`. If `x = 0`, which branch (Y/N) is taken for “less than zero”?\n\n3. You need to store a student’s 8 weekly quiz percentages. One variable or a collection? Which datatype class?\n\n4. Trace `c=1`, `d=4`, then `c ← d`, `d ← c`. What are `c` and `d`? (Watch order.)\n\n5. In a state table, why duplicate rows only on the taken branch after a decision?", "compressed": "state variables → datatype → assignment updates → flowchart ↔ trace.", "chain": [ { "label": "State", "expression": "named variables hold values", "when": "trace step by step" }, { "label": "Assignment", "expression": "x ← expression", "when": "RHS evaluated first" }, { "label": "Iterator", "expression": "loop counter / index", "when": "repeated steps" }, { "label": "Datatype", "expression": "int, float, str, bool", "when": "legal operations" }, { "label": "Flowchart", "expression": "boxes + arrows", "when": "algorithm before code" } ], "chattyReferenceId": "computationalthinking-week1-reference", "recognition": "Ask: What does a diamond represent in a flowchart?", "procedure": "Follow arrows from Start. At diamond, one branch taken. Update variables in rectangles before next decision.", "variations": "Watch for: Skipping decision branch label (Y/N)." } }, { "week": 2, "title": "Iteration & selection", "focus": "accumulation, max/min, AND predicates", "noteId": "may-2026-ct-week-2-iteration-selection", "skipIfExists": false, "content": { "map": "Loop over collection → accumulate → compare for max → filter with AND", "concepts": "- **Accumulation:** start neutral (0 for sum, 1 for product) then combine each item.\n- **Max/min scan:** keep best-so-far; compare each element.\n- **Selection with AND:** all conditions must pass—think checklist.\n- **Loop guard:** ensure collection non-empty before picking first as max.", "notation": "| Goal | Start value |\n| --- | --- |\n| sum | 0 |\n| product | 1 |\n| max | first item or sentinel |", "patterns": [ { "level": "Easy", "name": "Sum list", "body": "Initialize total 0. For each x, add to total. Result after last item." }, { "level": "Medium", "name": "Max with AND filter", "body": "Only consider items where predicate true (e.g. positive AND even). Update max among eligible only." }, { "level": "Hard", "name": "Count satisfying all", "body": "Nested logic: loop with compound condition incrementing counter when all tests pass. Empty input yields 0 count, not error." } ], "traps": [ "Max of empty without check.", "OR used when problem says all conditions.", "Accumulator wrong neutral element.", "Off-by-one in manual index loop." ], "retrieval": [ "Initial value for product accumulation?", "How does AND filter differ from OR?", "What if max is sought on empty data?" ], "deepStudy": "# Computational Thinking · Week 2 — Iteration and selection\n\nLoop patterns combine **walking data** with **filters** (AND predicates) and **aggregates** (sum, max, count).\n\n## Week map\n\nLoop over collection → neutral start value → accumulate → scan for max/min → filter with AND → empty input edge cases.\n\n## Accumulation notation\n\n- **Sum accumulator** → start 0 → `total ← total + x`.\n- **Product accumulator** → start 1 → `prod ← prod * x`.\n- **Count accumulator** → start 0 → increment when condition holds.\n- **Max scan** → start first item or sentinel → replace when `x > best`.\n\n### AND filter\n\nAll conditions must pass:\n\n“positive **and** even” → `x > 0` **and** `x % 2 == 0`.\n\nContrast OR (week 3 procedures): “positive **or** even” passes more items.\n\nMini-list: `[3, -4, 6, 8, -2]`. Positive and even → only `6, 8`.\n\n## Max and min scans\n\n```text\nbest ← first item\nfor each x in data:\n if x > best:\n best ← x\n```\n\nEmpty `data`: no first item — algorithm must guard or define error.\n\nMini-example: `[5, 2, 9, 9, 1]`. Max scan ends `9`. For **positive** max only: ignore nonpositive, start `best` at first positive or None.\n\n## Pattern families\n\n### Easy — Sum or count list\n\n- Sum all elements.\n- Count how many equal a target.\n- Product of list (start 1).\n\n### Medium — Max with AND filter\n\n- Largest among entries meeting two tests.\n- Count items where both predicates true.\n- Sum only negatives in list.\n\n### Hard — Compound loop logic\n\n- Multiple accumulators in one pass (sum and count together).\n- Empty list: max undefined; count returns 0.\n- Index loop vs for-each — same totals if bounds correct.\n\n## Worked mini-examples\n\n**Example 1 — Sum.**\n\nData `[10, 20, 5]`. `total=0` → 10 → 30 → 35.\n\n**Example 2 — AND count.**\n\nData `[2, 3, 4, 5, 6]`. Count even and >3:\n\n- 4 yes, 6 yes → count 2.\n\n**Example 3 — Filtered max.**\n\nData `[-1, 8, 3, 12, 5]`. Max among positive:\n\nCandidates 8,3,12,5 → max 12.\n\n**Example 4 — Empty.**\n\nData `[]`. Sum loop leaves `total=0`. Max scan without guard — undefined; safe design returns sentinel or “no data”.\n\n**Example 5 — Dual accumulator.**\n\nData `[1,2,3,4]`. Track `sum` and `count` of evens in one pass:\n\nEvens 2,4 → sum 6, count 2.\n\n## Traps\n\n- Product accumulator starting at 0 (always 0).\n- OR filter when problem says “all conditions”.\n- Max of empty without check.\n- Off-by-one manual index: `0..len-1` not `0..len`.\n- Updating max before checking filter — polluted by ineligible items.\n\n## Diagnostic (try yourself)\n\n1. List `[7, -2, 4, 0, 11]`. What is the sum of positive entries only?\n\n2. Same list: how many entries are **both** positive **and** less than 10?\n\n3. List `[3, 9, 1, 9, 2]`. What is the maximum value? If we only consider values ≥ 5, what is the max?\n\n4. Why does product accumulation start at 1, not 0?\n\n5. One pass: for `[5, 10, 15, 20]`, find `sum` and `count` of multiples of 5.", "compressed": "accumulator → max/min scan → AND predicate over loop → selection diamond.", "chain": [ { "label": "Accumulator", "expression": "sum ← sum + x", "when": "running total" }, { "label": "Max/min", "expression": "if x > best: best ← x", "when": "linear extremum" }, { "label": "AND over items", "expression": "all satisfy P(x)", "when": "flag stays true" }, { "label": "Selection", "expression": "if condition → branch", "when": "at most one path" }, { "label": "Counter", "expression": "count ← count + 1", "when": "how many match" } ], "chattyReferenceId": "computationalthinking-week2-reference", "recognition": "Ask: Initial value for product accumulation?", "procedure": "Initialize total 0. For each x, add to total. Result after last item.", "variations": "Watch for: Max of empty without check." } }, { "week": 3, "title": "Procedures & parameters", "focus": "procedures, side effects, OR logic", "noteId": "may-2026-ct-week-3-procedures", "skipIfExists": false, "content": { "map": "Decompose → procedure with parameters → return vs side effect → OR selection", "concepts": "- **Procedure:** named reusable block; **parameters** receive inputs per call.\n- **Return value** replaces call expression; **side effect** changes external state (print, mutate list).\n- **OR selection:** pass if any condition true—different from AND filter.\n- **Call stack:** caller waits; callee runs; returns to caller line.", "notation": "| Concept | Note |\n| --- | --- |\n| Parameter | input slot in definition |\n| Argument | value passed at call |\n| Side effect | change outside local vars |", "patterns": [ { "level": "Easy", "name": "Trace a call", "body": "Substitute arguments into parameter names in body. Execute body. Return value to caller if expression used." }, { "level": "Medium", "name": "Return vs print", "body": "Print shows human output; return sends value to caller for further use. Quiz traces often ask final variable—know which procedure does which." }, { "level": "Hard", "name": "OR gate procedure", "body": "Combine predicates with or for eligibility. Document truth table. Procedure may return bool or category label." } ], "traps": [ "Parameter name same as global without noticing shadowing.", "Ignoring return value when assignment expected.", "Side effect mutating input list unexpectedly.", "OR when problem requires all conditions (AND)." ], "retrieval": [ "Difference between parameter and argument?", "Return vs side effect example?", "When is OR the right composite predicate?" ], "deepStudy": "# Computational Thinking · Week 3 — Procedures and parameters\n\n**Procedures** package reusable steps. Week 3 adds parameters, return vs side effect, and **OR** selection patterns.\n\n## Week map\n\nDecompose problem → procedure definition → parameters vs arguments → return to caller → side effects → OR predicates → call-stack trace.\n\n## Procedure notation\n\n- **Procedure** / function → named block with parameters → `procedure Add(a, b)`.\n- **Parameter** → placeholder in definition → `a`, `b` inside body.\n- **Argument** → actual value at call → `Add(3, 5)` passes 3 and 5.\n- **Return** → value replaces call expression → `x ← Add(2, 4)` → `x = 6`.\n- **Side effect** → changes external state or prints → return may be absent.\n\nCall flow: caller pauses → callee runs → returns to line after call.\n\nMini-trace:\n\n```text\nprocedure Square(n):\n return n * n\n\nx ← 3\ny ← Square(x) + 1\n```\n\n`y` becomes `10`.\n\n## Return vs print (side effect)\n\n| Mechanism | Caller gets | Use |\n| --- | --- | --- |\n| `return v` | value `v` | further computation |\n| `Print(v)` | nothing (display) | human output |\n\nQuiz often asks final variable — trace `return`, not display.\n\n## OR selection\n\n**OR gate:** pass if **any** condition true.\n\nEligibility: “scholarship if grade A **or** score > 90” → one true suffices.\n\nTruth mini-table for OR:\n\n| cond1 | cond2 | OR |\n| --- | --- | --- |\n| F | F | F |\n| T | F | T |\n| F | T | T |\n| T | T | T |\n\nContrast week 2 AND filter — both must hold.\n\nProcedure sketch:\n\n```text\nprocedure Eligible(grade, score):\n if grade == \"A\" or score > 90:\n return True\n else:\n return False\n```\n\n## Pattern families\n\n### Easy — Trace one call\n\n- Substitute arguments into parameters.\n- Single return to assignment.\n- Parameter shadows outer name — inner definition wins inside body.\n\n### Medium — Return vs side effect\n\n- Procedure prints but caller assigns from missing return → `None`-like bug.\n- Mutating input list as side effect — caller’s list changes.\n- Two calls in one expression: `Add(1,2) + Add(3,4)`.\n\n### Hard — OR procedure design\n\n- Truth table from word problem → procedure returning category.\n- Nested call: `Double(Square(3))`.\n- Parameter count mismatch at call — error or wrong binding.\n\n## Worked mini-examples\n\n**Example 1 — Simple return.**\n\n```text\nprocedure Max2(a, b):\n if a >= b:\n return a\n else:\n return b\n\nm ← Max2(7, 5) # m = 7\n```\n\n**Example 2 — OR gate.**\n\n```text\nprocedure Weekend(day):\n if day == \"Sat\" or day == \"Sun\":\n return True\n return False\n\nWeekend(\"Sat\") → True\nWeekend(\"Mon\") → False\n```\n\n**Example 3 — Side effect only.**\n\n```text\nprocedure Show(n):\n Print(n)\n # no return\n\nx ← Show(4) # displays 4; x not useful for math\n```\n\n**Example 4 — Nested calls.**\n\n```text\nprocedure Inc(n):\n return n + 1\n\nInc(Inc(5)) → Inc(6) → 7\n```\n\n**Example 5 — AND vs OR trap.**\n\n“Free if member **or** senior” → OR. “Free if member **and** coupon” → AND. Procedure must match wording.\n\n## Traps\n\n- Ignoring return value when assignment expected.\n- Parameter name equals global variable — trace inside procedure carefully.\n- Side effect mutating caller’s list without expecting it.\n- OR when problem requires all conditions (AND).\n- Wrong argument order if parameters positional.\n\n## Diagnostic (try yourself)\n\n1. Trace:\n\n```text\nprocedure Times3(k):\n return k * 3\n\na ← 2\nb ← Times3(a) + Times3(1)\n```\n\nWhat is `b`?\n\n2. Write OR condition in one line: `flag` True when `code == 404` **or** `code == 500`.\n\n3. Procedure prints `n*n` but does not return. Caller runs `y ← Square(5)` then `z ← y + 1`. What can go wrong?\n\n4. `procedure Pick(a, b): if a > 10 or b > 10: return a + b else: return 0`. Evaluate `Pick(3, 12)` and `Pick(8, 2)`.\n\n5. Difference between parameter and argument in one sentence each.", "compressed": "procedure call → parameters → local vs global → side effects.", "chain": [ { "label": "Procedure", "expression": "def name(params): body", "when": "reusable block" }, { "label": "Call", "expression": "name(args)", "when": "jump to body, return" }, { "label": "Parameter", "expression": "formal ↔ actual binding", "when": "per-call values" }, { "label": "Return", "expression": "output value to caller", "when": "expression result" }, { "label": "Side effect", "expression": "mutates external state", "when": "trace globals carefully" } ], "chattyReferenceId": "computationalthinking-week3-reference", "procedure": "- Parameters", "recognition": "Ask: Difference between parameter and argument?", "variations": "Watch for: Parameter name same as global without noticing shadowing." } }, { "week": 4, "title": "Nested iteration", "focus": "nested loops, binning, birthday pattern", "noteId": "may-2026-ct-week-4-nested-iteration", "skipIfExists": false, "content": { "map": "Outer index → inner index → pair generation → bin counts", "concepts": "- **Nested iteration:** all inner runs per outer step; models pairs (i,j) or grid cells.\n- **Binning:** count how many items fall in each category bucket.\n- **Birthday pattern:** compare pairs for match—inner starts after outer to avoid duplicate pairs.\n- **Complexity intuition:** nested loops often O(n²) for n items.", "notation": "| Pattern | Inner loop start |\n| --- | --- |\n| all pairs | `j = i+1` or full grid |\n| grid cell | column index 0..cols-1 |", "patterns": [ { "level": "Easy", "name": "Pair count", "body": "For i in 0..n-1, j in 0..n-1 gives n² pairs. Restrict j > i gives n(n-1)/2 unique unordered pairs." }, { "level": "Medium", "name": "Binning tallies", "body": "Initialize bin counts. For each item, determine bin index, increment that bin. Bins array size fixed by range." }, { "level": "Hard", "name": "Duplicate detection", "body": "Compare each pair once using nested loops with inner ahead of outer. Flag when equal. Avoid comparing item with itself unless i=j intended." } ], "traps": [ "Double-counting pairs when inner not restricted.", "Bin index off-by-one at boundaries.", "Infinite loop if inner never advances.", "Confusing row/column loop order in grid." ], "retrieval": [ "How many unordered pairs from n items?", "Why start inner at i+1 for unique pairs?", "What is binning used for?" ], "deepStudy": "# Computational Thinking · Week 4 — Nested iteration\n\n**Nested loops** visit pairs or grid cells. Week 4 patterns: pair counting, duplicate detection, and **binning** tallies.\n\n## Week map\n\nOuter loop → inner loop completes per outer step → index pairs (i,j) → unique unordered pairs → bin array → birthday collision pattern.\n\n## Nested loop notation\n\n- **Outer index** `i` → often row or first item position.\n- **Inner index** `j` → column or second item; may start at `i+1` for unique pairs.\n- **Iteration count** → outer `n` times inner `m` → `n × m` body executions if full grid.\n\nMini-grid `i in 0..2`, `j in 0..2` (both 0,1,2): 3×3 = 9 pairs including (0,0),(1,1),(2,2).\n\n## Unique unordered pairs\n\nFrom `n` items, compare each pair once without double-count:\n\n```text\nfor i from 0 to n-1:\n for j from i+1 to n-1:\n compare item[i] with item[j]\n```\n\nCount: $\\frac{n(n-1)}{2}$.\n\nMini-example: `n=4` → pairs (0,1),(0,2),(0,3),(1,2),(1,3),(2,3) → six pairs.\n\n**Trap:** Inner `j` from `0` to `n-1` counts (0,1) and (1,0) separately — 12 pairs for `n=4`.\n\n## Binning\n\nFixed buckets `bin[0..B-1]`. For each value `v`, compute bucket index, increment `bin[k]`.\n\nExample: scores 0–100 in bins width 10 → index `k = v // 10` (watch overflow at 100).\n\nList `[23, 45, 17, 39, 45]` with bins 0-9,10-19,…:\n\n- 23→bin2, 45→bin4, 17→bin1, 39→bin3, 45→bin4\n- bin4 count 2.\n\n## Birthday / duplicate pattern\n\nNested loops compare pairs for equality. If equal, “shared birthday” or duplicate found.\n\n```text\nfound ← False\nfor i ...\n for j from i+1 ...\n if item[i] == item[j]:\n found ← True\n```\n\nSelf-pair `i=j` usually skipped when inner starts at `i+1`.\n\n## Pattern families\n\n### Easy — Count loop executions\n\n- `range(n)` × `range(m)` body count.\n- Last values of `i` and `j` after nested `for`.\n- Grid row-major order listing of `(i,j)`.\n\n### Medium — Binning tallies\n\n- Initialize bin array size from domain.\n- Map value to index; increment correct bin.\n- Boundary: value exactly on bin edge.\n\n### Hard — Duplicate / pair logic\n\n- Unique pair enumeration without double count.\n- Count pairs with sum equal target.\n- Early exit flags vs counting all matches.\n\n## Worked mini-examples\n\n**Example 1 — Full grid count.**\n\n```text\ncount ← 0\nfor i from 1 to 3:\n for j from 1 to 2:\n count ← count + 1\n# 3 * 2 = 6\n```\n\n**Example 2 — Unique pairs.**\n\n`n=5`, inner `j = i+1 .. n-1`. Pairs: 4+3+2+1 = 10.\n\n**Example 3 — Duplicate.**\n\nList `[3,1,4,1,5]`. Compare unique pairs; (1,3) positions values 4 and 1 — no; (3,4) values 1 and 1 — match once.\n\n**Example 4 — Bins width 5.**\n\nValues `[7, 12, 3, 18, 12]`. Index `v//5`: 7→1, 12→2, 3→0, 18→3, 12→2.\n\nBins [1,1,2,1,0,...] for indices 0..3 at least.\n\n**Example 5 — Pair sum.**\n\nList `[2,5,3]`. Pairs with sum 7: (2,5) and (5,2) if full grid — 2 if ordered; 1 if unique unordered.\n\n## Traps\n\n- Double-counting pairs when inner should start at `i+1`.\n- Bin index off-by-one at boundaries (0-based vs 1-based bins).\n- Infinite inner loop if `j` never advances toward stop.\n- Row/column order swapped in grid interpretation.\n- Assuming `n²` always — restricted inner changes count.\n\n## Diagnostic (try yourself)\n\n1. How many times does the body run?\n\n```text\nfor i from 0 to 4:\n for j from 0 to 2:\n # body\n```\n\n2. For `n=6`, how many unique unordered pairs `(i,j)` with `j > i`?\n\n3. Values `[14, 6, 21, 9, 14]` binned by `index = value // 10`. List the five bin indices.\n\n4. List `[1,2,3,2]`. How many unique pairs have equal values?\n\n5. Why use `j = i+1` instead of `j = 0` when detecting duplicates once per pair?", "compressed": "nested loops → binning counts → birthday collision pattern.", "chain": [ { "label": "Nested iteration", "expression": "for each i: for each j:", "when": "pairs / grid" }, { "label": "Binning", "expression": "bucket[index] += 1", "when": "histogram / frequency" }, { "label": "Collision check", "expression": "seen before?", "when": "duplicate detection" }, { "label": "Inner break", "expression": "exit inner only", "when": "flag + break scope" }, { "label": "Complexity", "expression": "outer × inner", "when": "count body executions" } ], "chattyReferenceId": "computationalthinking-week4-reference", "recognition": "Ask: How many unordered pairs from n items?", "procedure": "For i in 0..n-1, j in 0..n-1 gives n² pairs. Restrict j > i gives n(n-1)/2 unique unordered pairs.", "variations": "Watch for: Double-counting pairs when inner not restricted." } }, { "week": 5, "title": "Lists & insertion sort", "focus": "list ops, traversal, insertion sort trace", "noteId": "may-2026-ct-week-5-lists", "skipIfExists": false, "content": { "map": "List ops → traverse → insertion sort shifts → sorted invariant", "concepts": "- **List ops:** append, insert, length, index access; 0-based indexing.\n- **Traversal:** visit each position once with for or while index.\n- **Insertion sort:** for each position, shift larger elements right, insert into sorted prefix.\n- **Invariant:** items left of index are sorted after each outer step.", "notation": "| Step | Action |\n| --- | --- |\n| outer i | next element to place |\n| inner j | shift while larger |\n| insert | write key at hole |", "patterns": [ { "level": "Easy", "name": "Traverse and transform", "body": "Build new list or update in place per spec. Keep index valid: 0 to len-1." }, { "level": "Medium", "name": "Insertion sort pass", "body": "Take element at i, walk j backward while arr[j] > key, shift arr[j+1]=arr[j], place key at j+1." }, { "level": "Hard", "name": "Full sort trace", "body": "Table columns: i, key, array after shifts. Sorted prefix grows one element per i. Already-sorted input still runs but minimal shifts." } ], "traps": [ "Shift direction wrong in insertion sort.", "Using i past len-1.", "Confusing insert index after shifts.", "O(n²) trace confusion on small n—still trace mechanically." ], "retrieval": [ "What is sorted after outer index i in insertion sort?", "How does shift step work?", "Difference traverse vs sort?" ], "deepStudy": "# Computational Thinking · Week 5 — Lists and insertion sort\n\nDeep study for Quiz 2 week 5. Lists store ordered sequences; insertion sort builds a sorted prefix by shifting larger neighbors right.\n\n## Week map\n\nList operations → 0-based indexing → traversal → insertion sort outer loop → inner shift → sorted invariant.\n\n## List notation (algorithmic view)\n\n- **List** → ordered sequence of items at positions $0, 1, \\ldots, n-1$.\n- `len(L)` → length $n$.\n- `L[i]` → item at index $i$ → valid when $0 \\leq i < n$.\n- **Append** → add at end; **insert** → open slot at index, shift right.\n\nMini-example: $L = [5, 2, 8, 1]$. $L[0] = 5$, $L[-1] = 1$ (last), $\\text{len}(L) = 4$.\n\n### Traversal\n\nVisit each position once:\n\n```text\nfor i from 0 to len(L)-1:\n process L[i]\n```\n\nOr while-index style with counter increment.\n\n## Insertion sort notation\n\n- **Outer index** $i$ → next element to insert into sorted prefix $L[0..i-1]$.\n- **Key** → value at $L[i]$ to place correctly.\n- **Inner index** $j$ → walk backward while $L[j] > \\text{key}$, shift $L[j]$ right to $L[j+1]$.\n- **Invariant:** after each outer step, $L[0..i]$ is sorted.\n\nMini-trace on $[3, 1, 4, 2]$:\n\n| $i$ | key | after shifts | sorted prefix |\n| --- | --- | --- | --- |\n| 1 | 1 | [1, 3, 4, 2] | first 2 |\n| 2 | 4 | no shift | first 3 |\n| 3 | 2 | [1, 2, 3, 4] | all 4 |\n\n## Pattern families\n\n### Easy — Traverse and transform\n\nVisit each index; compute sum, count, or build new list. Keep indices in range $0$ to $\\text{len}-1$.\n\n### Medium — One insertion sort pass\n\nGiven $i$ and array state, trace inner shifts. Place key at final hole $j+1$.\n\n### Hard — Full sort trace\n\nTable columns: $i$, key, array after each outer iteration. Count shifts. Already-sorted input: minimal inner work but outer still runs $n-1$ times.\n\n## Worked mini-examples\n\n**Example 1 — Index access.**\n\n$L = [10, 20, 30]$. $L[1] = 20$. Insert 15 at index 1 → $[10, 15, 20, 30]$.\n\n**Example 2 — One shift step.**\n\nArray $[2, 5, 5, 7]$, key $= 4$ at position 2. Compare $L[1]=5 > 4$: shift → $[2, 5, 5, 7]$ then $[2, 5, 5, 7]$... walk $j$ from 1: $L[1]=5>4$ shift to index 2 → $[2, 5, 5, 7]$; $L[0]=2 \\not> 4$; place key at $j+1 = 1$ → $[2, 4, 5, 7]$.\n\n**Example 3 — Sorted input.**\n\n$[1, 2, 3]$: each key already in place — zero shifts, still $n-1$ outer passes.\n\n**Example 4 — Reverse input.**\n\n$[3, 2, 1]$: maximum shifts — roughly $1 + 2 = 3$ shifts for $n=3$.\n\n**Example 5 — Locate after shifts.**\n\nInner loop stops when $L[j] \\leq \\text{key}$ or $j < 0$. Write key at $L[j+1]$.\n\n## Traps\n\n- Shift direction wrong — move larger elements right, not left.\n- Off-by-one: outer $i$ typically starts at 1 (first element trivially sorted).\n- Confusing insert index after multiple shifts.\n- Using $i$ past $\\text{len}-1$.\n- Assuming $O(n)$ because small $n$ in trace — algorithm is $O(n^2)$ comparisons in worst case.\n\n## Diagnostic (try yourself)\n\n1. List $[7, 3, 9, 1]$. What is index of element 9? What is $\\text{len}$?\n\n2. One outer step of insertion sort at $i=1$ on $[4, 2, 5]$. Show array after placing key.\n\n3. How many outer iterations for list of length 5?\n\n4. After sorting $[5, 1, 4]$, what is the invariant about $L[0..i]$ after each $i$?\n\n5. Why does insertion sort do little work on already-sorted input?", "compressed": "list insert/delete → traversal index → insertion sort trace.", "chain": [ { "label": "List index", "expression": "L[i] read/write", "when": "0-based positions" }, { "label": "Insert", "expression": "shift right, place key", "when": "insertion sort inner loop" }, { "label": "Sorted prefix", "expression": "L[0..i-1] sorted", "when": "insertion sort invariant" }, { "label": "Compare-shift", "expression": "while L[j-1] > key: shift", "when": "trace swaps" }, { "label": "Stable sort", "expression": "equal keys keep order", "when": "insertion sort property" } ], "chattyReferenceId": "computationalthinking-week5-reference", "recognition": "Ask: What is sorted after outer index i in insertion sort?", "procedure": "Build new list or update in place per spec. Keep index valid: 0 to len-1.", "variations": "Watch for: Shift direction wrong in insertion sort." } }, { "week": 6, "title": "Tables & dictionaries", "focus": "row×column, key→value, frequency", "noteId": "may-2026-ct-week-6-tables-dicts", "skipIfExists": false, "content": { "map": "Table dimensions → cell access → dict as column map → frequency count", "concepts": "- **Table:** rows × columns; cell (r,c) identifies one value.\n- **Dictionary:** key maps to value; fast lookup by key.\n- **Frequency:** count repeats per key in data stream.\n- **Row vs column:** row is horizontal record; column is field across records.", "notation": "| Structure | Access |\n| --- | --- |\n| table | row r, column c |\n| dict | key k → value |\n| frequency dict | item → count |", "patterns": [ { "level": "Easy", "name": "Read table cell", "body": "Identify row and column from labels. Value at (2,3) is row 2 column 3 per course convention—verify problem statement." }, { "level": "Medium", "name": "Build frequency dict", "body": "Loop items; increment dict[item]. Missing key means zero before increment." }, { "level": "Hard", "name": "Table + dict combine", "body": "Use dict to store column totals keyed by header. Double loop rows then columns accumulating." } ], "traps": [ "Row/column index swapped.", "1-based vs 0-based in problem statement.", "Dict key typo creates duplicate buckets.", "Frequency before vs after normalization." ], "retrieval": [ "How is a table cell addressed?", "Dict vs table when to use?", "Steps to build frequency map?" ], "deepStudy": "# Computational Thinking · Week 6 — Tables and dictionaries\n\nDeep study for Quiz 2 week 6. Tables organize records in rows; dictionaries map keys to values for fast lookup and counting.\n\n## Week map\n\nRow/column table → record as dict → key-value lookup → frequency tally → table vs dict tradeoff.\n\n## Table notation\n\n- **Row** → one record → e.g. student name + score + section.\n- **Column** → one field across rows → all scores, all names.\n- **Cell** → intersection of row and column → single value.\n- **Header** → column labels → keys when converting to dict.\n\nMini-table:\n\n| Name | Score |\n| --- | --- |\n| Ada | 88 |\n| Ben | 92 |\n\nRow 1 cell (Ada, Score) = 88. Column Score = {88, 92}.\n\n### List of records (table as data)\n\n```text\ntable ← [\n {Name: Ada, Score: 88},\n {Name: Ben, Score: 92}\n]\n```\n\nAccess row 0 field Score → 88.\n\n## Dictionary notation\n\n- **Key** → unique identifier → string, number, tuple.\n- **Value** → data stored → any type.\n- **Lookup** → given key, retrieve value in $O(1)$ average time (conceptually constant).\n- `map[key] ← value` → insert or update.\n\nMini-example: frequency of letters in \"aba\":\n\n```text\nfreq ← empty map\nfor each character c in string:\n if c in freq:\n freq[c] ← freq[c] + 1\n else:\n freq[c] ← 1\n```\n\nResult: {a: 2, b: 1}.\n\n## Pattern families\n\n### Easy — Read table cell\n\nFrom small grid or list-of-dicts, fetch one value. Identify row vs column.\n\n### Medium — Build dict from table\n\nConvert parallel columns to records. Count occurrences. Lookup by key; handle missing key.\n\n### Hard — Aggregate with dict\n\nGroup rows by category key. Sum or average values per group. Merge two tables on shared key.\n\n## Worked mini-examples\n\n**Example 1 — Row access.**\n\nThree rows, columns (ID, Qty): row 2 ID cell = value in column ID at index 1 (0-based).\n\n**Example 2 — Dict lookup.**\n\n`phone[\"Ana\"] = \"555-0100\"`. Lookup \"Ana\" → number. Lookup missing key → error unless default policy stated.\n\n**Example 3 — Frequency.**\n\nItems [red, blue, red, green]: freq red=2, blue=1, green=1.\n\n**Example 4 — Dict of lists (column store).**\n\n```text\ndata.Name ← [Ada, Ben]\ndata.Score ← [88, 92]\n```\n\nColumn Name row index 1 → Ben.\n\n**Example 5 — Update vs insert.**\n\nIf key exists, overwrite value; dict size unchanged. New key increases size by 1.\n\n## Traps\n\n- Row index vs ID column value — row 3 ≠ ID 3 unless stated.\n- Missing key in dict — define behavior (0, null, error).\n- Counting rows vs counting distinct keys.\n- Assuming table sorted unless specified.\n- Confusing list index with dict key.\n\n## Diagnostic (try yourself)\n\n1. In a 4-row table with columns A and B, what does cell (row 3, B) mean?\n\n2. Map {x: 10, y: 20}. What is value at x? What happens at z without default?\n\n3. Count how many times \"the\" appears in word list [the, cat, the, sat].\n\n4. Represent the mini-table above as one dict mapping Name → Score.\n\n5. When is dict better than scanning entire table for each lookup?", "compressed": "table rows×cols → dict key→value → frequency count pattern.", "chain": [ { "label": "Table", "expression": "row i, column j", "when": "2D grid access" }, { "label": "Dictionary", "expression": "key ↦ value", "when": "lookup by label" }, { "label": "Frequency", "expression": "count[key] += 1", "when": "tally occurrences" }, { "label": "Row scan", "expression": "for j in cols: T[i][j]", "when": "fix row, sweep columns" }, { "label": "Missing key", "expression": "default 0 before +=", "when": "init or get" } ], "chattyReferenceId": "computationalthinking-week6-reference", "recognition": "Ask: How is a table cell addressed?", "procedure": "Identify row and column from labels. Value at (2,3) is row 2 column 3 per course convention—verify problem statement.", "variations": "Watch for: Row/column index swapped." } }, { "week": 7, "title": "Graphs & matrices", "focus": "vertices, edges, adjacency, matrix cells", "noteId": "may-2026-ct-week-7-graphs-matrices", "skipIfExists": false, "content": { "map": "Vertices & edges → adjacency idea → matrix stores edge data → read cell", "concepts": "- **Graph:** vertices (nodes) and edges (connections); may be directed or undirected.\n- **Adjacency:** whether edge exists between two vertices.\n- **Matrix representation:** rows and columns index vertices; cell encodes edge weight or count.\n- **Undirected:** matrix often symmetric; directed: row → column direction.", "notation": "| Cell | Meaning |\n| --- | --- |\n| M[i][j] | edge from i to j |\n| 0 | no edge (often) |\n| >0 | weight or count |", "patterns": [ { "level": "Easy", "name": "Count edges from matrix", "body": "Sum or count cells meeting rule (nonzero, or equals 1). Row i entries are out-edges from i in directed graph." }, { "level": "Medium", "name": "Directed vs undirected", "body": "Undirected: M[i][j]=M[j][i]. Directed: only one direction may have entry. Neighbor of i: scan row i or column i per definition." }, { "level": "Hard", "name": "Path of length 2", "body": "Two-step paths via intermediate vertex k: check pairs (i,k) and (k,j). Nested loops over k and j common in CT traces." } ], "traps": [ "Row vs column meaning swapped for directed edges.", "Assuming symmetry without undirected statement.", "Diagonal entries (self-loops) policy ignored.", "Counting each undirected edge twice." ], "retrieval": [ "What does matrix entry (i,j) usually mean?", "How to tell undirected from matrix?", "Where are out-edges of vertex i?" ], "deepStudy": "# Computational Thinking · Week 7 — Graphs and matrices\n\nDeep study for Quiz 2 week 7. Graphs model connections between vertices; matrices store grid or adjacency data in rows and columns.\n\n## Week map\n\nVertex and edge → directed vs undirected → adjacency matrix → matrix indexing → paths and degrees.\n\n## Graph notation\n\n- **Vertex** (node) → entity → labeled $v_1, v_2, \\ldots$ or named A, B, C.\n- **Edge** → connection between two vertices → $(u, v)$.\n- **Undirected edge** → $\\{u, v\\}$ — travel both ways.\n- **Directed edge** → $(u \\to v)$ — one-way arrow from $u$ to $v$.\n- **Degree** of vertex → number of edges incident → in directed graph: in-degree and out-degree separately.\n\nMini-example: vertices {A, B, C}, edges A—B, B—C. A has degree 1, B has degree 2, C has degree 1.\n\n### Path\n\n- **Path** → sequence of vertices where consecutive pairs are edges.\n- **Simple path** → no repeated vertices.\n\nPath A→B→C exists above; A→C does not (no direct edge).\n\n## Adjacency matrix notation\n\nFor $n$ vertices labeled $0..n-1$:\n\n- $M$ is $n \\times n$ matrix.\n- $M[i][j] = 1$ (or weight) if edge from $i$ to $j$ exists; else $0$.\n- Undirected graph → matrix symmetric: $M[i][j] = M[j][i]$.\n\nMini-example: 3 vertices, edges 0—1 and 1—2 (undirected):\n\n```text\nM = [0 1 0]\n [1 0 1]\n [0 1 0]\n```\n\nRow $i$ lists neighbors of vertex $i$ (out-neighbors if directed).\n\n### Matrix indexing\n\n- $M[i][j]$ → row $i$, column $j$ → 0-based unless problem states 1-based.\n- **Row** $i$ → all $j$ values — outgoing from $i$.\n- **Column** $j$ → all $i$ values — incoming to $j$ (directed).\n\n## Pattern families\n\n### Easy — Read graph from diagram\n\nCount vertices and edges. List neighbors of one vertex. Identify directed vs undirected.\n\n### Medium — Build or read adjacency matrix\n\nFill matrix from edge list. Read $M[i][j]$ for edge existence. Check symmetry for undirected.\n\n### Hard — Degree and path reasoning\n\nCompute degree from matrix row sums. Determine if path exists of length 2 (via intermediate vertex). Spot isolated vertex (all zeros in row and column).\n\n## Worked mini-examples\n\n**Example 1 — Neighbors.**\n\nTriangle on {0,1,2} all connected. Each vertex degree 2.\n\n**Example 2 — Directed matrix.**\n\nEdge $0 \\to 1$ only: $M[0][1]=1$, $M[1][0]=0$. Not symmetric.\n\n**Example 3 — Row sum = out-degree.**\n\nRow [0, 1, 1, 0] sums to 2 — vertex has two outgoing edges (directed).\n\n**Example 4 — Path length 2.**\n\n$M[0][1]=1$ and $M[1][2]=1$ implies path 0→1→2 exists (length 2).\n\n**Example 5 — Isolated vertex.**\n\nRow and column all zero — no edges incident.\n\n## Traps\n\n- 0-based vs 1-based vertex labels in matrix.\n- Directed edge $i \\to j$ does not imply $j \\to i$.\n- Counting self-loop $M[i][i]=1$ in degree twice wrongly in undirected mental model.\n- Confusing number of vertices with matrix size $n$.\n- Path vs edge — path can use multiple edges.\n\n## Diagnostic (try yourself)\n\n1. Graph with vertices {P, Q, R} and edges P—Q, Q—R. What is degree of Q?\n\n2. Write adjacency matrix (0/1) for single undirected edge between vertices 0 and 1, no other edges ($n=2$).\n\n3. In directed graph, $M[2][5]=1$. What does this mean?\n\n4. How many edges in undirected graph if adjacency matrix has 6 ones above the diagonal?\n\n5. Vertex with row sum 0 in directed adjacency matrix — what can you conclude?", "compressed": "graph V,E → adjacency list/matrix → matrix[i][j] cell meaning.", "chain": [ { "label": "Graph", "expression": "G = (V, E)", "when": "vertices + edges" }, { "label": "Adjacency list", "expression": "neighbours of v", "when": "sparse graphs" }, { "label": "Adjacency matrix", "expression": "A[i][j] = 1 if edge", "when": "dense / quick lookup" }, { "label": "Undirected", "expression": "A symmetric", "when": "edge i–j = j–i" }, { "label": "Degree", "expression": "count incident edges", "when": "row/column sums" } ], "chattyReferenceId": "computationalthinking-week7-reference", "recognition": "Ask: What does matrix entry (i,j) usually mean?", "procedure": "Sum or count cells meeting rule (nonzero, or equals 1). Row i entries are out-edges from i in directed graph.", "variations": "Watch for: Row vs column meaning swapped for directed edges." } }, { "week": 8, "title": "Adjacency & labelled graphs", "focus": "adjacency matrix, edge labels, representation switch", "noteId": "may-2026-ct-week-8-adjacency-labelled", "skipIfExists": false, "content": { "map": "Adjacency matrix → labelled edges → switch list ↔ matrix view", "concepts": "- **Adjacency matrix:** n×n for n vertices; entry labels edge or 0/absent.\n- **Labelled graph:** edges carry names/weights/distances—not just on/off.\n- **Switch representation:** same graph as edge list or matrix; convert by filling cells.\n- **Sparse vs dense:** matrix fine small n; list of pairs for few edges.", "notation": "| Rep | Best when |\n| --- | --- |\n| matrix | dense, fixed n |\n| edge list | few edges |\n| label | weight/name in cell |", "patterns": [ { "level": "Easy", "name": "Fill adjacency matrix", "body": "Zero matrix; for each edge (u,v,w) set M[u][v]=w (and M[v][u] if undirected)." }, { "level": "Medium", "name": "Read label", "body": "Shortest direct connection label is cell value. No edge often 0 or infinity per convention—check problem." }, { "level": "Hard", "name": "Convert representations", "body": "Matrix to list: scan nonzero cells. List to matrix: place labels at indices. Verify vertex count n consistent." } ], "traps": [ "Off-by-one vertex numbering (1..n vs 0..n-1).", "Missing reverse edge in undirected fill.", "Label 0 confused with no edge.", "Matrix size not matching vertex count." ], "retrieval": [ "How fill matrix from edge list?", "What is labelled edge?", "When matrix vs edge list?" ], "deepStudy": "# Computational Thinking · Week 8 — Labelled adjacency graphs\n\nDeep study for Quiz 2 week 8. Labels on edges carry weights, costs, or names — adjacency structures must store values, not just 0/1.\n\n## Week map\n\nUnweighted vs labelled → weight matrix → multi-graph caution → shortest-path intuition → reading labelled diagrams.\n\n## Labelled edge notation\n\n- **Label** → data on edge → weight, distance, time, capacity.\n- **Weighted graph** → each edge has numeric label → often non-negative in intro problems.\n- $M[i][j] = w$ → edge from $i$ to $j$ has weight $w$.\n- $M[i][j] = 0$ or $\\infty$ → no edge (convention varies — read problem statement).\n\nMini-example: three cities 0, 1, 2. Direct roads: 0→1 weight 4, 1→2 weight 2, 0→2 weight 10.\n\n```text\n 1 --4-- 2\n \\ |\n 10 2\n \\ |\n ---- 3\n```\n\n(Adjust to matrix form in examples below.)\n\n### Weight matrix\n\n```text\nW = [ 0 4 10]\n [ ∞ 0 2]\n [ ∞ ∞ 0]\n```\n\nUse ∞ or blank for missing edge. $W[0][1]=4$, $W[1][2]=2$. Path 0→1→2 has total weight $4+2=6$, better than direct 0→2 weight 10.\n\n## Adjacency list with labels\n\nAlternative to matrix:\n\n```text\n0 → [(1, 4), (2, 10)]\n1 → [(2, 2)]\n2 → []\n```\n\nEach entry (neighbor, weight). Space-efficient for sparse graphs.\n\n### Directed vs undirected weights\n\nUndirected road length $w$ on $\\{i,j\\}$ → typically $W[i][j] = W[j][i] = w$.\n\nDirected → only one direction gets weight unless both stated.\n\n## Pattern families\n\n### Easy — Read label from diagram\n\nIdentify weight on edge between two named vertices. List all neighbors with weights from one vertex.\n\n### Medium — Build weight matrix\n\nFrom edge list $(u, v, w)$ fill $W[u][v]$. Handle missing edges with 0 or ∞ per convention.\n\n### Hard — Compare path totals\n\nSum weights along path. Compare two routes. Greedy “pick lightest edge next” may fail globally — but Quiz 2 often asks direct sum comparison only.\n\n## Worked mini-examples\n\n**Example 1 — Matrix fill.**\n\nEdges: (0,1,3), (1,2,5). Directed:\n\n```text\nW[0][1]=3, W[1][2]=5, others missing\n```\n\n**Example 2 — Path sum.**\n\nPath 0→1→2: weights 3 + 5 = 8.\n\n**Example 3 — Undirected symmetry.**\n\nEdge A—B weight 7 → $W[A][B]=W[B][A]=7$.\n\n**Example 4 — No edge.**\n\n$W[2][0]$ missing → no direct 2→0 edge in directed sense.\n\n**Example 5 — List form lookup.**\n\nFrom vertex 1 list [(0, 2), (2, 4)]: edge to 0 weight 2, to 2 weight 4.\n\n## Traps\n\n- Confusing “no edge” 0 with “zero weight” edge — problem defines convention.\n- Forgetting directed orientation when summing path.\n- Double-counting undirected edge in degree/weight tally.\n- Picking edge with min label locally vs min total path.\n- Vertex label mismatch with matrix index.\n\n## Diagnostic (try yourself)\n\n1. Weighted edge from X to Y is 6. In matrix with X=1, Y=2, what is $W[1][2]$?\n\n2. Path A→B→C with weights 3 and 5. Total weight?\n\n3. Undirected edge weight 4 between vertices 0 and 2. What are $W[0][2]$ and $W[2][0]$?\n\n4. Adjacency list for vertex 1 is [(2, 7), (3, 1)]. What is weight of edge 1→3?\n\n5. Direct path weight 12 vs two-hop path 4+5. Which route is cheaper?", "compressed": "labelled edges → matrix stores weight/label → switch list ↔ matrix.", "chain": [ { "label": "Labelled edge", "expression": "edge (u,v,w)", "when": "weight or name w" }, { "label": "Matrix entry", "expression": "M[u][v] = label or 0", "when": "no edge = sentinel" }, { "label": "Directed", "expression": "M[u][v] ≠ M[v][u]", "when": "one-way edges" }, { "label": "Representation switch", "expression": "list ↔ matrix", "when": "same graph, two views" }, { "label": "Self-loop", "expression": "M[i][i] nonzero?", "when": "check diagonal" } ], "chattyReferenceId": "computationalthinking-week8-reference", "recognition": "Ask: How fill matrix from edge list?", "procedure": "Zero matrix; for each edge (u,v,w) set M[u][v]=w (and M[v][u] if undirected).", "variations": "Watch for: Off-by-one vertex numbering (1..n vs 0..n-1)." } } ] }, { "courseId": "stats1", "folder": "Stats 1", "label": "Statistics I", "prepGuideId": "may-2026-stats-quiz-2-weeks-1-8-prep", "weeks": [ { "week": 1, "title": "Data & measurement scales", "focus": "cases, variables, nominal/ordinal/interval/ratio", "noteId": "may-2026-stats-week-1-data-types", "skipIfExists": false, "content": { "map": "Case → variable → type → scale → valid operations", "concepts": "- **Case:** one observed unit (person, day, transaction).\n- **Variable:** characteristic measured on each case; **label** names it.\n- **Types:** categorical vs numerical; **scales:** nominal, ordinal, interval, ratio.\n- **Valid ops:** ratio allows all arithmetic; nominal only counts/mode.", "notation": "| Scale | Example | Arithmetic |\n| --- | --- | --- |\n| nominal | gender code | count |\n| ordinal | survey rating | order |\n| interval | Celsius | add/subtract |\n| ratio | height, weight | all ops |", "patterns": [ { "level": "Easy", "name": "Classify variable", "body": "Ask: number or category? If category, order meaningful? Fixed zero? Determines scale and allowed summary." }, { "level": "Medium", "name": "Cases vs variables", "body": "Rows often cases, columns variables in data table. Identify n cases and p variables from context." }, { "level": "Hard", "name": "Scale traps in news", "body": "Temperature F/C interval not ratio (no true zero). Likert ordinal—do not average without justification. ZIP code nominal not numerical." } ], "traps": [ "Averaging ordinal codes.", "Treating ID numbers as numerical.", "Confusing variable with value.", "Ratio scale without true zero claimed." ], "retrieval": [ "Difference categorical vs numerical?", "Why is Celsius interval not ratio?", "What is a case in a dataset?" ], "compressed": "case → variable → type (categorical/numerical) → scale (nominal…ratio) gates legal summaries.", "chain": [ { "label": "Population vs sample", "expression": "parameter vs statistic", "when": "wording of claim" }, { "label": "Categorical", "expression": "labels / categories", "when": "mode, bar charts" }, { "label": "Numerical", "expression": "counts or measures", "when": "mean, spread" }, { "label": "Scales", "expression": "nominal < ordinal < interval < ratio", "when": "which ops allowed" } ], "deepStudy": "# Statistics I · Week 1 — Data types and measurement scales\n\nStatistics starts with **what you measured** and **what arithmetic means** on that measurement — before any formula.\n\n## Week map\n\nCase vs variable → categorical vs numerical → measurement scales → valid summaries → rows/columns in tables → common misclassification traps.\n\n## Core vocabulary\n\n- **Case** → one observed unit → one row often → student #42, Tuesday’s weather, one transaction.\n- **Variable** → characteristic recorded per case → column → `height`, `major`, `rating`.\n- **Value** → one observation of a variable for one case → `172 cm`, `\"CS\"`, `4`.\n- **Label** → name of variable → not the same as a value.\n\n### Type split\n\n| Type | Values | Examples |\n| --- | --- | --- |\n| Categorical | labels / codes | eye color, department |\n| Numerical | numbers with quantity | height, count, income |\n\nNumerical subtypes: **discrete** (counts) vs **continuous** (measurements within interval).\n\n## Measurement scales\n\n- **Nominal** → categories, no order → gender codes, zip codes.\n- **Ordinal** → ordered categories → Likert “satisfied”, medal ranks.\n- **Interval** → differences meaningful, no true zero → Celsius temperature.\n- **Ratio** → true zero, ratios meaningful → mass, distance, income.\n\nMini-examples:\n\n- Shirt size S,M,L,XL → ordinal (order) but not ratio (L is not “twice” S).\n- Year 2024 → interval-like for calendar years (no year 0 in CE) — often taught as not ratio.\n- Kelvin → ratio (0 K means no thermal energy).\n\n## Valid operations (quick gate)\n\n| Scale | Order? | Mean? | Ratio “twice as much”? |\n| --- | --- | --- | --- |\n| nominal | no | no | no |\n| ordinal | yes | caution | no |\n| interval | yes | often | no |\n| ratio | yes | yes | yes |\n\n**Trap:** averaging ordinal codes without justification treats them as interval.\n\n## Pattern families\n\n### Easy — Classify variable\n\n- Given description, state categorical vs numerical.\n- Pick scale for one variable with reason in one line.\n- Identify case count `n` from table rows.\n\n### Medium — Table orientation\n\n- Rows as cases, columns as variables (usual).\n- Distinguish variable name from value entry.\n- Several variables same cases — joint dataset.\n\n### Hard — News headline traps\n\n- ID numbers nominal, not “big number” numerical analysis.\n- ZIP code nominal — do not average.\n- Percent correct as ratio; letter grades ordinal.\n\n## Worked mini-examples\n\n**Example 1 — Classify.**\n\nDataset: for 50 buses, record `route_id` (text), `passengers` (count), `on_time` (Yes/No).\n\n- `route_id` categorical nominal\n- `passengers` numerical discrete\n- `on_time` categorical nominal (binary)\n\n**Example 2 — Scale.**\n\nVariable: pain scale 0–10 where 0 means none, 10 worst. Ordered, differences somewhat meaningful — often ordinal; not ratio (10 is not “double” 5 in pain perception).\n\n**Example 3 — Celsius.**\n\n20°C to 30°C is +10°C difference. 30°C is not “1.5× heat” of 20°C in ratio sense — interval, not ratio.\n\n**Example 4 — Cases.**\n\nTable 120 rows, columns `age`, `city`, `salary` → 120 cases, 3 variables.\n\n**Example 5 — Invalid mean.**\n\nAverage of zip codes 10001 and 10002 is meaningless — nominal.\n\n## Traps\n\n- Confusing variable with value (“variable is John”).\n- Treating student ID as numerical for correlation.\n- Averaging ordinal satisfaction codes blindly.\n- Ratio claims on interval scales (twice as hot in °C).\n- Binary categorical treated as numerical 0/1 without context — sometimes OK for modeling, but type is still categorical.\n\n## Diagnostic (try yourself)\n\n1. Classify each variable as categorical or numerical: (a) number of siblings, (b) favorite fruit, (c) body temperature in °F, (d) race finish position.\n\n2. For “years of education completed”, which scale (nominal/ordinal/interval/ratio) is most appropriate? Brief reason.\n\n3. A spreadsheet has 200 rows and 15 columns of student records. What is `n`? How many variables?\n\n4. Why is “mode of zip code” silly but “mode of eye color” OK?\n\n5. Give one example variable that is numerical discrete and one numerical continuous.", "chattyReferenceId": "stats1-week1-reference", "recognition": "Ask: Difference categorical vs numerical?", "procedure": "Ask: number or category? If category, order meaningful? Fixed zero? Determines scale and allowed summary.", "variations": "Watch for: Averaging ordinal codes." } }, { "week": 2, "title": "Categorical data", "focus": "frequency, relative frequency, graphs", "noteId": "may-2026-stats-week-2-categorical", "skipIfExists": false, "content": { "map": "Categories → counts → relative frequency → bar/pie chart choice", "concepts": "- **Frequency:** count per category.\n- **Relative frequency:** proportion or percent of total; sums to 1 (or 100%).\n- **Bar chart:** categories on axis; heights show counts or percents.\n- **Pie chart:** wedges show parts of whole—meaningful for few categories.", "notation": "| Term | Formula |\n| --- | --- |\n| rel freq | count / n |\n| percent | rel freq × 100 |\n| complement cat | all others combined |", "patterns": [ { "level": "Easy", "name": "Frequency table", "body": "Tally each category. Total n is sum of counts. Relative freq = count/n." }, { "level": "Medium", "name": "Choose chart", "body": "Bar for compare categories; pie only for part-whole with moderate category count. Avoid pie with many thin slices." }, { "level": "Hard", "name": "Missing category", "body": "Given percents summing to <100, infer missing share. Or find count from percent and n." } ], "traps": [ "Percents not summing to 100 due to rounding.", "Bar chart with ordered nominal when order arbitrary.", "Pie chart for unrelated categories not one whole.", "Confusing frequency with relative frequency." ], "retrieval": [ "How compute relative frequency?", "When bar vs pie?", "What must pie wedges sum to?" ], "deepStudy": "# Statistics I · Week 2 — Categorical data\n\nOnce variables are categories, analysis is **counting** and **comparing shares** — tables and charts, not means.\n\n## Week map\n\nCategories → frequency table → relative frequency → percent → bar chart → pie chart → complements → rounding totals.\n\n## Frequency notation\n\n- **Frequency** $f$ → count in category → 23 students chose tea.\n- **Relative frequency** → $f / n$ → proportion of whole → 0.23 if $n=100$.\n- **Percent** → relative × 100 → 23%.\n- **Complement** → all categories not A → if A is 30%, complement is 70%.\n\nConstraint: relative frequencies sum to 1 (percents sum to 100%) except rounding drift.\n\nMini-table: colors Red 40, Blue 35, Green 25, $n=100$.\n\n- Rel freq: 0.40, 0.35, 0.25\n- Percents: 40%, 35%, 25%\n\n## Charts\n\n### Bar chart\n\n- Categories on axis (nominal or ordinal).\n- Bar height = count or percent.\n- Good for compare across categories.\n\n### Pie chart\n\n- Wedges show part-whole.\n- Works for few categories; weak for many thin slices.\n- Angles proportional to relative frequency.\n\n**Trap:** pie for unrelated totals not forming one meaningful whole.\n\n## Pattern families\n\n### Easy — Build frequency table\n\n- Tally categories from raw list.\n- Compute $n$ as sum of counts.\n- Relative freq = count/$n$.\n\n### Medium — Chart choice and read\n\n- Pick bar vs pie from question goal.\n- Read missing count from percent and $n$: count = percent/100 × $n$.\n- Compare two categories via difference in counts or percents.\n\n### Hard — Rounding and complements\n\n- Percents sum to 99% or 101% due to rounding — know largest category still identifiable often.\n- Given two category percents, find third when three categories total 100%.\n- Two-way categorical preview: row percent vs overall percent (setup for week 4).\n\n## Worked mini-examples\n\n**Example 1 — Relative frequency.**\n\n120 voters: A 54, B 36, C 30.\n\n$n=120$. Rel: 0.45, 0.30, 0.25.\n\n**Example 2 — Percent to count.**\n\n$n=250$, 16% chose option D → count = 0.16 × 250 = 40.\n\n**Example 3 — Complement.**\n\n40% walked → 60% did not walk (single binary split).\n\n**Example 4 — Missing category.**\n\nThree flavors: chocolate 45%, vanilla 30%, strawberry ? → strawberry 25%.\n\n**Example 5 — Bar vs pie.**\n\nSix transport modes with similar counts → bar chart clearer. Two outcome yes/no → pie or bar both OK.\n\n## Traps\n\n- Confusing frequency with relative frequency.\n- Pie chart with dozens of categories.\n- Percents not summing to 100 — rounding, not always error.\n- Bar chart ordered as if ordinal when nominal — order arbitrary unless by count.\n- Using pie when categories are not parts of one group total.\n\n## Diagnostic (try yourself)\n\n1. Raw: `[R,R,B,G,R,B,G,G,R]` — build frequency table and $n$.\n\n2. $n=80$, counts A=32, B=20, C=28. Find relative frequencies and percents.\n\n3. In a survey, 35% preferred online and 45% preferred hybrid. The only other option is in-person. What percent chose in-person?\n\n4. $n=200$, 12.5% chose “other”. How many cases?\n\n5. When would a bar chart be better than a pie chart for the same categorical data? One sentence.", "compressed": "frequency table → relative freq = count/n → bar/pie for categories.", "chain": [ { "label": "Frequency", "expression": "count per category", "when": "raw tallies" }, { "label": "Relative frequency", "expression": "count / total", "when": "proportions sum to 1" }, { "label": "Mode", "expression": "most frequent category", "when": "categorical centre" }, { "label": "Bar chart", "expression": "height = count or %", "when": "compare categories" }, { "label": "Missing category", "expression": "include \"other\" or NA", "when": "complete sample space" } ], "chattyReferenceId": "stats1-week2-reference", "recognition": "Ask: How compute relative frequency?", "procedure": "Tally each category. Total n is sum of counts. Relative freq = count/n.", "variations": "Watch for: Percents not summing to 100 due to rounding." } }, { "week": 3, "title": "Numerical data", "focus": "mean, median, spread, five-number summary", "noteId": "may-2026-stats-week-3-numerical", "skipIfExists": false, "content": { "map": "Sort → center (mean/median) → spread → five-number → boxplot read", "concepts": "- **Mean:** sum/n; sensitive to outliers.\n- **Median:** middle after sort; resists outliers.\n- **Spread:** range, IQR = Q3−Q1; **five-number summary:** min, Q1, median, Q3, max.\n- **Boxplot:** box Q1–Q3, line at median, whiskers to extremes or fences.", "notation": "| Measure | Definition |\n| --- | --- |\n| mean | $\\bar{x} = \\sum x_i / n$ |\n| IQR | Q3 − Q1 |\n| median | middle of sorted list |", "patterns": [ { "level": "Easy", "name": "Mean and median", "body": "Sort data for median. Mean uses all values. Even n: median average of two middle values." }, { "level": "Medium", "name": "Five-number summary", "body": "Find Q1 median of lower half, Q3 median of upper half (exclude median overall for odd n per course rule—follow problem convention)." }, { "level": "Hard", "name": "Outlier effect", "body": "Compare mean vs median shift when extreme added. IQR often stable; range changes. State which center matches context." } ], "traps": [ "Median without sorting.", "Q1/Q3 by wrong half split.", "Mean of ordinal data inappropriately.", "Range as only spread measure ignoring outliers." ], "retrieval": [ "When prefer median over mean?", "What is IQR?", "Five numbers in summary?" ], "deepStudy": "# Statistics I · Week 3 — Numerical summaries\n\nNumerical data asks for **center**, **spread**, and **five-number summary** — then reading boxplots.\n\n## Week map\n\nSort data → mean vs median → quartiles Q1, Q3 → IQR → five-number summary → boxplot → outlier sensitivity.\n\n## Center notation\n\n- **Mean** $\\bar{x}$ → sum divided by count → $\\bar{x} = \\frac{\\sum x_i}{n}$.\n- **Median** → middle of sorted list → resists extremes.\n- $n$ odd → median is middle value.\n- $n$ even → median average of two middle values.\n\nMini-data: `[3, 7, 8, 12]`, $n=4$, sorted same. Median = $(7+8)/2 = 7.5$. Mean = $(3+7+8+12)/4 = 7.5$ here coincidentally.\n\n## Spread notation\n\n- **Range** → max − min → sensitive to outliers.\n- **Q1** → median of lower half (convention varies — follow problem).\n- **Q3** → median of upper half.\n- **IQR** → $Q3 - Q1$ → middle 50% spread.\n- **Five-number summary** → min, Q1, median, Q3, max.\n\n### Boxplot read\n\n- Box from Q1 to Q3.\n- Line inside box at median.\n- Whiskers to min/max or to fences (course rule).\n- Outliers sometimes plotted as points beyond fences.\n\n## Mean vs median (when to use)\n\n| Situation | Prefer |\n| --- | --- |\n| symmetric, no outliers | mean |\n| skewed or outliers | median |\n| ordinal data | neither mean (usually) |\n\nMini-example: salaries `[30k, 32k, 35k, 200k]`. Mean pulled high; median ~32.5k more typical.\n\n## Pattern families\n\n### Easy — Mean and median\n\n- Compute on small list.\n- Sort first for median.\n- Even vs odd $n$.\n\n### Medium — Five-number summary\n\n- Split halves for Q1, Q3 with stated convention.\n- IQR from quartiles.\n- Compare two datasets via medians and IQRs.\n\n### Hard — Outlier effect\n\n- Add extreme point; track mean shift vs median.\n- Which measure changes more for one outlier?\n- Interpret boxplot: skew direction from median position in box.\n\n## Worked mini-examples\n\n**Example 1 — Median odd.**\n\n`[4, 1, 9, 2, 7]` → sort `[1,2,4,7,9]` → median 4.\n\n**Example 2 — Mean.**\n\n`[10, 20, 30]` → mean 20.\n\n**Example 3 — Five-number (simple convention).**\n\n`[2, 4, 5, 7, 9, 11, 15]` ($n=7$).\n\n- min 2, max 15, median 7 (middle)\n- Lower half `[2,4,5]` Q1=4; upper `[9,11,15]` Q3=11\n- IQR = 11 − 4 = 7\n\n(If problem uses inclusive/exclusive split differently, follow their rule — note it.)\n\n**Example 4 — Outlier.**\n\n`[5,6,6,7,7,8,100]`. Mean ≈ 18.9, median 7 — median better center tag.\n\n**Example 5 — Boxplot skew.**\n\nMedian near Q1 with long whisker to max → right skew suggested.\n\n## Traps\n\n- Median without sorting.\n- Q1/Q3 by wrong half split (include median in both halves vs exclude).\n- Mean on ordinal codes.\n- Range as only spread measure when outliers present.\n- Confusing IQR with full range.\n\n## Diagnostic (try yourself)\n\n1. Find mean and median of `[8, 3, 11, 3, 9]`.\n\n2. Sorted data `[1, 3, 4, 6, 8, 10, 12]`. Report min, max, median, Q1, Q3, IQR (use lower/upper half excluding overall median for quartiles).\n\n3. Two datasets same median 50. A has IQR 10, B has IQR 40. Which is more spread in the middle 50%?\n\n4. Add outlier 500 to `[10, 12, 11, 13, 12]`. Which changes more: mean or median?\n\n5. A boxplot shows median line near the top of the box and longer whisker below. Describe skew direction.", "compressed": "mean vs median → spread (range, IQR) → five-number summary → outlier caution.", "chain": [ { "label": "Mean", "expression": "x̄ = Σx / n", "when": "symmetric, no extreme outliers" }, { "label": "Median", "expression": "middle of sorted data", "when": "skewed / outliers" }, { "label": "IQR", "expression": "Q3 − Q1", "when": "middle 50% spread" }, { "label": "Five-number", "expression": "min, Q1, med, Q3, max", "when": "boxplot skeleton" }, { "label": "Variance", "expression": "avg squared deviation", "when": "spread measure" } ], "chattyReferenceId": "stats1-week3-reference", "recognition": "Ask: When prefer median over mean?", "procedure": "Sort data for median. Mean uses all values. Even n: median average of two middle values.", "variations": "Watch for: Median without sorting." } }, { "week": 4, "title": "Association", "focus": "contingency tables, scatterplots, correlation", "noteId": "may-2026-stats-week-4-association", "skipIfExists": false, "content": { "map": "Two variables → table or scatter → pattern → correlation strength", "concepts": "- **Contingency table:** counts for two categorical variables cross-classified.\n- **Scatterplot:** numerical vs numerical; direction, form, strength.\n- **Correlation r:** linear association −1 to 1; not for nonlinear or categorical.\n- **Association ≠ causation:** confounders may explain pattern.", "notation": "| Tool | Variables |\n| --- | --- |\n| contingency | both categorical |\n| scatter | both numerical |\n| r | linear correlation |", "patterns": [ { "level": "Easy", "name": "Read contingency cell", "body": "Cell is joint count for row category AND column category. Margins sum rows/columns." }, { "level": "Medium", "name": "Describe scatter", "body": "State positive/negative/none, linear/curved, weak/strong. Correlation sign matches slope direction for linear cloud." }, { "level": "Hard", "name": "r interpretation", "body": "Near ±1 tight linear; near 0 weak linear (nonlinear pattern may exist). r unchanged by scaling if linear." } ], "traps": [ "Causation from correlation.", "r for categorical coded numbers.", "Outlier dominating r.", "Confusing strength with slope steepness." ], "retrieval": [ "What does contingency table show?", "Correlation measures what kind of association?", "Why association not causation?" ], "deepStudy": "# Statistics I · Week 4 — Association and correlation\n\nTwo variables together: **tables** for categorical pairs, **scatterplots** and **$r$** for numerical pairs. Association is not causation.\n\n## Week map\n\nTwo variables → contingency table → marginal totals → scatterplot features → correlation $r$ → strength vs direction → limitations of $r$.\n\n## Contingency table notation\n\n- **Contingency table** → cross-classified counts → rows = one variable, columns = another.\n- **Cell** → count in one row category AND one column category.\n- **Marginal total** → row or column sum → not joint.\n- **Joint** → specific pair; **marginal** → one variable alone.\n\nMini-table (transport × gender, counts):\n\n| | Bus | Train | Total |\n| --- | --- | --- | --- |\n| F | 30 | 20 | 50 |\n| M | 25 | 25 | 50 |\n| Total | 55 | 45 | 100 |\n\nCell (F, Train) = 20. Marginal female total = 50.\n\n## Scatterplot language\n\nFor numerical $x$ and $y$:\n\n- **Direction** → positive (upward), negative (downward), none.\n- **Form** → linear, curved, clusters.\n- **Strength** → tight cloud vs scattered.\n- **Outliers** → points off main pattern.\n\nMini-description: “positive, roughly linear, moderate strength, one high outlier.”\n\n## Correlation $r$\n\n- $r$ → Pearson correlation coefficient → measures **linear** association.\n- Range $-1 \\le r \\le 1$.\n- $r \\approx 1$ → tight increasing line.\n- $r \\approx -1$ → tight decreasing line.\n- $r \\approx 0$ → weak **linear** pattern (curved pattern may still exist).\n\n**Trap:** $r$ is not steepness of slope — standardized measure of linear fit strength/direction.\n\nProperties (linear world):\n\n- Sign of $r$ matches slope of best-fit line.\n- $r$ unchanged if you add constant to all $x$ or scale $x$ by positive constant (linear transform).\n\n## Association vs causation\n\nPattern may be due to:\n\n- Direct cause\n- Confounding third variable\n- Coincidence\n\nIce cream sales and drowning correlate — weather confounds both.\n\n## Pattern families\n\n### Easy — Read contingency cell\n\n- Identify joint count.\n- Compute marginal from table.\n- Percent of total in one cell: cell/n.\n\n### Medium — Describe scatter\n\n- State direction, form, strength in words.\n- Match sign of $r$ to scatter direction.\n- Spot outlier effect on $r$.\n\n### Hard — Interpret $r$ and limits\n\n- Near ±1 vs near 0 interpretation.\n- Strong nonlinear pattern with $r$ near 0.\n- Do not infer causation from $r$.\n- Categorical coded as numbers — $r$ may mislead.\n\n## Worked mini-examples\n\n**Example 1 — Cell percent.**\n\nFrom table above: percent female bus riders = 30/100 = 30% of all, or 30/50 = 60% of females.\n\n**Example 2 — Scatter words.**\n\nPoints rise left to right tightly → positive, linear, strong.\n\n**Example 3 — $r$ sign.**\n\n$r = -0.82$ → strong negative linear association.\n\n**Example 4 — Nonlinear trap.**\n\nParabolic cloud around 0 → $r$ might be near 0 though $y$ clearly depends on $x$.\n\n**Example 5 — Outlier.**\n\nMost points tight positive line; one far low point pulls $r$ down.\n\n## Traps\n\n- Causation from correlation.\n- $r$ for categorical disguised as numbers (zip codes).\n- Confusing strength with steep slope.\n- Ignoring outliers dominating $r$.\n- Contingency cell vs marginal confusion.\n\n## Diagnostic (try yourself)\n\n1. In a 2×3 contingency table, what does a single cell count represent?\n\n2. Describe in words a scatterplot that is negative, linear, and weak.\n\n3. If $r = 0.15$ between study hours and exam score, is linear association strong or weak? Does high score **cause** more hours?\n\n4. Table: exercise (Low/High) × health (Poor/Good). Low-Poor cell = 40, total $n=200$. What percent of all cases are Low and Poor?\n\n5. A U-shaped scatter has $r \\approx 0$. Can $y$ still depend on $x$? Explain briefly.", "compressed": "contingency table → marginal totals → association vs causation → correlation r.", "chain": [ { "label": "Contingency", "expression": "rows × cols counts", "when": "two categorical vars" }, { "label": "Marginal", "expression": "row/col sums", "when": "univariate distributions" }, { "label": "Scatterplot", "expression": "(x,y) points", "when": "two numerical vars" }, { "label": "Correlation", "expression": "r ∈ [−1,1]", "when": "linear association strength" }, { "label": "Causation trap", "expression": "assoc ≠ cause", "when": "confounders / direction" } ], "chattyReferenceId": "stats1-week4-reference", "recognition": "Ask: What does contingency table show?", "procedure": "Cell is joint count for row category AND column category. Margins sum rows/columns.", "variations": "Watch for: Causation from correlation." } }, { "week": 5, "title": "Counting", "focus": "addition vs multiplication rule, factorials", "noteId": "may-2026-stats-week-5-counting", "skipIfExists": false, "content": { "map": "Events → addition OR → multiplication AND → factorial arrangements", "concepts": "- **Addition rule:** mutually exclusive outcomes: ways = n1 + n2.\n- **Multiplication rule:** sequential independent stages: ways = n1 × n2.\n- **Factorial n!:** permutations of n distinct items: n!.\n- **Identify:** OR vs AND story structure before computing.", "notation": "| Rule | When |\n| --- | --- |\n| + | either A or B, not both |\n| × | A then B stages |\n| n! | all orderings of n distinct |", "patterns": [ { "level": "Easy", "name": "OR count", "body": "Disjoint options: add counts. Example: pick meal OR drink from separate disjoint menus." }, { "level": "Medium", "name": "AND stages", "body": "Shirt then pants: multiply choices per stage. Tree diagram multiplies along paths." }, { "level": "Hard", "name": "Factorial setup", "body": "Arrange all in line: n!. Identify whether problem is arrangement (order) vs selection (later week)." } ], "traps": [ "Multiplying when outcomes overlap (not disjoint).", "Adding when stages should multiply.", "0! assumed 1 forgotten.", "Treat same objects as distinct without reason." ], "retrieval": [ "When add vs multiply counts?", "What does n! count?", "Value of 0!" ], "deepStudy": "# Statistics I · Week 5 — Counting rules\n\nDeep study for Quiz 2 week 5. Counting stories reduce to **OR** (add) vs **AND** (multiply) — identify structure before computing.\n\n## Week map\n\nOutcome listing → addition rule (mutually exclusive) → multiplication rule (sequential stages) → factorial arrangements → tree diagrams.\n\n## Counting notation\n\n- $n!$ → “$n$ factorial” → product $n \\times (n-1) \\times \\cdots \\times 1$ → ways to arrange $n$ distinct items in a line.\n- $0! = 1$ → empty arrangement convention.\n- **Mutually exclusive** → events cannot happen together → use addition.\n- **Independent stages** → choices in sequence → multiply counts per stage.\n\nMini-example: $4! = 4 \\times 3 \\times 2 \\times 1 = 24$ orderings of four distinct books.\n\n### Addition rule (OR)\n\nIf task A can be done in $n_1$ ways and task B in $n_2$ ways, and they are **disjoint** (only A or only B):\n\n$$\\text{ways} = n_1 + n_2$$\n\nExample: pick soup **or** salad (not both) from menus of 3 soups and 4 salads → $3 + 4 = 7$.\n\n### Multiplication rule (AND)\n\nIf stage 1 has $n_1$ options and stage 2 has $n_2$ options (independent sequential choices):\n\n$$\\text{ways} = n_1 \\times n_2$$\n\nExample: 3 shirts **and** 2 pants → $3 \\times 2 = 6$ outfits.\n\n## Pattern families\n\n### Easy — OR count\n\nDisjoint options: add counts. Identify that choices exclude each other.\n\n### Medium — AND stages\n\nMultiply choices per stage. Tree diagram: branches multiply along a path.\n\n### Hard — Factorial setup\n\nArrange all $n$ distinct objects in order → $n!$. Distinguish arrangement (order matters) from selection (week 6). Spot when objects are not all distinct (preview: divide later).\n\n## Worked mini-examples\n\n**Example 1 — Addition.**\n\nTravel by bus (4 routes) or metro (2 routes), not both → $4 + 2 = 6$.\n\n**Example 2 — Multiplication.**\n\nPIN with 2 letters (26 each) then 3 digits (10 each) → $26^2 \\times 10^3$ (if repetition allowed — state assumption).\n\n**Example 3 — Factorial.**\n\nArrange 3 students in a row → $3! = 6$.\n\n**Example 4 — Tree.**\n\nChoice A/B then choice 1/2/3 → $2 \\times 3 = 6$ paths.\n\n**Example 5 — Not disjoint trap.**\n\nRed shirt or blue shirt from 3 red and 2 blue → add works. “Shirt or pants” from same outfit pick may need careful reading.\n\n## Traps\n\n- Multiplying when outcomes overlap (not mutually exclusive).\n- Adding when stages should multiply.\n- Forgetting $0! = 1$.\n- Treating identical objects as distinct without reason.\n- Double-counting paths on tree when branches reconverge.\n\n## Diagnostic (try yourself)\n\n1. Menu: 5 vegetarian or 7 non-vegetarian mains (pick exactly one). How many choices?\n\n2. Lock with 3 dials, 10 digits each. How many combinations (repetition allowed)?\n\n3. In how many ways can 4 distinct trophies line up on a shelf?\n\n4. A task has two sequential choices: 3 then 5 options. Total paths?\n\n5. Why is $0!$ defined as 1? (One-sentence intuition.)", "compressed": "addition rule (or) → multiplication rule (and) → factorial n!.", "chain": [ { "label": "Addition rule", "expression": "|A∪B| = |A|+|B|−|A∩B|", "when": "either A or B" }, { "label": "Multiplication", "expression": "k choices × m choices", "when": "sequential independent stages" }, { "label": "Factorial", "expression": "n! = n×(n−1)×...×1", "when": "arrange n distinct" }, { "label": "Disjoint", "expression": "A∩B = ∅ → |A∪B|=|A|+|B|", "when": "no overlap" }, { "label": "With/without replacement", "expression": "denominator shrinks?", "when": "changes counts" } ], "chattyReferenceId": "stats1-week5-reference", "recognition": "Ask: When add vs multiply counts?", "procedure": "Disjoint options: add counts. Example: pick meal OR drink from separate disjoint menus.", "variations": "Watch for: Multiplying when outcomes overlap (not disjoint)." } }, { "week": 6, "title": "Permutations & combinations", "focus": "order matters?, nPr, nCr", "noteId": "may-2026-stats-week-6-permutations-combinations", "skipIfExists": false, "content": { "map": "Order matters? → permutation → combination → formula pick", "concepts": "- **Permutation:** order matters; nPr = n!/(n−r)!.\n- **Combination:** order irrelevant; nCr = n!/(r!(n−r)!).\n- **Choose r from n:** if roles differ, permutation; if committee, combination.\n- **With repetition** variants change formulas—read problem.", "notation": "| Symbol | Meaning |\n| --- | --- |\n| nPr | permutations of r from n |\n| nCr | combinations of r from n |\n| $\\binom{n}{r}$ | same as nCr |", "patterns": [ { "level": "Easy", "name": "Order test", "body": "Ask: would ABC differ from BAC? Yes → permutation. No → combination." }, { "level": "Medium", "name": "Compute nCr", "body": "Cancel factorial factors before multiplying large numbers. Symmetry nCr = nC(n−r)." }, { "level": "Hard", "name": "Multi-step select", "body": "Choose committee with roles: multiply combinations/permutations per slot. Ensure no double count when constraints overlap." } ], "traps": [ "Permutation when order irrelevant.", "Double counting identical committees.", "r > n giving nonzero wrongly.", "Ignoring indistinguishable items." ], "retrieval": [ "Difference permutation vs combination?", "Formula for nCr?", "When is order important?" ], "deepStudy": "# Statistics I · Week 6 — Permutations and combinations\n\nDeep study for Quiz 2 week 6. **Permutations** count ordered arrangements; **combinations** count unordered selections.\n\n## Week map\n\nOrder matters? → permutation → order irrelevant? → combination → formulas → complement counting → word-problem translation.\n\n## Permutation notation\n\n- $P(n, r)$ or ${}^nP_r$ → permutations of $r$ items chosen from $n$ distinct → **order matters**.\n- Formula: $P(n,r) = \\dfrac{n!}{(n-r)!}$.\n- Special case: $P(n,n) = n!$ — arrange all $n$.\n\nMini-example: Top 2 finishers from 5 runners. Order matters (gold vs silver): $P(5,2) = 5 \\times 4 = 20$.\n\n### Combination notation\n\n- $C(n, r)$ or $\\binom{n}{r}$ → combinations — choose $r$ from $n$ → **order does not matter**.\n- Formula: $C(n,r) = \\dfrac{n!}{r!(n-r)!}$.\n- $\\binom{n}{0} = 1$; $\\binom{n}{n} = 1$.\n\nMini-example: Choose 2 toppings from 5 regardless of order: $C(5,2) = \\frac{5 \\times 4}{2 \\times 1} = 10$.\n\n### Decision rule\n\n| Question phrasing | Use |\n| --- | --- |\n| Arrange, rank, sequence, PIN order | Permutation |\n| Choose, select, committee, hand | Combination |\n\n## Pattern families\n\n### Easy — Small n compute directly\n\nList or multiply descending factors: $5 \\times 4 \\times 3$ for $P(5,3)$. Divide by $r!$ when order ignored.\n\n### Medium — Formula application\n\nPlug into $P(n,r)$ or $C(n,r)$. Simplify factorials before multiplying large numbers.\n\n### Hard — Complement or restrictions\n\n“At least one” → total minus “none.” Adjacent or fixed-position constraints may reduce to smaller permutation subproblem.\n\n## Worked mini-examples\n\n**Example 1 — Permutation.**\n\n$P(4,2) = 4 \\times 3 = 12$.\n\n**Example 2 — Combination.**\n\n$\\binom{6}{2} = \\frac{6 \\times 5}{2} = 15$.\n\n**Example 3 — Compare.**\n\n3-letter code from {A,B,C,D} without repeat: $P(4,3) = 24$. Choose 3 letters unordered: $\\binom{4}{3} = 4$.\n\n**Example 4 — Committee.**\n\nChoose 3 from 7 people for roles-free committee: $\\binom{7}{3} = 35$.\n\n**Example 5 — Complement.**\n\nChoose at least one red from 3 red and 4 blue (choose 2 total): total $\\binom{7}{2}=21$ minus no red $\\binom{4}{2}=6$ → 15.\n\n## Traps\n\n- Using combination when order matters (rankings, passwords).\n- Using permutation when order irrelevant (teams, subsets).\n- Forgetting to divide by $r!$ when converting ordered to unordered.\n- $C(n,r) = C(n, n-r)$ symmetry — useful check.\n- Identical items need division beyond basic $C(n,r)$ (not all distinct).\n\n## Diagnostic (try yourself)\n\n1. How many ways to arrange 3 distinct books on a shelf?\n\n2. How many 2-person committees from 6 people (order irrelevant)?\n\n3. Compute $P(5,3)$ and $C(5,3)$. Which is larger?\n\n4. Word problem: “President and VP from 8 candidates.” Permutation or combination? Count?\n\n5. $\\binom{10}{0}$ equals what?", "compressed": "order matters? → nPr = n!/(n−r)! → nCr = nPr/r!.", "chain": [ { "label": "Permutation", "expression": "nPr = n!/(n−r)!", "when": "order matters" }, { "label": "Combination", "expression": "nCr = n!/(r!(n−r)!)", "when": "order irrelevant" }, { "label": "Identity", "expression": "nCr = nC(n−r)", "when": "symmetry trick" }, { "label": "Multiset", "expression": "divide by duplicate factorials", "when": "repeated letters" }, { "label": "Choose vs arrange", "expression": "combination then arrange?", "when": "read problem wording" } ], "chattyReferenceId": "stats1-week6-reference", "recognition": "Ask: Difference permutation vs combination?", "procedure": "Ask: would ABC differ from BAC? Yes → permutation. No → combination.", "variations": "Watch for: Permutation when order irrelevant." } }, { "week": 7, "title": "Probability", "focus": "sample space, union, complement, disjoint events", "noteId": "may-2026-stats-week-7-probability", "skipIfExists": false, "content": { "map": "Sample space → event → rules → union/complement → disjoint add", "concepts": "- **Sample space S:** all outcomes; **event:** subset of S.\n- **P(A):** long-run proportion; 0 ≤ P ≤ 1; P(S)=1.\n- **Complement:** P(Aᶜ) = 1 − P(A).\n- **Union:** if disjoint, P(A∪B) = P(A)+P(B); else inclusion-exclusion.", "notation": "| Rule | Formula |\n| --- | --- |\n| complement | P(Aᶜ)=1−P(A) |\n| disjoint union | P(A∪B)=P(A)+P(B) |\n| general union | P(A)+P(B)−P(A∩B) |", "patterns": [ { "level": "Easy", "name": "Complement", "body": "Often easier P(at least one) = 1 − P(none). List none case carefully." }, { "level": "Medium", "name": "Disjoint union", "body": "Verify events cannot both happen. Then add probabilities." }, { "level": "Hard", "name": "Counting probability", "body": "P(A) = (# favorable)/(# equally likely outcomes). Use perm/comb from week 6 for counts." } ], "traps": [ "Adding P when events overlap.", "Probability > 1 from bad counting.", "Assuming equally likely without justification.", "Confusing AND with OR in wording." ], "retrieval": [ "When can you add probabilities?", "What is complement rule?", "Define sample space." ], "deepStudy": "# Statistics I · Week 7 — Probability axioms\n\nDeep study for Quiz 2 week 7. Probability assigns numbers to outcomes between 0 and 1, governed by addition for disjoint events and normalization over the sample space.\n\n## Week map\n\nSample space → event → probability scale → axioms → equally likely outcomes → complement rule → union of disjoint events.\n\n## Probability notation\n\n- $S$ → **sample space** → set of all possible outcomes.\n- $E$ → **event** → subset of $S$.\n- $P(E)$ → probability of event $E$ → number in $[0, 1]$.\n- $P(E) = \\dfrac{\\text{favorable outcomes}}{\\text{total outcomes}}$ when outcomes equally likely and finite.\n\nMini-example: fair die. $S = \\{1,2,3,4,5,6\\}$. Event “even” $= \\{2,4,6\\}$. $P(\\text{even}) = 3/6 = 1/2$.\n\n### Axioms (finite setting)\n\n1. $P(E) \\geq 0$ for any event $E$.\n2. $P(S) = 1$.\n3. If $A$ and $B$ disjoint: $P(A \\cup B) = P(A) + P(B)$.\n\n**Complement:** $P(A^c) = 1 - P(A)$ where $A^c$ is “not $A$.”\n\nMini-example: $P(\\text{not even on die}) = 1 - 1/2 = 1/2$.\n\n### General addition (not necessarily disjoint)\n\n$$P(A \\cup B) = P(A) + P(B) - P(A \\cap B)$$\n\nSubtract overlap once.\n\n## Pattern families\n\n### Easy — Equally likely counting\n\nList $S$, count favorable, divide. Use complement when “at least one” is easier.\n\n### Medium — Disjoint union\n\nAdd probabilities of mutually exclusive events. Verify they do not overlap.\n\n### Hard — Inclusion-exclusion light\n\nTwo events with overlap: add singles, subtract intersection. Translate word problem to $A$, $B$, $A \\cap B$.\n\n## Worked mini-examples\n\n**Example 1 — Die.**\n\n$P(\\text{roll } 5) = 1/6$.\n\n**Example 2 — Complement.**\n\nDraw one card. $P(\\text{not heart}) = 1 - 13/52 = 3/4$.\n\n**Example 3 — Disjoint sum.**\n\nDie: $A = \\{1,2\\}$, $B = \\{5,6\\}$ disjoint. $P(A \\cup B) = 2/6 + 2/6 = 4/6$.\n\n**Example 4 — Inclusion-exclusion.**\n\n$P(A)=0.4$, $P(B)=0.3$, $P(A \\cap B)=0.1$. $P(A \\cup B)=0.4+0.3-0.1=0.6$.\n\n**Example 5 — Invalid probability check.**\n\nIf $P(A)=0.7$ and $P(B)=0.5$ and they are disjoint, $P(A \\cup B)=1.2$ — impossible; they cannot be disjoint.\n\n## Traps\n\n- Probabilities outside $[0,1]$ or sum of all outcomes not 1.\n- Adding $P(A)+P(B)$ when events overlap without subtracting intersection.\n- Assuming equally likely when outcomes are not (biased coin).\n- Complement of wrong event — define $A^c$ clearly.\n- Confusing probability with odds.\n\n## Diagnostic (try yourself)\n\n1. Fair coin flipped once. What is $P(\\text{heads})$?\n\n2. Two disjoint events with $P(A)=0.3$, $P(B)=0.45$. Find $P(A \\cup B)$.\n\n3. $P(E) = 0.82$. What is $P(E^c)$?\n\n4. Bag: 3 red, 5 blue balls, one draw. $P(\\text{red})$?\n\n5. $P(A)=0.5$, $P(B)=0.4$, $P(A \\cap B)=0.2$. Find $P(A \\cup B)$.", "compressed": "P(E) in [0,1] → complement → union for disjoint → general addition.", "chain": [ { "label": "Probability", "expression": "P(E) = favourable / total", "when": "equally likely outcomes" }, { "label": "Complement", "expression": "P(Eᶜ) = 1 − P(E)", "when": "at least one / not E" }, { "label": "Union disjoint", "expression": "P(A∪B)=P(A)+P(B)", "when": "mutually exclusive" }, { "label": "General union", "expression": "P(A)+P(B)−P(A∩B)", "when": "overlap possible" }, { "label": "Sample space", "expression": "all outcomes sum to 1", "when": "sanity check" } ], "chattyReferenceId": "stats1-week7-reference", "recognition": "Ask: When can you add probabilities?", "procedure": "Often easier P(at least one) = 1 − P(none). List none case carefully.", "variations": "Watch for: Adding P when events overlap." } }, { "week": 8, "title": "Conditional probability & Bayes", "focus": "P(A|B), independence, total probability, Bayes", "noteId": "may-2026-stats-week-8-conditional-bayes", "skipIfExists": false, "content": { "map": "Condition given → P(A|B) → independence check → Bayes flip", "concepts": "- **Conditional:** P(A|B) = P(A∩B)/P(B); B must have positive probability.\n- **Independent:** P(A|B)=P(A); knowing B does not change A.\n- **Total probability:** partition B1..Bk: P(A)=Σ P(A|Bi)P(Bi).\n- **Bayes:** P(B|A) = P(A|B)P(B)/P(A).", "notation": "| Idea | Formula |\n| --- | --- |\n| conditional | P(A|B)=P(A∩B)/P(B) |\n| independence | P(A∩B)=P(A)P(B) |\n| Bayes | flip condition with prior |", "patterns": [ { "level": "Easy", "name": "Read P(A|B)", "body": "Restrict sample space to B; what fraction of B is also A? Tree diagram: multiply along path, restrict denominator." }, { "level": "Medium", "name": "Independence test", "body": "Compare P(A∩B) with P(A)P(B) or check P(A|B)=P(A). Do not assume independence from wording." }, { "level": "Hard", "name": "Bayes update", "body": "Identify prior P(B), likelihood P(A|B), compute P(A) via total prob if needed, then Bayes for posterior P(B|A)." } ], "traps": [ "P(A|B) vs P(B|A) swapped.", "Using P(A)+P(B) for AND.", "Independence assumed without check.", "Denominator P(B) zero in conditional." ], "retrieval": [ "Formula for P(A|B)?", "What does independence mean?", "When use Bayes rule?" ], "compressed": "P(A|B)=P(A∩B)/P(B) → multiply → Bayes invert cause from evidence.", "chain": [ { "label": "Conditional", "expression": "P(A|B) = P(A∩B)/P(B)", "when": "given B happened" }, { "label": "Multiplication", "expression": "P(A∩B) = P(A|B)P(B)", "when": "sequential events" }, { "label": "Independence", "expression": "P(A∩B)=P(A)P(B)", "when": "no information flow" }, { "label": "Bayes", "expression": "P(A|B)=P(B|A)P(A)/P(B)", "when": "invert direction" }, { "label": "Total prob.", "expression": "P(B)=Σ P(B|Aᵢ)P(Aᵢ)", "when": "expand denominator" } ], "deepStudy": "# Statistics I · Week 8 — Conditional probability and Bayes\n\nDeep study for Quiz 2 week 8. Conditioning narrows the sample space; Bayes flips the direction of a conditional statement.\n\n## Week map\n\nGiven information → $P(A|B)$ → multiplication rule → independence → law of total probability → Bayes theorem.\n\n## Conditional notation\n\n- $P(A|B)$ → “probability of $A$ given $B$” → probability $A$ occurs knowing $B$ occurred.\n- Formula: $P(A|B) = \\dfrac{P(A \\cap B)}{P(B)}$ — requires $P(B) > 0$.\n- **Narrow sample space:** restrict to outcomes where $B$ is true, renormalize.\n\nMini-example: die roll, $B$ = “even,” $A$ = “greater than 3.” Given even $\\{2,4,6\\}$, favorable $\\{4,6\\}$ → $P(A|B) = 2/3$.\n\n### Multiplication rule\n\n$$P(A \\cap B) = P(A|B) \\cdot P(B) = P(B|A) \\cdot P(A)$$\n\nChain events sequentially: multiply conditionals.\n\n## Independence\n\n- $A$ and $B$ **independent** if $P(A|B) = P(A)$ — knowing $B$ does not change $A$.\n- Equivalent: $P(A \\cap B) = P(A) \\cdot P(B)$.\n- Independent ≠ mutually exclusive (disjoint events with positive probability are dependent).\n\nMini-example: fair coin tosses. $A$ = first head, $B$ = second head. $P(A \\cap B) = 1/4 = P(A)P(B)$.\n\n## Bayes and total probability\n\n**Law of total probability** (partition $B_1, \\ldots, B_k$):\n\n$$P(A) = \\sum_{i=1}^{k} P(A|B_i) P(B_i)$$\n\n**Bayes theorem:**\n\n$$P(B|A) = \\frac{P(A|B) \\cdot P(B)}{P(A)}$$\n\nFlip from $P(A|B)$ to $P(B|A)$ using prior $P(B)$ and evidence $P(A)$.\n\nMini-example (screening): disease rate 1%, test sensitivity $P(+|D)=0.99$, specificity $P(-|\\text{no }D)=0.95$. Positive test does not imply 99% sick — denominator $P(+)$ mixes true and false positives via total probability.\n\n## Pattern families\n\n### Easy — Read conditional from table or story\n\nIdentify $P(A|B)$ numerator and denominator. Compute from counts in restricted row.\n\n### Medium — Multiply chain\n\n$P(A \\cap B)$ from $P(A|B)P(B)$. Two-step tree: multiply along branch.\n\n### Hard — Bayes setup\n\nIdentify hypothesis $H$ and evidence $E$. Plug $P(E|H)$, $P(H)$, compute $P(E)$ via total probability, then $P(H|E)$.\n\n## Worked mini-examples\n\n**Example 1 — Conditional from counts.**\n\n100 students: 40 take stats, 25 take both CS and stats. $P(\\text{CS}|\\text{stats}) = 25/40$.\n\n**Example 2 — Multiplication.**\n\n$P(\\text{rain})=0.2$, $P(\\text{late}|\\text{rain})=0.5$ → $P(\\text{rain and late})=0.1$.\n\n**Example 3 — Independence check.**\n\nRoll die: $A$ odd, $B$ greater than 4. $P(A)=3/6$, $P(A|B)$ on $\\{5,6\\}$ is 1/2 — not equal → dependent.\n\n**Example 4 — Complement conditional.**\n\n$P(A^c|B) = 1 - P(A|B)$.\n\n**Example 5 — Bayes skeleton.**\n\nPrior $P(H)=0.01$, likelihood $P(E|H)=0.9$, $P(E|H^c)=0.1$. Compute $P(H|E)$ using $P(E)=0.9(0.01)+0.1(0.99)$.\n\n## Traps\n\n- Swapping $P(A|B)$ and $P(B|A)$ without Bayes.\n- Using $P(A)+P(B)$ instead of conditional formula.\n- Treating independent as disjoint.\n- Forgetting to renormalize when conditioning.\n- Base rate neglect: ignoring small $P(H)$ in medical/test stories.\n\n## Diagnostic (try yourself)\n\n1. $P(A \\cap B)=0.12$, $P(B)=0.4$. Find $P(A|B)$.\n\n2. Events independent with $P(A)=0.3$, $P(B)=0.5$. Find $P(A \\cap B)$.\n\n3. Two cards without replacement: $P(\\text{second ace}|\\text{first ace})$ on standard deck — qualitative: larger or smaller than $P(\\text{second ace})$ unconditional?\n\n4. Write Bayes formula for $P(H|E)$ in terms of $P(E|H)$, $P(H)$, $P(E)$.\n\n5. Table row “Test +” split into disease / no disease counts. What probability does $P(\\text{disease}|\\text{test}+)$ use as denominator?", "chattyReferenceId": "stats1-week8-reference", "recognition": "Ask: Formula for P(A|B)?", "procedure": "Restrict sample space to B; what fraction of B is also A? Tree diagram: multiply along path, restrict denominator.", "variations": "Watch for: P(A|B) vs P(B|A) swapped." } } ] } ] }
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.