<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/~yorgey/forest/default.xsl"?>
<fr:tree xmlns:fr="http://www.forester-notes.org" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xml="http://www.w3.org/XML/1998/namespace" root="false" base-url="/~yorgey/forest/">
  <fr:frontmatter>
    <fr:authors />
    <fr:date>
      <fr:year>2026</fr:year>
      <fr:month>8</fr:month>
      <fr:day>26</fr:day>
    </fr:date>
    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JL/</fr:uri>
    <fr:display-uri>00JL</fr:display-uri>
    <fr:route>/~yorgey/forest/00JL/</fr:route>
    <fr:title text="Algorithms problems">Algorithms problems</fr:title>
  </fr:frontmatter>
  <fr:mainmatter>
    <html:p>This page collects the problems available for you to solve on <fr:link href="https://hendrix-cs.github.io/csci382/problemsets" type="external">problem sets</fr:link>.</html:p>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors />
        <fr:date>
          <fr:year>2026</fr:year>
          <fr:month>8</fr:month>
          <fr:day>26</fr:day>
        </fr:date>
        <fr:title text="Intro/review problems">Intro/review problems</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>The problems in this section are intended to help you review key ideas from Data Structures and Discrete Math that we will be using a lot in this class.  If you are unsure about anything here, use it as an opportunity to review or ask for help!</html:p>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>8</fr:month>
              <fr:day>26</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JK/</fr:uri>
            <fr:display-uri>00JK</fr:display-uri>
            <fr:route>/~yorgey/forest/00JK/</fr:route>
            <fr:title text="[RH] Repeated halving (1 pt)">[RH] Repeated halving (1 pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>How many times do you have to repeatedly halve <fr:tex display="inline"><![CDATA[32]]></fr:tex> in order to reach <fr:tex display="inline"><![CDATA[1]]></fr:tex> (or, put another way, how many times do you have to repeatedly double <fr:tex display="inline"><![CDATA[1]]></fr:tex> in order to reach <fr:tex display="inline"><![CDATA[32]]></fr:tex>)? What about <fr:tex display="inline"><![CDATA[8192]]></fr:tex>? Consider the function which given an input <fr:tex display="inline"><![CDATA[n]]></fr:tex>, outputs the number of times <fr:tex display="inline"><![CDATA[n]]></fr:tex> can be repeatedly halved before falling below <fr:tex display="inline"><![CDATA[1]]></fr:tex>. What is the common mathematical name for this function?</html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>8</fr:month>
              <fr:day>26</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JM/</fr:uri>
            <fr:display-uri>00JM</fr:display-uri>
            <fr:route>/~yorgey/forest/00JM/</fr:route>
            <fr:title text="[I1] Recurrence (2 pts)">[I1] Recurrence (2 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Let <fr:tex display="inline"><![CDATA[p_n]]></fr:tex> be defined for all <fr:tex display="inline"><![CDATA[n \geq  0]]></fr:tex> by <fr:tex display="block"><![CDATA[\begin {align*}
      p_0 &= 0 \\
      p_n &= 2p_{n-1} + 1 && (n > 0)
\end {align*}]]></fr:tex> State and prove a closed (that is, non-recursive) formula for <fr:tex display="inline"><![CDATA[p_n]]></fr:tex>.</html:p>
            <html:p>(If you need a refresher on recursion and induction, there are <fr:link href="https://hendrix-cs.github.io/csci382/resources" type="external">a lot of resources posted on the course website</fr:link>!)</html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>8</fr:month>
              <fr:day>26</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JN/</fr:uri>
            <fr:display-uri>00JN</fr:display-uri>
            <fr:route>/~yorgey/forest/00JN/</fr:route>
            <fr:title text="[O1] Big-O review (3 pts)">[O1] Big-O review (3 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>For each of the following, answer with the <html:strong>best</html:strong> (smallest) upper bound from this list: <fr:tex display="block"><![CDATA[O(1), O(\log  n), O(n), O(n \log  n), O(n^2), O(2^n).]]></fr:tex> Give a <html:strong>brief justification</html:strong> for each.</html:p>
            <html:ol><html:li>Number of leaves in a depth-<fr:tex display="inline"><![CDATA[n]]></fr:tex> balanced binary tree</html:li>
  <html:li>Depth of an <fr:tex display="inline"><![CDATA[n]]></fr:tex>-node balanced binary tree</html:li>
  <html:li>Number of edges in an <fr:tex display="inline"><![CDATA[n]]></fr:tex>-node tree</html:li>
  <html:li>Time needed to sort a list of <fr:tex display="inline"><![CDATA[n]]></fr:tex> items using merge sort</html:li>
  <html:li>Number of distinct subsets of a set of <fr:tex display="inline"><![CDATA[n]]></fr:tex> items</html:li>
  <html:li>Number of bits needed to represent the number <fr:tex display="inline"><![CDATA[n]]></fr:tex> in binary</html:li>
  <html:li>Time needed to find the closest pair of points among <fr:tex display="inline"><![CDATA[n]]></fr:tex> points in Euclidean space by simply listing all the pairs</html:li>
  <html:li>Time needed to insert <fr:tex display="inline"><![CDATA[n]]></fr:tex> items into a binary heap</html:li>
  <html:li>Time needed to find the second largest number in a <html:em>sorted</html:em> list of <fr:tex display="inline"><![CDATA[n]]></fr:tex> distinct numbers</html:li>
  <html:li>Time needed to find the second largest number in an <html:em>unsorted</html:em> list of <fr:tex display="inline"><![CDATA[n]]></fr:tex> distinct numbers</html:li></html:ol>
            <fr:tree show-metadata="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>8</fr:month>
                  <fr:day>27</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JS/</fr:uri>
                <fr:display-uri>00JS</fr:display-uri>
                <fr:route>/~yorgey/forest/00JS/</fr:route>
                <fr:title text="Big-O is not about time!">Big-<fr:tex display="inline"><![CDATA[O]]></fr:tex> is not about time!</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Students coming out of data structures often think that big-<fr:tex display="inline"><![CDATA[O]]></fr:tex> is specifically about measuring <html:em>how long</html:em> algorithms take, but it is not. Big-<fr:tex display="inline"><![CDATA[O]]></fr:tex> is a tool for measuring the <html:em>rate of growth</html:em> of one thing relative to another. We often do use it to measure the rate of growth of the time needed to run an algorithm relative to the size of the input, but we can use it to measure rates of growth of other things as well, such as the amount of memory used relative to the size of the input, the height of a tree relative to the width, and so on.</html:p>
                <html:p>So, for example, you should not assume that the questions in <fr:link href="/~yorgey/forest/00JN/" title="[O1] Big-O review (3 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00JN/" display-uri="00JN" type="local">[O1] Big-O review (3 pts)</fr:link> are asking about <html:em>time</html:em> unless they explicitly say so. For example, part (a) is asking <html:em>how many leaves</html:em> there are in a tree with a depth of <fr:tex display="inline"><![CDATA[n]]></fr:tex>, that is, how fast does the number of leaves grow relative to the depth? It is not asking <html:em>how long</html:em> it would take to find those leaves.</html:p>
              </fr:mainmatter>
            </fr:tree>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>8</fr:month>
              <fr:day>27</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JO/</fr:uri>
            <fr:display-uri>00JO</fr:display-uri>
            <fr:route>/~yorgey/forest/00JO/</fr:route>
            <fr:title text="[K1] Kattis: Akcija (1pt)">[K1] Kattis: Akcija (1pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Solve <fr:link href="https://open.kattis.com/problems/akcija" type="external">Akcija</fr:link>.</html:p>
            <fr:tree show-metadata="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>8</fr:month>
                  <fr:day>27</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JP/</fr:uri>
                <fr:display-uri>00JP</fr:display-uri>
                <fr:route>/~yorgey/forest/00JP/</fr:route>
                <fr:title text="Tips on solving Kattis problems">Tips on solving Kattis problems</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Throughout the semester, I will occasionally assign programming
challenges from <fr:link href="https://open.kattis.com/" type="external">Open Kattis</fr:link>.  These
problems will help you translate theory into practice by writing
working implementations of algorithms or concepts we have been
discussing in class.</html:p>
                <html:p>I am very aware that solutions to Kattis problems can easily be
found online, and LLMs can solve many of them.  I trust you not to
look at any such solutions.  You only get the benefit of these
problems by solving them on your own (not to mention that doing
otherwise would be an academic integrity violation).</html:p>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>8</fr:month>
                      <fr:day>27</fr:day>
                    </fr:date>
                    <fr:title text="Solving">Solving</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>You can implement your solution in any
  programming language you wish.  Kattis always expects you to submit
  a program that <html:em>reads from standard input</html:em> and <html:em>writes to
  standard output</html:em>.  For example, in Python, that means using
  <html:code>input()</html:code> to read the input and <html:code>print()</html:code> to produce output.
  In Java, you can use <html:code>Scanner</html:code> and <html:code>System.out.println</html:code>, and so
  on.</html:p>
                    <html:p>If you'd like additional hints on how to parse the input, how to
  access standard data structures in your chosen programming language,
  <html:em>etc.</html:em>, just ask!</html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>8</fr:month>
                      <fr:day>27</fr:day>
                    </fr:date>
                    <fr:title text="Submitting">Submitting</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>To submit your solution to a Kattis problem, you must submit <html:em>both</html:em>:
  <html:ul><html:li>A screenshot showing that Kattis accepted your submission</html:li>
    <html:li>Your code. Note, do <html:em>not</html:em> submit a screenshot of your code, and do not submit a project folder containing a zillion auto-generated files!  Just submit a single <html:code>.py</html:code> or <html:code>.java</html:code> file (for example—you can also use other languages besides Python and Java).</html:li></html:ul></html:p>
                  </fr:mainmatter>
                </fr:tree>
              </fr:mainmatter>
            </fr:tree>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>8</fr:month>
              <fr:day>27</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JQ/</fr:uri>
            <fr:display-uri>00JQ</fr:display-uri>
            <fr:route>/~yorgey/forest/00JQ/</fr:route>
            <fr:title text="[K2] Kattis: Backspace (1 pt)">[K2] Kattis: Backspace (1 pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Solve <fr:link href="https://open.kattis.com/problems/backspace" type="external">Backspace</fr:link>.</html:p>
            <html:p>
              <fr:link href="/~yorgey/forest/00JP/" title="Tips on solving Kattis problems" uri="http://ozark.hendrix.edu/~yorgey/forest/00JP/" display-uri="00JP" type="local">Tips on solving Kattis problems</fr:link>
            </html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>8</fr:month>
              <fr:day>27</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JR/</fr:uri>
            <fr:display-uri>00JR</fr:display-uri>
            <fr:route>/~yorgey/forest/00JR/</fr:route>
            <fr:title text="[K3] Kattis: Forests (1pt)">[K3] Kattis: Forests (1pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Solve <fr:link href="https://open.kattis.com/problems/forests" type="external">Forests</fr:link>.</html:p>
            <html:p>
              <fr:link href="/~yorgey/forest/00JP/" title="Tips on solving Kattis problems" uri="http://ozark.hendrix.edu/~yorgey/forest/00JP/" display-uri="00JP" type="local">Tips on solving Kattis problems</fr:link>
            </html:p>
          </fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors />
        <fr:date>
          <fr:year>2026</fr:year>
          <fr:month>9</fr:month>
          <fr:day>4</fr:day>
        </fr:date>
        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KF/</fr:uri>
        <fr:display-uri>00KF</fr:display-uri>
        <fr:route>/~yorgey/forest/00KF/</fr:route>
        <fr:title text="Euclidean Algorithm problems">Euclidean Algorithm problems</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>Problems related to <fr:link href="/~yorgey/forest/00JU/" title="The Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00JU/" display-uri="00JU" type="local">The Euclidean Algorithm</fr:link>, <fr:link href="/~yorgey/forest/00CA/" title="Induction" uri="http://ozark.hendrix.edu/~yorgey/forest/00CA/" display-uri="00CA" type="local">induction</fr:link>, and <fr:link href="/~yorgey/forest/00K3/" title="Proving \mathsf {GCDR} correct" uri="http://ozark.hendrix.edu/~yorgey/forest/00K3/" display-uri="00K3" type="local">proving algorithm correctness</fr:link>.</html:p>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>8</fr:month>
              <fr:day>31</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JW/</fr:uri>
            <fr:display-uri>00JW</fr:display-uri>
            <fr:route>/~yorgey/forest/00JW/</fr:route>
            <fr:title text="[GCD1] GCD via factoring vs Euclidean algorithm (2 pts)">[GCD1] GCD via factoring vs Euclidean algorithm (2 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>In class we considered the problem of finding the <html:em>greatest
  common divisor</html:em> of two positive integers.  We explored two ways to
  compute the GCD:

<html:ol><html:li>Factor the two numbers into their unique prime
  factorizations, and find the biggest subset of primes contained in
  both; this is the factorization of the GCD.</html:li>
  <html:li>Run the Euclidean Algorithm.</html:li></html:ol>

In this problem, you will consider the difference between these methods.</html:p>
            <html:ol><html:li>Use your brain, a calculator, <fr:link href="https://www.wolframalpha.com/" type="external">Wolfram Alpha</fr:link>, and/or some other appropriate computational system to factor <fr:tex display="inline"><![CDATA[170520]]></fr:tex> into its prime factors.</html:li>
  <html:li>Now factor <fr:tex display="inline"><![CDATA[522522]]></fr:tex>, and use the results to find <fr:tex display="inline"><![CDATA[\gcd (170520, 522522)]]></fr:tex> by Method 1.</html:li>
  <html:li>Trace the execution of the Euclidean Algorithm on <fr:tex display="inline"><![CDATA[(170520, 522522)]]></fr:tex>. Compare and contrast the two methods of computing the GCD of these two numbers.</html:li>
  <html:li>Now try to factor the number <fr:tex display="inline"><![CDATA[m]]></fr:tex> shown below, using whatever methods you like (for example, try using Wolfram Alpha). What happens? <fr:tex display="block"><![CDATA[m = 308903627938612635213051732991863520976852479109400884338832430641564115236537.]]></fr:tex>

<html:p>I would be willing to bet some money that you did not succeed in factoring <fr:tex display="inline"><![CDATA[m]]></fr:tex>—though not a large amount, since there do exist algorithms that can factor numbers of this size in a matter of hours or even minutes; but in any case factoring a number with, say, four times as many digits as this would require more like centuries. Factoring is widely believed to be a rather difficult computational problem (the security of your bank account probably depends on it!).</html:p></html:li>
  <html:li>Now, suppose I tell you that there are in fact three prime numbers <fr:tex display="inline"><![CDATA[p]]></fr:tex>, <fr:tex display="inline"><![CDATA[q]]></fr:tex>, and <fr:tex display="inline"><![CDATA[r]]></fr:tex>, such that <fr:tex display="block"><![CDATA[\begin {align*}
    m &= p \cdot  q =
        308903627938612635213051732991863520976852479109400884338832430641564115236537
    \\
    n &= p \cdot  r = 235051426595377535232357646935740625119338466495681619002059053022377525089111
\end {align*}]]></fr:tex> (this is the same number <fr:tex display="inline"><![CDATA[m]]></fr:tex> from part (d)). Find <fr:tex display="inline"><![CDATA[p]]></fr:tex>, <fr:tex display="inline"><![CDATA[q]]></fr:tex>, and <fr:tex display="inline"><![CDATA[r]]></fr:tex>.</html:li>
<html:li>What does this suggest about the relative efficiency of the two methods for computing the GCD?</html:li></html:ol>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>1</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JY/</fr:uri>
            <fr:display-uri>00JY</fr:display-uri>
            <fr:route>/~yorgey/forest/00JY/</fr:route>
            <fr:title text="[K4] Kattis: GCD (1 pt)">[K4] Kattis: GCD (1 pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Solve <fr:link href="https://open.kattis.com/problems/gcd" type="external">GCD</fr:link>.  You may not use any built-in GCD function; you must implement the Euclidean Algorithm yourself.</html:p>
            <html:p>
              <fr:link href="/~yorgey/forest/00JP/" title="Tips on solving Kattis problems" uri="http://ozark.hendrix.edu/~yorgey/forest/00JP/" display-uri="00JP" type="local">Tips on solving Kattis problems</fr:link>
            </html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>4</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KE/</fr:uri>
            <fr:display-uri>00KE</fr:display-uri>
            <fr:route>/~yorgey/forest/00KE/</fr:route>
            <fr:title text="Runtime analysis of the Euclidean Algorithm">Runtime analysis of the Euclidean Algorithm</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>In <fr:link href="/~yorgey/forest/00JW/" title="[GCD1] GCD via factoring vs Euclidean algorithm (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00JW/" display-uri="00JW" type="local">[GCD1] GCD via factoring vs Euclidean algorithm (2 pts)</fr:link>, you learned that the Euclidean Algorithm seems much more efficient than factoring; but how efficient is it, exactly? The problems in this section will walk you through a classic analysis of how long the Euclidean Algorithm takes to run on given inputs.  However, the problems are independent; it is possible to do each problem without having done the previous ones.</html:p>
            <html:p>Throughout this section, when referring to the Euclidean
Algorithm, we will specifically work with the <fr:link href="/~yorgey/forest/00F9/" title="Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00F9/" display-uri="00F9" type="local">recursive
implementation</fr:link> (<html:code>GCDRecA</html:code> from the POGIL activity).
</html:p>
            <fr:tree show-metadata="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>1</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JZ/</fr:uri>
                <fr:display-uri>00JZ</fr:display-uri>
                <fr:route>/~yorgey/forest/00JZ/</fr:route>
                <fr:title text="[GCD2] GCD of consecutive Fibonacci numbers (2 pts)">[GCD2] GCD of consecutive Fibonacci numbers (2 pts)</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Recall the <fr:link href="/~yorgey/forest/00BL/" title="Fibonacci numbers" uri="http://ozark.hendrix.edu/~yorgey/forest/00BL/" display-uri="00BL" type="local">Fibonacci numbers</fr:link>, defined by <fr:tex display="inline"><![CDATA[F_0 = 0]]></fr:tex>, <fr:tex display="inline"><![CDATA[F_1
= 1]]></fr:tex>, and <fr:tex display="inline"><![CDATA[F_{n+2} = F_{n+1} + F_n]]></fr:tex>. That is, the first two Fibonacci
numbers are <fr:tex display="inline"><![CDATA[0, 1]]></fr:tex>, and then each subsequent Fibonacci number is the
sum of the previous two, so the first few are <fr:tex display="inline"><![CDATA[0, 1, 1, 2, 3, 5, 8,
13, \dots ]]></fr:tex></html:p>
                <html:ol><html:li>Compute <fr:tex display="inline"><![CDATA[F_9]]></fr:tex> and <fr:tex display="inline"><![CDATA[F_{10}]]></fr:tex>, and trace the execution of the <fr:link href="/~yorgey/forest/00F9/" title="Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00F9/" display-uri="00F9" type="local">Euclidean Algorithm</fr:link> to compute <fr:tex display="inline"><![CDATA[\gcd (F_{10}, F_9)]]></fr:tex>. What happens?</html:li>
  <html:li>Prove by induction on <fr:tex display="inline"><![CDATA[n]]></fr:tex> that <fr:tex display="inline"><![CDATA[\gcd (F_{n+1}, F_n) = 1]]></fr:tex> for all <fr:tex display="inline"><![CDATA[n \geq  0]]></fr:tex>.</html:li>
  <html:li>Explain why your proof also shows that the Euclidean Algorithm requires <fr:tex display="inline"><![CDATA[n]]></fr:tex> recursive steps to compute <fr:tex display="inline"><![CDATA[\gcd (F_{n+1}, F_n) = 1]]></fr:tex>.</html:li></html:ol>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>1</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K0/</fr:uri>
                <fr:display-uri>00K0</fr:display-uri>
                <fr:route>/~yorgey/forest/00K0/</fr:route>
                <fr:title text="[GCD3] Worst-case GCD input (3 pts)">[GCD3] Worst-case GCD input (3 pts)</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>In fact, more is true: <fr:link href="/~yorgey/forest/00JZ/" title="[GCD2] GCD of consecutive Fibonacci numbers (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00JZ/" display-uri="00JZ" type="local">consecutive Fibonacci numbers</fr:link> <fr:tex display="inline"><![CDATA[(F_{n+1},
F_n)]]></fr:tex> are in some sense a <html:em>worst-case</html:em> input for the Euclidean
Algorithm: they are the <html:em>smallest</html:em> numbers for which the Euclidean
Algorithm needs <fr:tex display="inline"><![CDATA[n]]></fr:tex> steps.</html:p>
                <html:p>Let <fr:tex display="inline"><![CDATA[S(n)]]></fr:tex> be the following proposition:</html:p>
                <html:p><fr:tex display="inline"><![CDATA[S(n) =]]></fr:tex> <html:em>For all natural numbers <fr:tex display="inline"><![CDATA[a]]></fr:tex> and <fr:tex display="inline"><![CDATA[b]]></fr:tex>, if <fr:tex display="inline"><![CDATA[a > b]]></fr:tex> and <fr:tex display="inline"><![CDATA[\mathsf {GCDRec}(a,b)]]></fr:tex> makes <fr:tex display="inline"><![CDATA[n]]></fr:tex> recursive calls, then <fr:tex display="inline"><![CDATA[a \geq  F_{n+1}]]></fr:tex> and <fr:tex display="inline"><![CDATA[b \geq  F_n]]></fr:tex>.</html:em></html:p>
                <html:p>That is, if <fr:tex display="inline"><![CDATA[R(a,b,n)]]></fr:tex> represents the proposition "<fr:tex display="inline"><![CDATA[\mathsf {GCDRec}(a,b)]]></fr:tex> makes <fr:tex display="inline"><![CDATA[n]]></fr:tex> recursive calls", then <fr:tex display="block"><![CDATA[S(n) = \forall  a,b : \mathbb {N}.\; ((a > b) \land  R(a,b,n)) \to  ((a \geq  F_{n+1}) \land  (b \geq  F_n))]]></fr:tex>.</html:p>
                <html:ol><html:li>Prove <fr:tex display="inline"><![CDATA[\forall  n : \mathbb {N}. S(n)]]></fr:tex> by induction on <fr:tex display="inline"><![CDATA[n]]></fr:tex>:
  <html:ol><html:li>What does the base case <fr:tex display="inline"><![CDATA[S(0)]]></fr:tex> say? Prove it.
    
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Look at the code for <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex>.  What can you conclude about <fr:tex display="inline"><![CDATA[a]]></fr:tex> and <fr:tex display="inline"><![CDATA[b]]></fr:tex> if it makes zero recursive calls?</html:p></fr:mainmatter></fr:tree></html:li>
    <html:li>Let <fr:tex display="inline"><![CDATA[k]]></fr:tex> be an arbitrary natural number, and prove <fr:tex display="inline"><![CDATA[S(k) \to  S(k+1)]]></fr:tex> by supposing <fr:tex display="inline"><![CDATA[S(k)]]></fr:tex> to be true and proving <fr:tex display="inline"><![CDATA[S(k+1)]]></fr:tex>. You may want to write out <fr:tex display="inline"><![CDATA[S(k)]]></fr:tex> and <fr:tex display="inline"><![CDATA[S(k+1)]]></fr:tex> in full to help you <fr:link href="/~yorgey/forest/0057/" title="Proofs" uri="http://ozark.hendrix.edu/~yorgey/forest/0057/" display-uri="0057" type="local">keep track of what you know and what you are trying to prove</fr:link>.
    
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Show that <fr:tex display="inline"><![CDATA[a \geq  b + a \mathbin {\mathbf {mod}} b]]></fr:tex>.</html:p></fr:mainmatter></fr:tree></html:li></html:ol></html:li>

  <html:li>Explain why the previous result shows that if <fr:tex display="inline"><![CDATA[a \leq  F_{n+1}]]></fr:tex>
  then the Euclidean Algorithm requires at most <fr:tex display="inline"><![CDATA[n]]></fr:tex> steps.</html:li></html:ol>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>1</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K1/</fr:uri>
                <fr:display-uri>00K1</fr:display-uri>
                <fr:route>/~yorgey/forest/00K1/</fr:route>
                <fr:title text="[GCD4] Fibonacci number size (3 pts)">[GCD4] Fibonacci number size (3 pts)</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>How big are <fr:link href="/~yorgey/forest/00BL/" title="Fibonacci numbers" uri="http://ozark.hendrix.edu/~yorgey/forest/00BL/" display-uri="00BL" type="local">Fibonacci numbers</fr:link>? Let’s find out:

<html:ol><html:li>Solve <fr:tex display="inline"><![CDATA[x^2 = x + 1]]></fr:tex> for <fr:tex display="inline"><![CDATA[x]]></fr:tex> and call the positive solution <fr:tex display="inline"><![CDATA[\varphi ]]></fr:tex> (this is often known as the <html:em>golden ratio</html:em>) and the negative solution <fr:tex display="inline"><![CDATA[\hat {\varphi }]]></fr:tex>.</html:li>
  <html:li>Explain why we know that <fr:tex display="inline"><![CDATA[\varphi ^2 = \varphi  + 1]]></fr:tex> and <fr:tex display="inline"><![CDATA[\hat {\varphi }^2 = \hat {\varphi } + 1]]></fr:tex>.
  
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Your answer should be one sentence!</html:p></fr:mainmatter></fr:tree></html:li>
  <html:li>Show that <fr:tex display="inline"><![CDATA[\varphi ^{k+2} = \varphi ^{k+1}
    + \varphi ^k]]></fr:tex> for all <fr:tex display="inline"><![CDATA[k \geq  0]]></fr:tex> (by starting with <fr:tex display="inline"><![CDATA[\varphi ^2 =
    \varphi  + 1]]></fr:tex> and multiplying both sides by <fr:tex display="inline"><![CDATA[\varphi ^k]]></fr:tex>). Note that the same is also true with <fr:tex display="inline"><![CDATA[\hat {\varphi }]]></fr:tex> in place of <fr:tex display="inline"><![CDATA[\varphi ]]></fr:tex>.</html:li>
  <html:li>Now prove by induction on <fr:tex display="inline"><![CDATA[n]]></fr:tex> that <fr:tex display="inline"><![CDATA[F_n = \frac {1}{\sqrt  5}(\varphi ^n -
  \hat {\varphi }^n)]]></fr:tex>.
  
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Don’t forget that you need two base cases; you will want to show that <fr:tex display="inline"><![CDATA[\varphi  - \hat {\varphi } = \sqrt  5]]></fr:tex>.</html:p></fr:mainmatter></fr:tree></html:li>
  <html:li>
    Conclude that <fr:tex display="inline"><![CDATA[F_n \approx  \varphi ^n/\sqrt  5]]></fr:tex>.
    
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>What can you say about <fr:tex display="inline"><![CDATA[\hat {\varphi }^n]]></fr:tex> as <fr:tex display="inline"><![CDATA[n]]></fr:tex> gets large?</html:p></fr:mainmatter></fr:tree></html:li></html:ol></html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>4</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KD/</fr:uri>
                <fr:display-uri>00KD</fr:display-uri>
                <fr:route>/~yorgey/forest/00KD/</fr:route>
                <fr:title text="[GCD5] Time complexity of the Euclidean Algorithm (logarithm review) (2 pts)">[GCD5] Time complexity of the Euclidean Algorithm (logarithm review) (2 pts)</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Suppose we want to run the Euclidean Algorithm to compute <fr:tex display="inline"><![CDATA[\gcd (a,b)]]></fr:tex>, assuming <fr:tex display="inline"><![CDATA[a > b]]></fr:tex>. Let <fr:tex display="inline"><![CDATA[F_{n+1}]]></fr:tex> be the smallest Fibonacci number which is greater than or equal to <fr:tex display="inline"><![CDATA[a]]></fr:tex>. Then we know from <fr:link href="/~yorgey/forest/00K1/" title="[GCD4] Fibonacci number size (3 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00K1/" display-uri="00K1" type="local">the previous problem</fr:link> that the Euclidean Algorithm takes at most <fr:tex display="inline"><![CDATA[n]]></fr:tex> steps to run, with the worst case being when <fr:tex display="inline"><![CDATA[a = F_{n+1}]]></fr:tex>. We want to figure out how <fr:tex display="inline"><![CDATA[n]]></fr:tex> relates to <fr:tex display="inline"><![CDATA[a]]></fr:tex>.</html:p>
                <html:p>Starting from <fr:tex display="inline"><![CDATA[a = F_{n+1}]]></fr:tex> (since this is the <html:em>worst</html:em> case), and using the result from <fr:link href="/~yorgey/forest/00K1/" title="[GCD4] Fibonacci number size (3 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00K1/" display-uri="00K1" type="local">the previous problem</fr:link>, namely, that <fr:tex display="inline"><![CDATA[F_n \approx  \varphi ^n/\sqrt  5]]></fr:tex>, solve (approximately) for <fr:tex display="inline"><![CDATA[n]]></fr:tex> in terms of <fr:tex display="inline"><![CDATA[a]]></fr:tex>. Your final answer should be of the form <fr:tex display="block"><![CDATA[n \approx  k_1 \log _{10} a + k_2]]></fr:tex> for suitable constants <fr:tex display="inline"><![CDATA[k_1]]></fr:tex> and <fr:tex display="inline"><![CDATA[k_2]]></fr:tex>; you should give <fr:tex display="inline"><![CDATA[k_1]]></fr:tex> and <fr:tex display="inline"><![CDATA[k_2]]></fr:tex> in approximate, decimal form. Conclude that the Euclidean Algorithm requires, <html:em>in the worst case</html:em>, a number of steps proportional to the number of digits in the base-ten representation of <fr:tex display="inline"><![CDATA[a]]></fr:tex>.</html:p>
              </fr:mainmatter>
            </fr:tree>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>4</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KG/</fr:uri>
            <fr:display-uri>00KG</fr:display-uri>
            <fr:route>/~yorgey/forest/00KG/</fr:route>
            <fr:title text="[I2] Exponentiation (3 pts)">[I2] Exponentiation (3 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Write a recursive algorithm which, given a real number <fr:tex display="inline"><![CDATA[b]]></fr:tex> and a natural number <fr:tex display="inline"><![CDATA[e]]></fr:tex>, computes the power <fr:tex display="inline"><![CDATA[b^e]]></fr:tex>.  Prove that your algorithm is correct.</html:p>
            <html:p>You may express your algorithm using appropriate <fr:link href="/~yorgey/forest/00KH/" title="Pseudocode" uri="http://ozark.hendrix.edu/~yorgey/forest/00KH/" display-uri="00KH" type="local">pseudocode</fr:link>, or you may implement it in a real programming language; either one is fine.  You may use addition, subtraction, multiplication, and division, but you may not use any kind of built-in exponentiation operation.</html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>8</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KI/</fr:uri>
            <fr:display-uri>00KI</fr:display-uri>
            <fr:route>/~yorgey/forest/00KI/</fr:route>
            <fr:title text="[I3] The Jellybean Game (3 pts)">[I3] The Jellybean Game (3 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>The jellybean game is a game for two players. There is a row of <fr:tex display="inline"><![CDATA[n]]></fr:tex> jars, numbered <fr:tex display="inline"><![CDATA[1]]></fr:tex> to <fr:tex display="inline"><![CDATA[n]]></fr:tex> from left to right, each of which starts out containing some number of jellybeans (possibly zero). We assume that these are magical jars which can hold an <html:em>unlimited number</html:em> of jellybeans, so we don’t have to worry about the jars getting too full. (Note, however, that the jars cannot hold <html:em>infinitely</html:em> many beans—each jar must always have some finite number of jellybeans in it, but that number can be as big as we want.) We also assume that there is an unlimited supply of extra jellybeans (such as a jellybean factory or a magical jellybean-pooping unicorn).</html:p>
            <html:p>The players alternate turns. On a player’s turn, she must:
<html:ol><html:li>Pick a nonempty jar, call it jar <fr:tex display="inline"><![CDATA[k]]></fr:tex>.</html:li>
  <html:li><html:em>Remove</html:em> one jellybean from jar <fr:tex display="inline"><![CDATA[k]]></fr:tex>.</html:li>
  <html:li><html:em>Add</html:em> as many jellybeans as she wants (possibly zero) to each of the jars <fr:tex display="inline"><![CDATA[1 \dots  (k-1)]]></fr:tex> to the left of her chosen jar.</html:li></html:ol></html:p>
            <html:p>For example, suppose there are five jars which currently hold <fr:tex display="block"><![CDATA[1 \quad  3 \quad  0 \quad  2 \quad  6.]]></fr:tex> One possible valid turn is to pick jar 4 and remove one jellybean from it, then add 6, 29, and one billion jellybeans to jars <fr:tex display="inline"><![CDATA[1]]></fr:tex>, <fr:tex display="inline"><![CDATA[2]]></fr:tex>, and <fr:tex display="inline"><![CDATA[3]]></fr:tex> respectively, resulting in <fr:tex display="block"><![CDATA[7 \quad  32 \quad  10^9 \quad  1 \quad  6.]]></fr:tex></html:p>
            <html:p>The winner is the player who removes the last jellybean. Put another way, the loser is the first player who is unable to move because all the jars are empty.</html:p>
            <html:ol><html:li>Prove that the jellybean game always ends eventually. That is, even if the players conspire to try to make the game last forever, they cannot, as long as they follow the rules. (Of course, they certainly can make the game take a very, <html:em>very</html:em> long time...)</html:li>
  <html:li>Describe a winning strategy for the jellybean game.  From which positions is the first player guaranteed to win, as long as they play perfectly?  What strategy should the first player follow in order to guarantee a win, if a win is possible?</html:li></html:ol>
          </fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors />
        <fr:date>
          <fr:year>2026</fr:year>
          <fr:month>9</fr:month>
          <fr:day>8</fr:day>
        </fr:date>
        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KJ/</fr:uri>
        <fr:display-uri>00KJ</fr:display-uri>
        <fr:route>/~yorgey/forest/00KJ/</fr:route>
        <fr:title text="Asymptotic analysis problems">Asymptotic analysis problems</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>Problems related to asymptotic analysis.</html:p>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>8</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KK/</fr:uri>
            <fr:display-uri>00KK</fr:display-uri>
            <fr:route>/~yorgey/forest/00KK/</fr:route>
            <fr:title text="[O2] Algorithm input sizes by runtime (1 pt)">[O2] Algorithm input sizes by runtime (1 pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter><html:p>Suppose you have algorithms with the six running times listed below. (Assume these are the <html:em>exact</html:em> number of operations performed as a function of the input size <fr:tex display="inline"><![CDATA[n]]></fr:tex>.) Suppose you have a computer that can perform <fr:tex display="inline"><![CDATA[10^{10}]]></fr:tex> operations per second, and you need to compute a result in at most an hour of computation. For each of the algorithms, what is the largest input size <fr:tex display="inline"><![CDATA[n]]></fr:tex> for which you would be able to get the result within an hour? For answers smaller than <fr:tex display="inline"><![CDATA[10^{10}]]></fr:tex>, give your answer as an exact integer; for larger answers you may provide an approximation.</html:p>
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>8</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Most of these can be solved algebraically, but for at least one
  you may need to resort to numeric methods (<html:em>e.g.</html:em> use Wolfram Alpha
  or write a bit of code yourself).</html:p></fr:mainmatter></fr:tree>
<html:ol><html:li><fr:tex display="inline"><![CDATA[n^2]]></fr:tex></html:li>
  <html:li><fr:tex display="inline"><![CDATA[n^3]]></fr:tex></html:li>
  <html:li><fr:tex display="inline"><![CDATA[100n^2]]></fr:tex></html:li>
  <html:li><fr:tex display="inline"><![CDATA[n \log _2 n]]></fr:tex></html:li>
  <html:li><fr:tex display="inline"><![CDATA[2^n]]></fr:tex></html:li>
  <html:li><fr:tex display="inline"><![CDATA[2^{2^n}]]></fr:tex></html:li>
  <html:li><fr:tex display="inline"><![CDATA[n!]]></fr:tex></html:li></html:ol></fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>8</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KL/</fr:uri>
            <fr:display-uri>00KL</fr:display-uri>
            <fr:route>/~yorgey/forest/00KL/</fr:route>
            <fr:title text="[O3] Some asymptotic properties (2 pts)">[O3] Some asymptotic properties (2 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <fr:tree show-metadata="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>8</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KM/</fr:uri>
                <fr:display-uri>00KM</fr:display-uri>
                <fr:route>/~yorgey/forest/00KM/</fr:route>
                <fr:title text="Little-o notation">Little-o notation</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>In addition to <fr:tex display="inline"><![CDATA[O]]></fr:tex>, <fr:tex display="inline"><![CDATA[\Theta ]]></fr:tex>, and <fr:tex display="inline"><![CDATA[\Omega ]]></fr:tex>, we will also sometimes use the notation <fr:tex display="inline"><![CDATA[o(g(n))]]></fr:tex> (little-o) to mean that a function is <fr:tex display="inline"><![CDATA[O(g(n))]]></fr:tex> but <html:em>not</html:em> <fr:tex display="inline"><![CDATA[\Theta (g(n))]]></fr:tex>. So, if <fr:tex display="inline"><![CDATA[\lim _{n \to  \infty } T(n)/g(n)
= 0]]></fr:tex>, then <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(g(n))]]></fr:tex>. Intuitively, if big-O is like “less than or equal to”, little-o is like “less than”; if <fr:tex display="inline"><![CDATA[f(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(g(n))]]></fr:tex> then <fr:tex display="inline"><![CDATA[f]]></fr:tex> “grows strictly more slowly than” <fr:tex display="inline"><![CDATA[g]]></fr:tex>.</html:p>
              </fr:mainmatter>
            </fr:tree>
            <html:ol><html:li>Show that <fr:tex display="inline"><![CDATA[n^j]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(n^k)]]></fr:tex> whenever <fr:tex display="inline"><![CDATA[j < k]]></fr:tex>.</html:li>

  <html:li>Prove that <fr:tex display="inline"><![CDATA[\log _a n]]></fr:tex> is <fr:tex display="inline"><![CDATA[\Theta (\log _b n)]]></fr:tex> for any positive
  integer bases <fr:tex display="inline"><![CDATA[a,b > 1]]></fr:tex>. Conclude that we are justified in writing
  simply <fr:tex display="inline"><![CDATA[\Theta (\log  n)]]></fr:tex> without caring about the base of the
  logarithm.
  
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>8</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Recall, or look up, the logarithm change-of-base formula.</html:p></fr:mainmatter></fr:tree></html:li>

  <html:li>Prove that <fr:tex display="inline"><![CDATA[\log _b n]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(n^x)]]></fr:tex> for any <fr:tex display="inline"><![CDATA[b > 1]]></fr:tex> and <fr:tex display="inline"><![CDATA[x > 0]]></fr:tex>.
  
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>8</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Use l'Hôpital's rule.</html:p></fr:mainmatter></fr:tree></html:li>

  <html:li>Prove that <fr:tex display="inline"><![CDATA[n^k]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(b^n)]]></fr:tex> for any positive integer <fr:tex display="inline"><![CDATA[k]]></fr:tex> and
  any real number <fr:tex display="inline"><![CDATA[b > 1]]></fr:tex>. For example, <fr:tex display="inline"><![CDATA[n^{295}]]></fr:tex> is
  <fr:tex display="inline"><![CDATA[o(1.0001^n)]]></fr:tex>. <html:em>In the long run</html:em>, any polynomial function grows
  more slowly than any exponential function!
  
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>8</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Use induction and l'Hôpital's rule.</html:p></fr:mainmatter></fr:tree></html:li></html:ol>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>11</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L5/</fr:uri>
            <fr:display-uri>00L5</fr:display-uri>
            <fr:route>/~yorgey/forest/00L5/</fr:route>
            <fr:title text="[O4] Function ordering (1 pt)">[O4] Function ordering (1 pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Take the following list of functions and arrange them in ascending order of asymptotic growth rate. That is, if function <fr:tex display="inline"><![CDATA[g(n)]]></fr:tex> immediately follows function <fr:tex display="inline"><![CDATA[f(n)]]></fr:tex> in your list, then it should be the case that <fr:tex display="inline"><![CDATA[f(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[O(g(n))]]></fr:tex>. Please prove/justify your claims by making reference to theorems from class or <fr:link href="/~yorgey/forest/00KL/" title="[O3] Some asymptotic properties (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00KL/" display-uri="00KL" type="local">the previous problem</fr:link>.</html:p>
            <html:ul><html:li><fr:tex display="inline"><![CDATA[f_{1}(n) = n^{2.5}]]></fr:tex></html:li>
<html:li><fr:tex display="inline"><![CDATA[f_{2}(n) = \sqrt {2n}]]></fr:tex></html:li>
<html:li><fr:tex display="inline"><![CDATA[f_{3}(n) = n + 10]]></fr:tex></html:li>
<html:li><fr:tex display="inline"><![CDATA[f_{4}(n) = 10^n]]></fr:tex></html:li>
<html:li><fr:tex display="inline"><![CDATA[f_{5}(n) = 100^n]]></fr:tex></html:li>
<html:li><fr:tex display="inline"><![CDATA[f_{6}(n) = n^2 \log  n]]></fr:tex></html:li></html:ul>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>11</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L6/</fr:uri>
            <fr:display-uri>00L6</fr:display-uri>
            <fr:route>/~yorgey/forest/00L6/</fr:route>
            <fr:title text="[O5] Characterizing asymptotic behavior (4 pts)">[O5] Characterizing asymptotic behavior (4 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Characterize the asymptotic behavior of each of the following in terms of <fr:tex display="inline"><![CDATA[n]]></fr:tex>, using <fr:tex display="inline"><![CDATA[\Theta ]]></fr:tex>. <html:strong>Give a brief justification for each answer.</html:strong> For items asking for the time needed to perform some operation or solve some problem, you should describe the <html:em>worst case</html:em> running time of the <html:em>best possible</html:em> algorithm.</html:p>
            <html:ol><html:li><fr:tex display="inline"><![CDATA[1 + 2 + 3 + 4 + \dots  + n]]></fr:tex></html:li>
  <html:li>Average number of array lookups needed to find a given element in a sorted array of length <fr:tex display="inline"><![CDATA[n]]></fr:tex>.</html:li>
  <html:li>Number of two-element subsets of a set of size <fr:tex display="inline"><![CDATA[n]]></fr:tex>.</html:li>
  <html:li><fr:tex display="inline"><![CDATA[1 + 2 + 4 + 8 + \dots  + 2^n]]></fr:tex></html:li>
  <html:li><html:p>Total number of nodes in a complete binary tree with <fr:tex display="inline"><![CDATA[n]]></fr:tex> leaves.  A <html:em>complete</html:em> binary tree is one where every node has two children except for the leaves on the last level.  For example, the complete binary tree shown below has <fr:tex display="inline"><![CDATA[8]]></fr:tex> leaves.</html:p>
  <html:p><html:p><html:div class="forester-block"><html:a href="/~yorgey/forest/386cf4b92680f2a8">
  <html:img src="/~yorgey/forest/bafkrmibxodesocv4zb7pjgntui56ykrbrhtso2omiys72jefgm2puujoka.png" />
</html:a></html:div></html:p></html:p></html:li>

  <html:li><html:p>Number of edges in a graph with <fr:tex display="inline"><![CDATA[n]]></fr:tex> nodes, where every node is connected to every other node.</html:p>
  <html:p><html:p><html:div class="forester-block"><html:a href="/~yorgey/forest/464dc284d10b2bbb">
  <html:img src="/~yorgey/forest/bafkrmie3vpj5syvsuxkznyhvvqm3bbqzcpeuwk4jc3ez564zxihdopwqpq.png" />
</html:a></html:div></html:p></html:p></html:li>
  <html:li>Number of different ways to arrange <fr:tex display="inline"><![CDATA[n]]></fr:tex> people in a line.</html:li>
  <html:li>Average number of steps needed to find a given element in a sorted linked list of length <fr:tex display="inline"><![CDATA[n]]></fr:tex>.</html:li>
  <html:li>Biggest integer that can be represented with <fr:tex display="inline"><![CDATA[n]]></fr:tex> bits.</html:li>
  <html:li>Worst-case number of swaps needed to sort an array of length <fr:tex display="inline"><![CDATA[n]]></fr:tex> if you are only allowed to swap adjacent elements.</html:li>

  <html:li>Worst-case number of steps needed to check whether two lists, each containing <fr:tex display="inline"><![CDATA[n]]></fr:tex> integers (not necessarily sorted), have any element in common. 
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>11</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p><fr:tex display="inline"><![CDATA[\Theta (n^2)]]></fr:tex> is too slow!</html:p></fr:mainmatter></fr:tree></html:li>

  <html:li>Number of array lookups performed by this Python code:
  <html:p><html:pre><![CDATA[  for i in range(0,n):
    for j in range (0,i):
      sum += array[i][j]]]></html:pre></html:p></html:li>

  <html:li>Number of addition operations performed by this Java code:
  <html:p><html:pre><![CDATA[  for (int i = 0; i < n; i += 3) {
    sum = sum + i;
  }]]></html:pre></html:p></html:li>

  <html:li>Total number of calls to <html:code>println</html:code> performed by this Java code:
  <html:p><html:pre><![CDATA[  for (int i = 1; i < n; i *= 2) {
    for (j = 0; j < 20; j++) {
      System.out.println(i + j);
    }
  }]]></html:pre></html:p></html:li>

  <html:li>Total number of calls to <html:code>print</html:code> performed by this Python code:
  <html:p><html:pre><![CDATA[  def foo(n):
    print(n)
    if n > 0:
      foo(n-1)
      foo(n-1)]]></html:pre></html:p></html:li></html:ol>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>11</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L7/</fr:uri>
            <fr:display-uri>00L7</fr:display-uri>
            <fr:route>/~yorgey/forest/00L7/</fr:route>
            <fr:title text="[O6] Dropping jars (3 pts)">[O6] Dropping jars (3 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>You’re doing some stress-testing on various models of glass jars to determine the height from which they can be dropped and still not break. The setup for this experiment, on a particular type of jar, is as follows. You have a ladder with <fr:tex display="inline"><![CDATA[n]]></fr:tex> rungs, and you want to find the highest rung from which you can drop a copy of the jar   and not have it break. We call this the <html:em>highest safe rung</html:em>.</html:p>
            <html:p>It might be natural to try binary search: drop a jar from the middle rung, see if it breaks, and then recursively try from rung <fr:tex display="inline"><![CDATA[n/4]]></fr:tex> or <fr:tex display="inline"><![CDATA[3n/4]]></fr:tex> depending on the outcome. But this has the drawback that you could break a lot of jars in finding the answer.</html:p>
            <html:p>If your primary goal were to conserve jars, on the other hand, you could try the following strategy. Start by dropping a jar from the first rung, then the second rung, and so forth, climbing one higher each time until the jar breaks. In this way, you only need a single jar—at the moment it breaks, you have the correct answer—but you may have to drop it <fr:tex display="inline"><![CDATA[n]]></fr:tex> times (rather than <fr:tex display="inline"><![CDATA[\lg  n]]></fr:tex> times as in the binary search solution).</html:p>
            <html:p>So here is the trade-off: it seems you can perform fewer drops if you’re willing to break more jars. To understand better how this trade-off works at a quantitative level, let’s consider how to run this experiment given a fixed “budget” of <fr:tex display="inline"><![CDATA[k \geq  1]]></fr:tex> jars. In other words, you have to determine the correct answer—the highest safe rung—and can use at most <fr:tex display="inline"><![CDATA[k]]></fr:tex> jars in doing so.</html:p>
            <html:ol><html:li>Suppose you are given a budget of <fr:tex display="inline"><![CDATA[k = 2]]></fr:tex> jars. Describe a strategy for finding the highest safe rung that requires you to drop a jar at most <fr:tex display="inline"><![CDATA[f(n)]]></fr:tex> times, for some function <fr:tex display="inline"><![CDATA[f(n)]]></fr:tex> that grows slower than linearly. (In other words, <fr:tex display="inline"><![CDATA[f(n)]]></fr:tex> should be <fr:tex display="inline"><![CDATA[o(n)]]></fr:tex>, that is, <fr:tex display="inline"><![CDATA[\lim _{n \to  \infty } f(n)/n = 0]]></fr:tex>.)</html:li>

  <html:li>Now suppose you have a budget of <fr:tex display="inline"><![CDATA[k > 2]]></fr:tex> jars, for some given <fr:tex display="inline"><![CDATA[k]]></fr:tex>. Describe a strategy for finding the highest safe rung using at most <fr:tex display="inline"><![CDATA[k]]></fr:tex> jars. If <fr:tex display="inline"><![CDATA[f_k(n)]]></fr:tex> denotes the number of times you need to drop a jar according to your strategy, then the functions <fr:tex display="inline"><![CDATA[f_1, f_2, f_3, \dots ]]></fr:tex> should have the property that each grows asymptotically slower than the previous one: <fr:tex display="inline"><![CDATA[\lim _{n \to  \infty }
    f_k(n)/f_{k-1}(n) = 0]]></fr:tex> for each <fr:tex display="inline"><![CDATA[k]]></fr:tex>.</html:li></html:ol>
          </fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors />
        <fr:date>
          <fr:year>2026</fr:year>
          <fr:month>9</fr:month>
          <fr:day>14</fr:day>
        </fr:date>
        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LW/</fr:uri>
        <fr:display-uri>00LW</fr:display-uri>
        <fr:route>/~yorgey/forest/00LW/</fr:route>
        <fr:title text="Graph problems">Graph problems</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>Problems related to graphs.</html:p>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>14</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LX/</fr:uri>
            <fr:display-uri>00LX</fr:display-uri>
            <fr:route>/~yorgey/forest/00LX/</fr:route>
            <fr:title text="[G1] Adjacency matrices (1 pt)">[G1] Adjacency matrices (1 pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Given a simple graph <fr:tex display="inline"><![CDATA[G]]></fr:tex> with vertices numbered from <fr:tex display="inline"><![CDATA[1]]></fr:tex> to <fr:tex display="inline"><![CDATA[n]]></fr:tex>, an <html:em>adjacency matrix</html:em> for <fr:tex display="inline"><![CDATA[G]]></fr:tex> is an <fr:tex display="inline"><![CDATA[n \times  n]]></fr:tex> matrix <fr:tex display="inline"><![CDATA[A]]></fr:tex> where <fr:tex display="inline"><![CDATA[A[i,j] = 1]]></fr:tex> if <fr:tex display="inline"><![CDATA[i]]></fr:tex> and <fr:tex display="inline"><![CDATA[j]]></fr:tex> are adjacent, and <fr:tex display="inline"><![CDATA[A[i,j] = 0]]></fr:tex> otherwise. In other words, the entry at row <fr:tex display="inline"><![CDATA[i]]></fr:tex> and column <fr:tex display="inline"><![CDATA[j]]></fr:tex> tells us whether there is an edge between <fr:tex display="inline"><![CDATA[i]]></fr:tex> and <fr:tex display="inline"><![CDATA[j]]></fr:tex>, with <fr:tex display="inline"><![CDATA[1]]></fr:tex> for yes and <fr:tex display="inline"><![CDATA[0]]></fr:tex> for no.</html:p>
            <html:ol><html:li>Make a drawing of the graph represented by the adjacency matrix <fr:tex display="block"><![CDATA[\begin {bmatrix} 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & 0 \\ 1 & 1
                                    & 0 & 1 \\ 1 & 0 & 1 & 0 \end {bmatrix}.]]></fr:tex></html:li>
  <html:li>Given a vertex <fr:tex display="inline"><![CDATA[u]]></fr:tex> and the adjacency matrix <fr:tex display="inline"><![CDATA[A]]></fr:tex>, how long does it take to list all the neighbors of <fr:tex display="inline"><![CDATA[u]]></fr:tex>: <fr:tex display="inline"><![CDATA[\Theta (n)]]></fr:tex>, or <fr:tex display="inline"><![CDATA[\Theta (\deg (u))]]></fr:tex>? Why?</html:li>

  <html:li>A <html:em>directed</html:em> graph is a graph where each edge has a particular <html:em>direction</html:em>, that is, an edge is an <html:em>ordered pair</html:em> of vertices rather than just a set of two vertices. Typically such graphs are drawn with a little arrow on each edge showing which direction it goes. Explain how to generalize adjacency matrices to represent directed graphs.</html:li>

  <html:li>A <html:em>weighted</html:em> graph is a graph where each edge has an associated number, or <html:em>weight</html:em>, representing something like cost, time, or distance. Explain how to generalize adjacency matrices to represent weighted graphs.</html:li>

  <html:li>(Advanced, optional) Let <fr:tex display="inline"><![CDATA[A]]></fr:tex> be the adjacency matrix for a simple (undirected, unweighted) graph <fr:tex display="inline"><![CDATA[G]]></fr:tex>. What information does the matrix <fr:tex display="inline"><![CDATA[A^2]]></fr:tex> represent? What about <fr:tex display="inline"><![CDATA[A^3]]></fr:tex>? In general, what about <fr:tex display="inline"><![CDATA[A^n]]></fr:tex>?</html:li></html:ol>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>14</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LY/</fr:uri>
            <fr:display-uri>00LY</fr:display-uri>
            <fr:route>/~yorgey/forest/00LY/</fr:route>
            <fr:title text="[G2] Adjacency lists (1 pt)">[G2] Adjacency lists (1 pt)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Given a simple graph <fr:tex display="inline"><![CDATA[G]]></fr:tex>, an <html:em>adjacency list</html:em> representation for <fr:tex display="inline"><![CDATA[G]]></fr:tex> consists of a map (<html:em>aka</html:em> dictionary) associating each vertex with the <html:em>list</html:em> (or set) of all its adjacent neighbors. In other words, using Java-like notation, <html:code>Map&lt;Vertex, List&lt;Vertex&gt; &gt;</html:code>.</html:p>
            <html:ol><html:li>Make a drawing of the graph represented by the map <fr:tex display="block"><![CDATA[\{ 1
      \mapsto  [3,4], 2 \mapsto  [3], 3 \mapsto  [1, 2, 4], 4 \mapsto  [1,
      3] \}.]]></fr:tex></html:li>

  <html:li>Given a vertex <fr:tex display="inline"><![CDATA[u]]></fr:tex> and an adjacency list representation of a graph <fr:tex display="inline"><![CDATA[G]]></fr:tex>, how long does it take to list all the neighbors of <fr:tex display="inline"><![CDATA[u]]></fr:tex>: <fr:tex display="inline"><![CDATA[\Theta (n)]]></fr:tex>, or <fr:tex display="inline"><![CDATA[\Theta (\deg (u))]]></fr:tex>? Why?</html:li>

  <html:li>Explain how to generalize adjacency lists to represent directed graphs.</html:li>

  <html:li>Explain how to generalize adjacency lists to represent weighted graphs.</html:li></html:ol>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>14</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LZ/</fr:uri>
            <fr:display-uri>00LZ</fr:display-uri>
            <fr:route>/~yorgey/forest/00LZ/</fr:route>
            <fr:title text="[G3] Connectivity from degree (2 pts)">[G3] Connectivity from degree (2 pts)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter><html:p>Let <fr:tex display="inline"><![CDATA[G=(V,E)]]></fr:tex> be an undirected graph with <fr:tex display="inline"><![CDATA[n]]></fr:tex> vertices, with no self-loops (that is, no edges of the form <fr:tex display="inline"><![CDATA[(v,v)]]></fr:tex> from a vertex to itself). Show that if every vertex has degree at least <fr:tex display="inline"><![CDATA[n/2]]></fr:tex>, the graph is connected. If it makes your proof easier, you may assume that <fr:tex display="inline"><![CDATA[n]]></fr:tex> is even.</html:p>
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>14</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Think about cuts in the graph. A cut <fr:tex display="inline"><![CDATA[(S,T)]]></fr:tex> is a partition of the vertices into two sets <fr:tex display="inline"><![CDATA[S]]></fr:tex> and <fr:tex display="inline"><![CDATA[T]]></fr:tex> such that every vertex is in either <fr:tex display="inline"><![CDATA[S]]></fr:tex> or <fr:tex display="inline"><![CDATA[T]]></fr:tex> but not both. Is it possible to have a cut <fr:tex display="inline"><![CDATA[(S,T)]]></fr:tex> with no edges between <fr:tex display="inline"><![CDATA[S]]></fr:tex> and <fr:tex display="inline"><![CDATA[T]]></fr:tex>?</html:p></fr:mainmatter></fr:tree>
</fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
  </fr:mainmatter>
  <fr:backmatter>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="References">References</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Context">Context</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Backlinks">Backlinks</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>4</fr:day>
            </fr:date>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/2026-W35/</fr:uri>
            <fr:display-uri>2026-W35</fr:display-uri>
            <fr:route>/~yorgey/forest/2026-W35/</fr:route>
            <fr:title text="Weeknotes for 4 September 2026 (week 35)">Weeknotes for 4 September 2026 (week 35)</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Missed last week's weeknotes since there is a whole lot going on at
the start of the semester!</html:p>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>4</fr:day>
                </fr:date>
                <fr:title text="Haskell Interlude">Haskell Interlude</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>I was on the <fr:link href="https://haskell.foundation/podcast/" type="external">Haskell Interlude podcast</fr:link>!  I recorded the actual interview last spring, with <fr:link href="/~yorgey/forest/farhad-mehta/" title="Farhad Mehta" uri="http://ozark.hendrix.edu/~yorgey/forest/farhad-mehta/" display-uri="farhad-mehta" type="local">Farhad Mehta</fr:link> and <fr:link href="/~yorgey/forest/sam-frohlich/" title="Sam Frohlich" uri="http://ozark.hendrix.edu/~yorgey/forest/sam-frohlich/" display-uri="sam-frohlich" type="local">Sam Frohlich</fr:link>; the whole process was a lot of fun.  I listened to the episode before it was released and I am not too embarrassed about anything I said, so <fr:link href="https://haskell.foundation/podcast/85/" type="external">give it a listen</fr:link>!</html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>4</fr:day>
                </fr:date>
                <fr:title text="Semester start">Semester start</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Because of all administrative responsibilities, I had very little time to prepare for my actual classes, and the first few days of classes hit like a ton of bricks—I did not get very much sleep as I prepared syllabi and assignments at the very last minute.  I do feel I'm in a better place now, though.  Much of it was one-time overhead that need not be repeated.</html:p>
                <html:p>Getting to know my students has been fun.  I am teaching one upper-level course (<fr:link href="/~yorgey/forest/00JE/" title="CSCI 382, Algorithms" uri="http://ozark.hendrix.edu/~yorgey/forest/00JE/" display-uri="00JE" type="local">CSCI 382, Algorithms</fr:link>) in which I already knew most of the students; one introductory computing course (<fr:link href="https://hendrix-cs.github.io/csci150/" type="external">CSCI 150, Foundations of Computer Science</fr:link>); and one general education first-year seminar.  For the most part, the students seem thoughtful and engaged.</html:p>
                <html:p>I am trying something a bit different with <fr:link href="/~yorgey/forest/00JE/" title="CSCI 382, Algorithms" uri="http://ozark.hendrix.edu/~yorgey/forest/00JE/" display-uri="00JE" type="local">CSCI 382, Algorithms</fr:link> this semester (besides <fr:link href="/~yorgey/forest/00JF/" title="Algorithms Fall 2026 lecture notes" uri="http://ozark.hendrix.edu/~yorgey/forest/00JF/" display-uri="00JF" type="local">typing up my lecture notes in Forester</fr:link>). I used to assign weekly problem sets, consisting of a bunch of problems in a PDF that they would have one week to solve and submit.  But scheduling the problem sets around exams and breaks, and making sure they contained appropriate material, was always tricky.  They also didn't adapt well to students who were either very advanced or struggling.  This semester, I am simply publishing a <fr:link href="/~yorgey/forest/00JL/" title="Algorithms problems" uri="http://ozark.hendrix.edu/~yorgey/forest/00JL/" display-uri="00JL" type="local">collection of problems</fr:link>, and the students are responsible for selecting which problems they want to solve.  To help ensure they are making consistent progress, they still have weekly "problem sets" due, but the problem sets do not specify which problems they must solve, but only a required number of problems instead.  This allows me to publish a wider variety of problems, as well as helping students who fall a bit behind continue to make consistent progress without penalizing them for being behind.</html:p>
                <html:p>We'll see how it goes!  I am cautiously optimistic, though of course I'm sure there are things I will learn and change about the system next time.</html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>4</fr:day>
                </fr:date>
                <fr:title text="Missing ICFP">Missing ICFP</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>ICFP was relatively close to me this year (Indianapolis would be about a 9 hour drive, or a short plane flight or two, away), but unfortunately, it happened during the first week of classes.  Since I am the department chair and an advisor for first-year students, that sadly made ICFP a no-go.  Spent the week watching the occasional livestream, reading friends post about ICFP on Mastodon, and just generally feeling like I was missing out.  I am already plotting how I can make it to Nijmegen next year...</html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>4</fr:day>
                </fr:date>
                <fr:title text="Admin corner">Admin corner</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>A bunch of my extra time is taken up right now with two major administrative tasks: completing a self-evaluation, and putting together a hiring request for next year.  Both are due early next week.  I will be very glad when they are both done!
  </html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>4</fr:day>
                </fr:date>
                <fr:title text="Swarm">Swarm</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Only a tiny bit of incremental progress on the integrated help system this week; looking forward to having the above admin stuff done so I can get back to working on this more regularly!</html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>4</fr:day>
                </fr:date>
                <fr:title text="Piano corner">Piano corner</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>I've continued to work on my Chopin waltz project.  I'm also slowly <fr:link href="/~yorgey/forest/00H7/" title="Piano repertoire" uri="http://ozark.hendrix.edu/~yorgey/forest/00H7/" display-uri="00H7" type="local">adding repertoire to my forest</fr:link>.</html:p>
              </fr:mainmatter>
            </fr:tree>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors>
              <fr:author>
                <fr:link href="/~yorgey/forest/brentyorgey/" title="Brent A. Yorgey" uri="http://ozark.hendrix.edu/~yorgey/forest/brentyorgey/" display-uri="brentyorgey" type="local">Brent A. Yorgey</fr:link>
              </fr:author>
            </fr:authors>
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JF/</fr:uri>
            <fr:display-uri>00JF</fr:display-uri>
            <fr:route>/~yorgey/forest/00JF/</fr:route>
            <fr:title text="Algorithms Fall 2026 lecture notes">Algorithms Fall 2026 lecture notes</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>These are my lecture notes for <fr:link href="/~yorgey/forest/00JE/" title="CSCI 382, Algorithms" uri="http://ozark.hendrix.edu/~yorgey/forest/00JE/" display-uri="00JE" type="local">CSCI 382, Algorithms</fr:link> for the Fall 2026 semester.</html:p>
            <html:p>Problems to be solved <fr:link href="/~yorgey/forest/00JL/" title="Algorithms problems" uri="http://ozark.hendrix.edu/~yorgey/forest/00JL/" display-uri="00JL" type="local">can be found here</fr:link>.</html:p>
            <fr:tree show-metadata="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/advanced/</fr:uri>
                <fr:display-uri>advanced</fr:display-uri>
                <fr:route>/~yorgey/forest/advanced/</fr:route>
                <fr:title text="Advanced/optional material">Advanced/optional material</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Some sections of the notes may be marked with a star (★).  This indicates optional, more advanced material which is included for the sake of those who are interested.  Such material may or may not be presented in class and will not be formally assessed.</html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" expanded="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>8</fr:month>
                  <fr:day>6</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JG/</fr:uri>
                <fr:display-uri>00JG</fr:display-uri>
                <fr:route>/~yorgey/forest/00JG/</fr:route>
                <fr:title text="Introduction to POGIL/CSCI 382">Introduction to POGIL/CSCI 382</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>We used <fr:link href="https://hendrix-cs.github.io/csci382/pub/POGIL-intro.pdf" type="external">an activity</fr:link> to introduce <fr:link href="https://pogil.org/" type="external">POGIL</fr:link> and the <fr:link href="https://hendrix-cs.github.io/csci382/" type="external">syllabus for CSCI 382</fr:link>.</html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" expanded="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>8</fr:month>
                  <fr:day>28</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JT/</fr:uri>
                <fr:display-uri>00JT</fr:display-uri>
                <fr:route>/~yorgey/forest/00JT/</fr:route>
                <fr:title text="Why POGIL?">Why POGIL?</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Via <fr:link href="https://hendrix-cs.github.io/csci382/pub/why-POGIL.pdf" type="external">another activity</fr:link>, we learned about the two main aspects of <fr:link href="https://pogil.org/" type="external">POGIL</fr:link>:

<html:ul><html:li><html:em>Guided Inquiry Learning</html:em>: working in a team on an activity designed to guide you through a learning process.</html:li>
  <html:li><html:em>Process-Oriented</html:em>: through the roles, the activities also help you develop <html:em>process skills</html:em> such as communication, critical thinking, information processing, and teamwork.</html:li></html:ul></html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" expanded="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>8</fr:month>
                  <fr:day>26</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JJ/</fr:uri>
                <fr:display-uri>00JJ</fr:display-uri>
                <fr:route>/~yorgey/forest/00JJ/</fr:route>
                <fr:title text="Brute force algorithms">Brute force algorithms</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Introduced via a <fr:link href="https://hendrix-cs.github.io/csci382/pub/brute-force.pdf" type="external">POGIL activity</fr:link>.  Some key takeaways:

<html:ul><html:li>In this class we will consider solving problems with specified inputs and outputs.</html:li>
  <html:li>A <html:em>brute-force</html:em> algorithm is one that simply lists all possible outputs for the given inputs and checks which one has the desired properties.</html:li>
  <html:li>This semester we will consider a lot of clever ways to solve problems faster than brute force.  But that's not always possible.</html:li></html:ul></html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" expanded="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>8</fr:month>
                  <fr:day>31</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JU/</fr:uri>
                <fr:display-uri>00JU</fr:display-uri>
                <fr:route>/~yorgey/forest/00JU/</fr:route>
                <fr:title text="The Euclidean Algorithm">The Euclidean Algorithm</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>The first algorithm we will consider is the famous <html:em><fr:link href="/~yorgey/forest/00ET/" title="GCD and the Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00ET/" display-uri="00ET" type="local">Euclidean algorithm</fr:link></html:em> for finding the <fr:link href="/~yorgey/forest/00EW/" title="GCD" uri="http://ozark.hendrix.edu/~yorgey/forest/00EW/" display-uri="00EW" type="local">greatest common divisor</fr:link> of two integers.  We name it after Euclid, who wrote it down in his classic work on geometry and number theory, <html:em>The Elements</html:em>; however, it has been reinvented in multiple times, places and cultures throughout history.</html:p>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>8</fr:month>
                      <fr:day>31</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JV/</fr:uri>
                    <fr:display-uri>00JV</fr:display-uri>
                    <fr:route>/~yorgey/forest/00JV/</fr:route>
                    <fr:title text="Review: mod and GCD">Review: mod and GCD</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>The material in this section is presented via a <fr:link href="https://hendrix-cs.github.io/csci382/pub/GCD-analysis.pdf" type="external">POGIL activity</fr:link>.</html:p>
                    <html:p>For a refresher on the <fr:tex display="inline"><![CDATA[\mathbin {\mathbf {mod}}]]></fr:tex> operator, see <fr:link href="/~yorgey/forest/00DC/" title="The Division Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00DC/" display-uri="00DC" type="local">these lecture notes from Discrete Math</fr:link>.</html:p>
                    <html:p>For a refresher on GCD, see <fr:link href="/~yorgey/forest/00ET/" title="GCD and the Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00ET/" display-uri="00ET" type="local">these lecture notes</fr:link>.</html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>2</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K2/</fr:uri>
                    <fr:display-uri>00K2</fr:display-uri>
                    <fr:route>/~yorgey/forest/00K2/</fr:route>
                    <fr:title text="The Euclidean Algorithm, recusively and iteratively">The Euclidean Algorithm, recusively and iteratively</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>The material in this section is also presented via a <fr:link href="https://hendrix-cs.github.io/csci382/pub/GCD-analysis.pdf" type="external">POGIL activity</fr:link>.</html:p>
                    <html:p>We will consider two different implementations of the Euclidean
Algorithm.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>2</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K4/</fr:uri>
                        <fr:display-uri>00K4</fr:display-uri>
                        <fr:route>/~yorgey/forest/00K4/</fr:route>
                        <fr:title text="Recursive Euclidean Algorithm">Recursive Euclidean Algorithm</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter><html:p>The first implementation of the Euclidean Algorithm is recursive:</html:p>
  <html:p><fr:resource hash="ff10e425d01737a8ba749bd7c3125be3"><fr:resource-content><html:img src="/~yorgey/forest/ff10e425d01737a8ba749bd7c3125be3.svg" /></fr:resource-content><fr:resource-source type="latex" part="preamble"><![CDATA[\usepackage {../../tex/acode}]]></fr:resource-source><fr:resource-source type="latex" part="body"><![CDATA[\begin {acode}\> GCDR($a$,$b$) = \\
\> \tb \> !if $b = 0$ \\
\>     \> \tb \> !then \> $a$ \\
\>     \>     \> !else \> GCDR($b$, $a \bmod b$)
\end {acode}]]></fr:resource-source></fr:resource></html:p>
</fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>2</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K5/</fr:uri>
                        <fr:display-uri>00K5</fr:display-uri>
                        <fr:route>/~yorgey/forest/00K5/</fr:route>
                        <fr:title text="Iterative Euclidean Algorithm">Iterative Euclidean Algorithm</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter><html:p>The second implementation of the Euclidean Algorithm is iterative:</html:p>
  <html:p><fr:resource hash="ac92ed2ae5db86fadf4c7f062bbc80f5"><fr:resource-content><html:img src="/~yorgey/forest/ac92ed2ae5db86fadf4c7f062bbc80f5.svg" /></fr:resource-content><fr:resource-source type="latex" part="preamble"><![CDATA[\usepackage {../../tex/acode}]]></fr:resource-source><fr:resource-source type="latex" part="body"><![CDATA[\begin {acode}\> GCDI($m$,$n$) = \\
\> \tb \> $a \gets m$ \\
\>     \> $b \gets n$ \\
\>     \> !while $(a \neq 0)$ !and $(b \neq 0)$ \\
\>     \> \tb \> !if $a \leq b$ \\
\>     \>     \> \tb \> !then \> $b \gets b \bmod a$ \\
\>     \>     \>     \> !else \> $a \gets a \bmod b$ \\
\>     \> !if $a = 0$ !then !return $b$ !else !return $a$
\end {acode}]]></fr:resource-source></fr:resource></html:p>
</fr:mainmatter>
                    </fr:tree>
                    <html:p>By trying examples, it seems like both these algorithms produce correct results.  But how can we be sure?  This is an important question, because it's easy to write versions of these algorithms which look very similar, and even work some of the time, but which sometimes crash, loop forever, or return an incorrect result!</html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>2</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K3/</fr:uri>
                    <fr:display-uri>00K3</fr:display-uri>
                    <fr:route>/~yorgey/forest/00K3/</fr:route>
                    <fr:title text="Proving \mathsf {GCDR} correct">Proving <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex> correct</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>We will begin by formally proving the correctness of <fr:link href="/~yorgey/forest/00K4/" title="Recursive Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00K4/" display-uri="00K4" type="local">the recursive
Euclidean Algorithm</fr:link>. But before we can even do that, we have to
back up a bit: what does it even mean for an algorithm to be
"correct"?</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>2</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K6/</fr:uri>
                        <fr:display-uri>00K6</fr:display-uri>
                        <fr:route>/~yorgey/forest/00K6/</fr:route>
                        <fr:title text="Specification vs implementation">Specification vs implementation</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Whenever we implement an algorithm, we have in mind a <html:em>specification</html:em> of what we would like the algorithm to achieve.  This specification could be in the form of a mathematical definition (as in this case), or it could be a brute-force algorithm which "obviously" does what we want, or a table of inputs and outputs, or any other way of precisely defining a relationship between inputs and outputs.  Our algorithm is then an <html:em>implementation</html:em> of this specification, and our job is to show that the specification and implementation match: that is, they produce identical outputs for all possible inputs.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <html:p>In this case, the <html:em>specification</html:em> we have in mind is the mathematical definition of <fr:tex display="inline"><![CDATA[\gcd ]]></fr:tex>; the implementation we have in mind is the <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex> function.  We are starting with <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex> because it's usually much easier to prove things about recursive algorithms than about iterative ones!</html:p>
                    <html:p>In order to prove that <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex> is correct, we first need two small lemmas about the mathematical <fr:tex display="inline"><![CDATA[\gcd ]]></fr:tex> function.  The proofs are included only for completeness—feel free to skip them unless you are interested.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>4</fr:month>
                          <fr:day>16</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00F3/</fr:uri>
                        <fr:display-uri>00F3</fr:display-uri>
                        <fr:route>/~yorgey/forest/00F3/</fr:route>
                        <fr:title text="GCD is commutative">GCD is commutative</fr:title>
                        <fr:taxon>Lemma</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter><html:p><fr:tex display="inline"><![CDATA[\gcd (a,b) = \gcd (b,a)]]></fr:tex>.</html:p>
  
    
    <fr:tree show-metadata="false" toc="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>4</fr:month><fr:day>16</fr:day></fr:date><fr:taxon>Proof</fr:taxon></fr:frontmatter><fr:mainmatter>
  Look at the <fr:link href="/~yorgey/forest/00EW/" title="GCD" uri="http://ozark.hendrix.edu/~yorgey/forest/00EW/" display-uri="00EW" type="local">definition of <fr:tex display="inline"><![CDATA[\gcd ]]></fr:tex></fr:link> and note that <fr:tex display="inline"><![CDATA[\land ]]></fr:tex> is commutative.
</fr:mainmatter></fr:tree>
  
</fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>4</fr:month>
                          <fr:day>16</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00F8/</fr:uri>
                        <fr:display-uri>00F8</fr:display-uri>
                        <fr:route>/~yorgey/forest/00F8/</fr:route>
                        <fr:title text="GCD reduction via mod">GCD reduction via mod</fr:title>
                        <fr:taxon>Theorem</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter><html:p>For all <fr:tex display="inline"><![CDATA[a,b \in  \mathbb {N}]]></fr:tex>, <fr:tex display="inline"><![CDATA[\gcd (a,b) = \gcd (a \mathbin {\mathbf {mod}} b, b)]]></fr:tex>.</html:p>
  
    
    <fr:tree show-metadata="false" toc="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>4</fr:month><fr:day>16</fr:day></fr:date><fr:taxon>Proof</fr:taxon></fr:frontmatter><fr:mainmatter>
  <html:p>By the <fr:link href="/~yorgey/forest/00DC/" title="The Division Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00DC/" display-uri="00DC" type="local">division algorithm</fr:link> write <fr:tex display="inline"><![CDATA[a = bq + r]]></fr:tex>. Then</html:p>

  
  <html:div style="margin-left: 30px"><fr:tex display="inline"><![CDATA[\gcd (a,b)]]></fr:tex></html:div>

  
  <fr:tex display="inline"><![CDATA[= \quad \quad \quad ]]></fr:tex> { Division algorithm, substitute for <fr:tex display="inline"><![CDATA[a]]></fr:tex> }

  
  <html:div style="margin-left: 30px"><fr:tex display="inline"><![CDATA[\gcd (bq+r, b)]]></fr:tex></html:div>

  
  <fr:tex display="inline"><![CDATA[= \quad \quad \quad ]]></fr:tex> { <fr:link href="/~yorgey/forest/00GQ/" title="GCD arguments can be subtracted from the other" uri="http://ozark.hendrix.edu/~yorgey/forest/00GQ/" display-uri="00GQ" type="local">GCD arguments can be subtracted from the other</fr:link>, applied <fr:tex display="inline"><![CDATA[q]]></fr:tex> times }

  
  <html:div style="margin-left: 30px"><fr:tex display="inline"><![CDATA[\gcd (bq+r-bq, b)]]></fr:tex></html:div>

  
  <fr:tex display="inline"><![CDATA[= \quad \quad \quad ]]></fr:tex> { algebra }

  
  <html:div style="margin-left: 30px"><fr:tex display="inline"><![CDATA[\gcd (r, b)]]></fr:tex></html:div>

  
  <fr:tex display="inline"><![CDATA[= \quad \quad \quad ]]></fr:tex> { Definition of <fr:tex display="inline"><![CDATA[\mathbin {\mathbf {mod}}]]></fr:tex> }

  
  <html:div style="margin-left: 30px"><fr:tex display="inline"><![CDATA[\gcd (a \mathbin {\mathbf {mod}} b, b)]]></fr:tex></html:div>

</fr:mainmatter></fr:tree>
  
</fr:mainmatter>
                    </fr:tree>
                    <html:p>Now we can prove that <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex> matches its specification.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>3</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K8/</fr:uri>
                        <fr:display-uri>00K8</fr:display-uri>
                        <fr:route>/~yorgey/forest/00K8/</fr:route>
                        <fr:title text="\mathsf {GCDR} is correct"><fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex> is correct</fr:title>
                        <fr:taxon>Theorem</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter><html:p>For all <fr:tex display="inline"><![CDATA[a,b, \geq  0]]></fr:tex>, <fr:tex display="inline"><![CDATA[\mathsf {GCDR}(a,b) = \gcd (a,b)]]></fr:tex>.</html:p>
  
    
    <fr:tree show-metadata="false" toc="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>3</fr:day></fr:date><fr:taxon>Proof</fr:taxon></fr:frontmatter><fr:mainmatter>
<html:p>By <fr:link href="/~yorgey/forest/00CM/" title="Strong induction" uri="http://ozark.hendrix.edu/~yorgey/forest/00CM/" display-uri="00CM" type="local">(strong) induction</fr:link> on <fr:tex display="inline"><![CDATA[b]]></fr:tex>.</html:p>

<html:ul><html:li>In the base case, when <fr:tex display="inline"><![CDATA[b = 0]]></fr:tex>, <fr:tex display="inline"><![CDATA[\mathsf {GCDR}(a,0) = a]]></fr:tex>, which is indeed the definition of <fr:tex display="inline"><![CDATA[\gcd (a,0)]]></fr:tex>.</html:li>

  <html:li>Now suppose <fr:tex display="inline"><![CDATA[b > 0]]></fr:tex> and that for all <fr:tex display="inline"><![CDATA[a]]></fr:tex>, <fr:tex display="inline"><![CDATA[\mathsf {GCDR}(a,b') = \gcd (a,b')]]></fr:tex> whenever <fr:tex display="inline"><![CDATA[b' < b]]></fr:tex>. In this case <fr:tex display="inline"><![CDATA[\mathsf {GCDR}(a,b) = \mathsf {GCDR}(b, a \bmod  b)]]></fr:tex>. We know <fr:tex display="inline"><![CDATA[a \bmod  b < b]]></fr:tex>, so the induction hypothesis applies (note in particular that the induction hypothesis holds for <html:em>any</html:em> <fr:tex display="inline"><![CDATA[a]]></fr:tex>, and in particular we can pick <fr:tex display="inline"><![CDATA[b]]></fr:tex> as our “<fr:tex display="inline"><![CDATA[a]]></fr:tex>”). We concude that <fr:tex display="inline"><![CDATA[\mathsf {GCDR}(a,b) = \mathsf {GCDR}(b, a \bmod  b) = \gcd (b, a \bmod  b) = \gcd (a \bmod  b, b) = \gcd (a,b)]]></fr:tex>, where the last two steps follow from the fact that <fr:link href="/~yorgey/forest/00F3/" title="GCD is commutative" uri="http://ozark.hendrix.edu/~yorgey/forest/00F3/" display-uri="00F3" type="local"><fr:tex display="inline"><![CDATA[\gcd ]]></fr:tex> is commutative</fr:link> and the <fr:link href="/~yorgey/forest/00F8/" title="GCD reduction via mod" uri="http://ozark.hendrix.edu/~yorgey/forest/00F8/" display-uri="00F8" type="local">previous lemma</fr:link>.</html:li></html:ul>
</fr:mainmatter></fr:tree>
  
</fr:mainmatter>
                    </fr:tree>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>3</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K9/</fr:uri>
                    <fr:display-uri>00K9</fr:display-uri>
                    <fr:route>/~yorgey/forest/00K9/</fr:route>
                    <fr:title text="Proving \mathsf {GCDI} correct">Proving <fr:tex display="inline"><![CDATA[\mathsf {GCDI}]]></fr:tex> correct</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>Now let's prove that <fr:link href="/~yorgey/forest/00K5/" title="Iterative Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00K5/" display-uri="00K5" type="local">the iterative version of the Euclidean
Algorithm</fr:link> is correct as well.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>3</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KB/</fr:uri>
                        <fr:display-uri>00KB</fr:display-uri>
                        <fr:route>/~yorgey/forest/00KB/</fr:route>
                        <fr:title text="\mathsf {GCDI} is correct"><fr:tex display="inline"><![CDATA[\mathsf {GCDI}]]></fr:tex> is correct</fr:title>
                        <fr:taxon>Theorem</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter><html:p><fr:tex display="inline"><![CDATA[\mathsf {GCDI}(a,b) = \gcd (a,b)]]></fr:tex>.</html:p>
  
    
    <fr:tree show-metadata="false" toc="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>3</fr:day></fr:date><fr:taxon>Proof</fr:taxon></fr:frontmatter><fr:mainmatter>
<html:p>Suppose we initially call <fr:tex display="inline"><![CDATA[\mathsf {GCDI}(m,n)]]></fr:tex>. Then we claim the following <html:em>loop invariant</html:em>: each time right before doing the loop check again, <fr:tex display="inline"><![CDATA[\gcd (a,b) = \gcd (m,n)]]></fr:tex>. That is, the <fr:tex display="inline"><![CDATA[\gcd ]]></fr:tex> of the <html:em>current</html:em> values of <fr:tex display="inline"><![CDATA[a]]></fr:tex> and <fr:tex display="inline"><![CDATA[b]]></fr:tex> is always equal to the <fr:tex display="inline"><![CDATA[\gcd ]]></fr:tex> of the <html:em>original</html:em> arguments to <fr:tex display="inline"><![CDATA[\mathsf {GCDI}]]></fr:tex>.</html:p>

<html:p>We prove this by induction on the number of loop executions.</html:p>

<html:ul><html:li>In the base case, before the loop has executed at all, <fr:tex display="inline"><![CDATA[a]]></fr:tex> and <fr:tex display="inline"><![CDATA[b]]></fr:tex> are equal to the original arguments to <fr:tex display="inline"><![CDATA[\mathsf {GCDI}]]></fr:tex>, hence the invariant holds trivially.</html:li>
  <html:li>Otherwise, suppose the invariant held after <fr:tex display="inline"><![CDATA[n]]></fr:tex> loop iterations; we must show it will still hold after one more loop iteration. But this follows from the theorem <fr:link href="/~yorgey/forest/00F8/" title="GCD reduction via mod" uri="http://ozark.hendrix.edu/~yorgey/forest/00F8/" display-uri="00F8" type="local">GCD reduction via mod</fr:link>.</html:li></html:ul>

<html:p>Finally, after the loop ends, we will have either <fr:tex display="inline"><![CDATA[a = 0]]></fr:tex> or <fr:tex display="inline"><![CDATA[b = 0]]></fr:tex>, and we can see that we will return wichever one is nonzero. This correctly returns the <fr:tex display="inline"><![CDATA[\gcd ]]></fr:tex> of <fr:tex display="inline"><![CDATA[a]]></fr:tex> and <fr:tex display="inline"><![CDATA[b]]></fr:tex> since <fr:tex display="inline"><![CDATA[\gcd (a,0) = a]]></fr:tex>. But because of the loop invariant we know that <fr:tex display="inline"><![CDATA[\gcd (a,b) = \gcd (m,n)]]></fr:tex>, hence <fr:tex display="inline"><![CDATA[\mathsf {GCDI}(m,n) = \gcd (m,n)]]></fr:tex>.</html:p>

<html:p>It might seem like we are done, but actually we are not—we do not know that the loop will ever stop!  All we have proved so far is that <html:em>if</html:em> it ever stops, it will deliver the correct value, but that is a big <html:em>if</html:em>.  It's worth remarking that our <fr:link href="/~yorgey/forest/00K8/" title="\mathsf {GCDR} is correct" uri="http://ozark.hendrix.edu/~yorgey/forest/00K8/" display-uri="00K8" type="local">proof of correctness for <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex></fr:link> neatly sidestepped this issue because it was by induction on the size of the arguments to <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex>: the proof that the function returns the correct value, and the proof that the function always stops after a finite amount of time, were both wrapped up into a single argument.  With <fr:tex display="inline"><![CDATA[\mathsf {GCDI}]]></fr:tex>, we must argue these two things separately.</html:p>

<html:p>So, why does <fr:tex display="inline"><![CDATA[\mathsf {GCDI}]]></fr:tex> always stop?  Each time through the loop, either <fr:tex display="inline"><![CDATA[a]]></fr:tex> gets smaller and <fr:tex display="inline"><![CDATA[b]]></fr:tex> stays the same, or <fr:tex display="inline"><![CDATA[b]]></fr:tex> gets smaller and <fr:tex display="inline"><![CDATA[a]]></fr:tex> stays the same: if the loop starts out with <fr:tex display="inline"><![CDATA[a \leq  b]]></fr:tex>, then <fr:tex display="inline"><![CDATA[b]]></fr:tex> gets smaller, since <fr:tex display="inline"><![CDATA[b \bmod  a < a \leq  b]]></fr:tex>. Otherwise <fr:tex display="inline"><![CDATA[a]]></fr:tex> gets smaller, since <fr:tex display="inline"><![CDATA[a \bmod  b < b < a]]></fr:tex>. Since neither ever gets bigger and one gets strictly smaller every loop iteration, one of them must eventually hit <fr:tex display="inline"><![CDATA[0]]></fr:tex>, which will stop the loop.


<fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>3</fr:day></fr:date><fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KC/</fr:uri><fr:display-uri>00KC</fr:display-uri><fr:route>/~yorgey/forest/00KC/</fr:route><fr:title text="★ Pedantic comment about well-founded induction, for those who like that sort of thing"><fr:link href="/~yorgey/forest/advanced/" title="Advanced/optional material" uri="http://ozark.hendrix.edu/~yorgey/forest/advanced/" display-uri="advanced" type="local">★</fr:link> Pedantic comment about well-founded induction, for those who like that sort of thing</fr:title><fr:taxon>Remark</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Technically, this argument that <fr:tex display="inline"><![CDATA[\mathsf {GCDI}]]></fr:tex> always stops is a proof by <html:em>well-founded induction</html:em> on pairs <fr:tex display="inline"><![CDATA[\mathbb {N}^2]]></fr:tex> under the <fr:link href="https://en.wikipedia.org/wiki/Well-founded_relation" type="external">well-founded relation</fr:link> <fr:tex display="block"><![CDATA[\{((a,b), (x,y)) \mid  (a < x \land  b = y) \lor  (a = x \land  b < y)\}.]]></fr:tex></html:p></fr:mainmatter></fr:tree></html:p>

</fr:mainmatter></fr:tree>
  
</fr:mainmatter>
                    </fr:tree>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>4</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KF/</fr:uri>
                    <fr:display-uri>00KF</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KF/</fr:route>
                    <fr:title text="Euclidean Algorithm problems">Euclidean Algorithm problems</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>Problems related to <fr:link href="/~yorgey/forest/00JU/" title="The Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00JU/" display-uri="00JU" type="local">The Euclidean Algorithm</fr:link>, <fr:link href="/~yorgey/forest/00CA/" title="Induction" uri="http://ozark.hendrix.edu/~yorgey/forest/00CA/" display-uri="00CA" type="local">induction</fr:link>, and <fr:link href="/~yorgey/forest/00K3/" title="Proving \mathsf {GCDR} correct" uri="http://ozark.hendrix.edu/~yorgey/forest/00K3/" display-uri="00K3" type="local">proving algorithm correctness</fr:link>.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>8</fr:month>
                          <fr:day>31</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JW/</fr:uri>
                        <fr:display-uri>00JW</fr:display-uri>
                        <fr:route>/~yorgey/forest/00JW/</fr:route>
                        <fr:title text="[GCD1] GCD via factoring vs Euclidean algorithm (2 pts)">[GCD1] GCD via factoring vs Euclidean algorithm (2 pts)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>In class we considered the problem of finding the <html:em>greatest
  common divisor</html:em> of two positive integers.  We explored two ways to
  compute the GCD:

<html:ol><html:li>Factor the two numbers into their unique prime
  factorizations, and find the biggest subset of primes contained in
  both; this is the factorization of the GCD.</html:li>
  <html:li>Run the Euclidean Algorithm.</html:li></html:ol>

In this problem, you will consider the difference between these methods.</html:p>
                        <html:ol><html:li>Use your brain, a calculator, <fr:link href="https://www.wolframalpha.com/" type="external">Wolfram Alpha</fr:link>, and/or some other appropriate computational system to factor <fr:tex display="inline"><![CDATA[170520]]></fr:tex> into its prime factors.</html:li>
  <html:li>Now factor <fr:tex display="inline"><![CDATA[522522]]></fr:tex>, and use the results to find <fr:tex display="inline"><![CDATA[\gcd (170520, 522522)]]></fr:tex> by Method 1.</html:li>
  <html:li>Trace the execution of the Euclidean Algorithm on <fr:tex display="inline"><![CDATA[(170520, 522522)]]></fr:tex>. Compare and contrast the two methods of computing the GCD of these two numbers.</html:li>
  <html:li>Now try to factor the number <fr:tex display="inline"><![CDATA[m]]></fr:tex> shown below, using whatever methods you like (for example, try using Wolfram Alpha). What happens? <fr:tex display="block"><![CDATA[m = 308903627938612635213051732991863520976852479109400884338832430641564115236537.]]></fr:tex>

<html:p>I would be willing to bet some money that you did not succeed in factoring <fr:tex display="inline"><![CDATA[m]]></fr:tex>—though not a large amount, since there do exist algorithms that can factor numbers of this size in a matter of hours or even minutes; but in any case factoring a number with, say, four times as many digits as this would require more like centuries. Factoring is widely believed to be a rather difficult computational problem (the security of your bank account probably depends on it!).</html:p></html:li>
  <html:li>Now, suppose I tell you that there are in fact three prime numbers <fr:tex display="inline"><![CDATA[p]]></fr:tex>, <fr:tex display="inline"><![CDATA[q]]></fr:tex>, and <fr:tex display="inline"><![CDATA[r]]></fr:tex>, such that <fr:tex display="block"><![CDATA[\begin {align*}
    m &= p \cdot  q =
        308903627938612635213051732991863520976852479109400884338832430641564115236537
    \\
    n &= p \cdot  r = 235051426595377535232357646935740625119338466495681619002059053022377525089111
\end {align*}]]></fr:tex> (this is the same number <fr:tex display="inline"><![CDATA[m]]></fr:tex> from part (d)). Find <fr:tex display="inline"><![CDATA[p]]></fr:tex>, <fr:tex display="inline"><![CDATA[q]]></fr:tex>, and <fr:tex display="inline"><![CDATA[r]]></fr:tex>.</html:li>
<html:li>What does this suggest about the relative efficiency of the two methods for computing the GCD?</html:li></html:ol>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>1</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JY/</fr:uri>
                        <fr:display-uri>00JY</fr:display-uri>
                        <fr:route>/~yorgey/forest/00JY/</fr:route>
                        <fr:title text="[K4] Kattis: GCD (1 pt)">[K4] Kattis: GCD (1 pt)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Solve <fr:link href="https://open.kattis.com/problems/gcd" type="external">GCD</fr:link>.  You may not use any built-in GCD function; you must implement the Euclidean Algorithm yourself.</html:p>
                        <html:p>
                          <fr:link href="/~yorgey/forest/00JP/" title="Tips on solving Kattis problems" uri="http://ozark.hendrix.edu/~yorgey/forest/00JP/" display-uri="00JP" type="local">Tips on solving Kattis problems</fr:link>
                        </html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>4</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KE/</fr:uri>
                        <fr:display-uri>00KE</fr:display-uri>
                        <fr:route>/~yorgey/forest/00KE/</fr:route>
                        <fr:title text="Runtime analysis of the Euclidean Algorithm">Runtime analysis of the Euclidean Algorithm</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>In <fr:link href="/~yorgey/forest/00JW/" title="[GCD1] GCD via factoring vs Euclidean algorithm (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00JW/" display-uri="00JW" type="local">[GCD1] GCD via factoring vs Euclidean algorithm (2 pts)</fr:link>, you learned that the Euclidean Algorithm seems much more efficient than factoring; but how efficient is it, exactly? The problems in this section will walk you through a classic analysis of how long the Euclidean Algorithm takes to run on given inputs.  However, the problems are independent; it is possible to do each problem without having done the previous ones.</html:p>
                        <html:p>Throughout this section, when referring to the Euclidean
Algorithm, we will specifically work with the <fr:link href="/~yorgey/forest/00F9/" title="Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00F9/" display-uri="00F9" type="local">recursive
implementation</fr:link> (<html:code>GCDRecA</html:code> from the POGIL activity).
</html:p>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>1</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JZ/</fr:uri>
                            <fr:display-uri>00JZ</fr:display-uri>
                            <fr:route>/~yorgey/forest/00JZ/</fr:route>
                            <fr:title text="[GCD2] GCD of consecutive Fibonacci numbers (2 pts)">[GCD2] GCD of consecutive Fibonacci numbers (2 pts)</fr:title>
                          </fr:frontmatter>
                          <fr:mainmatter>
                            <html:p>Recall the <fr:link href="/~yorgey/forest/00BL/" title="Fibonacci numbers" uri="http://ozark.hendrix.edu/~yorgey/forest/00BL/" display-uri="00BL" type="local">Fibonacci numbers</fr:link>, defined by <fr:tex display="inline"><![CDATA[F_0 = 0]]></fr:tex>, <fr:tex display="inline"><![CDATA[F_1
= 1]]></fr:tex>, and <fr:tex display="inline"><![CDATA[F_{n+2} = F_{n+1} + F_n]]></fr:tex>. That is, the first two Fibonacci
numbers are <fr:tex display="inline"><![CDATA[0, 1]]></fr:tex>, and then each subsequent Fibonacci number is the
sum of the previous two, so the first few are <fr:tex display="inline"><![CDATA[0, 1, 1, 2, 3, 5, 8,
13, \dots ]]></fr:tex></html:p>
                            <html:ol><html:li>Compute <fr:tex display="inline"><![CDATA[F_9]]></fr:tex> and <fr:tex display="inline"><![CDATA[F_{10}]]></fr:tex>, and trace the execution of the <fr:link href="/~yorgey/forest/00F9/" title="Euclidean Algorithm" uri="http://ozark.hendrix.edu/~yorgey/forest/00F9/" display-uri="00F9" type="local">Euclidean Algorithm</fr:link> to compute <fr:tex display="inline"><![CDATA[\gcd (F_{10}, F_9)]]></fr:tex>. What happens?</html:li>
  <html:li>Prove by induction on <fr:tex display="inline"><![CDATA[n]]></fr:tex> that <fr:tex display="inline"><![CDATA[\gcd (F_{n+1}, F_n) = 1]]></fr:tex> for all <fr:tex display="inline"><![CDATA[n \geq  0]]></fr:tex>.</html:li>
  <html:li>Explain why your proof also shows that the Euclidean Algorithm requires <fr:tex display="inline"><![CDATA[n]]></fr:tex> recursive steps to compute <fr:tex display="inline"><![CDATA[\gcd (F_{n+1}, F_n) = 1]]></fr:tex>.</html:li></html:ol>
                          </fr:mainmatter>
                        </fr:tree>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>1</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K0/</fr:uri>
                            <fr:display-uri>00K0</fr:display-uri>
                            <fr:route>/~yorgey/forest/00K0/</fr:route>
                            <fr:title text="[GCD3] Worst-case GCD input (3 pts)">[GCD3] Worst-case GCD input (3 pts)</fr:title>
                          </fr:frontmatter>
                          <fr:mainmatter>
                            <html:p>In fact, more is true: <fr:link href="/~yorgey/forest/00JZ/" title="[GCD2] GCD of consecutive Fibonacci numbers (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00JZ/" display-uri="00JZ" type="local">consecutive Fibonacci numbers</fr:link> <fr:tex display="inline"><![CDATA[(F_{n+1},
F_n)]]></fr:tex> are in some sense a <html:em>worst-case</html:em> input for the Euclidean
Algorithm: they are the <html:em>smallest</html:em> numbers for which the Euclidean
Algorithm needs <fr:tex display="inline"><![CDATA[n]]></fr:tex> steps.</html:p>
                            <html:p>Let <fr:tex display="inline"><![CDATA[S(n)]]></fr:tex> be the following proposition:</html:p>
                            <html:p><fr:tex display="inline"><![CDATA[S(n) =]]></fr:tex> <html:em>For all natural numbers <fr:tex display="inline"><![CDATA[a]]></fr:tex> and <fr:tex display="inline"><![CDATA[b]]></fr:tex>, if <fr:tex display="inline"><![CDATA[a > b]]></fr:tex> and <fr:tex display="inline"><![CDATA[\mathsf {GCDRec}(a,b)]]></fr:tex> makes <fr:tex display="inline"><![CDATA[n]]></fr:tex> recursive calls, then <fr:tex display="inline"><![CDATA[a \geq  F_{n+1}]]></fr:tex> and <fr:tex display="inline"><![CDATA[b \geq  F_n]]></fr:tex>.</html:em></html:p>
                            <html:p>That is, if <fr:tex display="inline"><![CDATA[R(a,b,n)]]></fr:tex> represents the proposition "<fr:tex display="inline"><![CDATA[\mathsf {GCDRec}(a,b)]]></fr:tex> makes <fr:tex display="inline"><![CDATA[n]]></fr:tex> recursive calls", then <fr:tex display="block"><![CDATA[S(n) = \forall  a,b : \mathbb {N}.\; ((a > b) \land  R(a,b,n)) \to  ((a \geq  F_{n+1}) \land  (b \geq  F_n))]]></fr:tex>.</html:p>
                            <html:ol><html:li>Prove <fr:tex display="inline"><![CDATA[\forall  n : \mathbb {N}. S(n)]]></fr:tex> by induction on <fr:tex display="inline"><![CDATA[n]]></fr:tex>:
  <html:ol><html:li>What does the base case <fr:tex display="inline"><![CDATA[S(0)]]></fr:tex> say? Prove it.
    
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Look at the code for <fr:tex display="inline"><![CDATA[\mathsf {GCDR}]]></fr:tex>.  What can you conclude about <fr:tex display="inline"><![CDATA[a]]></fr:tex> and <fr:tex display="inline"><![CDATA[b]]></fr:tex> if it makes zero recursive calls?</html:p></fr:mainmatter></fr:tree></html:li>
    <html:li>Let <fr:tex display="inline"><![CDATA[k]]></fr:tex> be an arbitrary natural number, and prove <fr:tex display="inline"><![CDATA[S(k) \to  S(k+1)]]></fr:tex> by supposing <fr:tex display="inline"><![CDATA[S(k)]]></fr:tex> to be true and proving <fr:tex display="inline"><![CDATA[S(k+1)]]></fr:tex>. You may want to write out <fr:tex display="inline"><![CDATA[S(k)]]></fr:tex> and <fr:tex display="inline"><![CDATA[S(k+1)]]></fr:tex> in full to help you <fr:link href="/~yorgey/forest/0057/" title="Proofs" uri="http://ozark.hendrix.edu/~yorgey/forest/0057/" display-uri="0057" type="local">keep track of what you know and what you are trying to prove</fr:link>.
    
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Show that <fr:tex display="inline"><![CDATA[a \geq  b + a \mathbin {\mathbf {mod}} b]]></fr:tex>.</html:p></fr:mainmatter></fr:tree></html:li></html:ol></html:li>

  <html:li>Explain why the previous result shows that if <fr:tex display="inline"><![CDATA[a \leq  F_{n+1}]]></fr:tex>
  then the Euclidean Algorithm requires at most <fr:tex display="inline"><![CDATA[n]]></fr:tex> steps.</html:li></html:ol>
                          </fr:mainmatter>
                        </fr:tree>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>1</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K1/</fr:uri>
                            <fr:display-uri>00K1</fr:display-uri>
                            <fr:route>/~yorgey/forest/00K1/</fr:route>
                            <fr:title text="[GCD4] Fibonacci number size (3 pts)">[GCD4] Fibonacci number size (3 pts)</fr:title>
                          </fr:frontmatter>
                          <fr:mainmatter>
                            <html:p>How big are <fr:link href="/~yorgey/forest/00BL/" title="Fibonacci numbers" uri="http://ozark.hendrix.edu/~yorgey/forest/00BL/" display-uri="00BL" type="local">Fibonacci numbers</fr:link>? Let’s find out:

<html:ol><html:li>Solve <fr:tex display="inline"><![CDATA[x^2 = x + 1]]></fr:tex> for <fr:tex display="inline"><![CDATA[x]]></fr:tex> and call the positive solution <fr:tex display="inline"><![CDATA[\varphi ]]></fr:tex> (this is often known as the <html:em>golden ratio</html:em>) and the negative solution <fr:tex display="inline"><![CDATA[\hat {\varphi }]]></fr:tex>.</html:li>
  <html:li>Explain why we know that <fr:tex display="inline"><![CDATA[\varphi ^2 = \varphi  + 1]]></fr:tex> and <fr:tex display="inline"><![CDATA[\hat {\varphi }^2 = \hat {\varphi } + 1]]></fr:tex>.
  
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Your answer should be one sentence!</html:p></fr:mainmatter></fr:tree></html:li>
  <html:li>Show that <fr:tex display="inline"><![CDATA[\varphi ^{k+2} = \varphi ^{k+1}
    + \varphi ^k]]></fr:tex> for all <fr:tex display="inline"><![CDATA[k \geq  0]]></fr:tex> (by starting with <fr:tex display="inline"><![CDATA[\varphi ^2 =
    \varphi  + 1]]></fr:tex> and multiplying both sides by <fr:tex display="inline"><![CDATA[\varphi ^k]]></fr:tex>). Note that the same is also true with <fr:tex display="inline"><![CDATA[\hat {\varphi }]]></fr:tex> in place of <fr:tex display="inline"><![CDATA[\varphi ]]></fr:tex>.</html:li>
  <html:li>Now prove by induction on <fr:tex display="inline"><![CDATA[n]]></fr:tex> that <fr:tex display="inline"><![CDATA[F_n = \frac {1}{\sqrt  5}(\varphi ^n -
  \hat {\varphi }^n)]]></fr:tex>.
  
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>Don’t forget that you need two base cases; you will want to show that <fr:tex display="inline"><![CDATA[\varphi  - \hat {\varphi } = \sqrt  5]]></fr:tex>.</html:p></fr:mainmatter></fr:tree></html:li>
  <html:li>
    Conclude that <fr:tex display="inline"><![CDATA[F_n \approx  \varphi ^n/\sqrt  5]]></fr:tex>.
    
  
  <fr:tree show-metadata="false" expanded="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>1</fr:day></fr:date><fr:taxon>Hint</fr:taxon></fr:frontmatter><fr:mainmatter><html:p>What can you say about <fr:tex display="inline"><![CDATA[\hat {\varphi }^n]]></fr:tex> as <fr:tex display="inline"><![CDATA[n]]></fr:tex> gets large?</html:p></fr:mainmatter></fr:tree></html:li></html:ol></html:p>
                          </fr:mainmatter>
                        </fr:tree>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>4</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KD/</fr:uri>
                            <fr:display-uri>00KD</fr:display-uri>
                            <fr:route>/~yorgey/forest/00KD/</fr:route>
                            <fr:title text="[GCD5] Time complexity of the Euclidean Algorithm (logarithm review) (2 pts)">[GCD5] Time complexity of the Euclidean Algorithm (logarithm review) (2 pts)</fr:title>
                          </fr:frontmatter>
                          <fr:mainmatter>
                            <html:p>Suppose we want to run the Euclidean Algorithm to compute <fr:tex display="inline"><![CDATA[\gcd (a,b)]]></fr:tex>, assuming <fr:tex display="inline"><![CDATA[a > b]]></fr:tex>. Let <fr:tex display="inline"><![CDATA[F_{n+1}]]></fr:tex> be the smallest Fibonacci number which is greater than or equal to <fr:tex display="inline"><![CDATA[a]]></fr:tex>. Then we know from <fr:link href="/~yorgey/forest/00K1/" title="[GCD4] Fibonacci number size (3 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00K1/" display-uri="00K1" type="local">the previous problem</fr:link> that the Euclidean Algorithm takes at most <fr:tex display="inline"><![CDATA[n]]></fr:tex> steps to run, with the worst case being when <fr:tex display="inline"><![CDATA[a = F_{n+1}]]></fr:tex>. We want to figure out how <fr:tex display="inline"><![CDATA[n]]></fr:tex> relates to <fr:tex display="inline"><![CDATA[a]]></fr:tex>.</html:p>
                            <html:p>Starting from <fr:tex display="inline"><![CDATA[a = F_{n+1}]]></fr:tex> (since this is the <html:em>worst</html:em> case), and using the result from <fr:link href="/~yorgey/forest/00K1/" title="[GCD4] Fibonacci number size (3 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00K1/" display-uri="00K1" type="local">the previous problem</fr:link>, namely, that <fr:tex display="inline"><![CDATA[F_n \approx  \varphi ^n/\sqrt  5]]></fr:tex>, solve (approximately) for <fr:tex display="inline"><![CDATA[n]]></fr:tex> in terms of <fr:tex display="inline"><![CDATA[a]]></fr:tex>. Your final answer should be of the form <fr:tex display="block"><![CDATA[n \approx  k_1 \log _{10} a + k_2]]></fr:tex> for suitable constants <fr:tex display="inline"><![CDATA[k_1]]></fr:tex> and <fr:tex display="inline"><![CDATA[k_2]]></fr:tex>; you should give <fr:tex display="inline"><![CDATA[k_1]]></fr:tex> and <fr:tex display="inline"><![CDATA[k_2]]></fr:tex> in approximate, decimal form. Conclude that the Euclidean Algorithm requires, <html:em>in the worst case</html:em>, a number of steps proportional to the number of digits in the base-ten representation of <fr:tex display="inline"><![CDATA[a]]></fr:tex>.</html:p>
                          </fr:mainmatter>
                        </fr:tree>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>4</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KG/</fr:uri>
                        <fr:display-uri>00KG</fr:display-uri>
                        <fr:route>/~yorgey/forest/00KG/</fr:route>
                        <fr:title text="[I2] Exponentiation (3 pts)">[I2] Exponentiation (3 pts)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Write a recursive algorithm which, given a real number <fr:tex display="inline"><![CDATA[b]]></fr:tex> and a natural number <fr:tex display="inline"><![CDATA[e]]></fr:tex>, computes the power <fr:tex display="inline"><![CDATA[b^e]]></fr:tex>.  Prove that your algorithm is correct.</html:p>
                        <html:p>You may express your algorithm using appropriate <fr:link href="/~yorgey/forest/00KH/" title="Pseudocode" uri="http://ozark.hendrix.edu/~yorgey/forest/00KH/" display-uri="00KH" type="local">pseudocode</fr:link>, or you may implement it in a real programming language; either one is fine.  You may use addition, subtraction, multiplication, and division, but you may not use any kind of built-in exponentiation operation.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>8</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KI/</fr:uri>
                        <fr:display-uri>00KI</fr:display-uri>
                        <fr:route>/~yorgey/forest/00KI/</fr:route>
                        <fr:title text="[I3] The Jellybean Game (3 pts)">[I3] The Jellybean Game (3 pts)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>The jellybean game is a game for two players. There is a row of <fr:tex display="inline"><![CDATA[n]]></fr:tex> jars, numbered <fr:tex display="inline"><![CDATA[1]]></fr:tex> to <fr:tex display="inline"><![CDATA[n]]></fr:tex> from left to right, each of which starts out containing some number of jellybeans (possibly zero). We assume that these are magical jars which can hold an <html:em>unlimited number</html:em> of jellybeans, so we don’t have to worry about the jars getting too full. (Note, however, that the jars cannot hold <html:em>infinitely</html:em> many beans—each jar must always have some finite number of jellybeans in it, but that number can be as big as we want.) We also assume that there is an unlimited supply of extra jellybeans (such as a jellybean factory or a magical jellybean-pooping unicorn).</html:p>
                        <html:p>The players alternate turns. On a player’s turn, she must:
<html:ol><html:li>Pick a nonempty jar, call it jar <fr:tex display="inline"><![CDATA[k]]></fr:tex>.</html:li>
  <html:li><html:em>Remove</html:em> one jellybean from jar <fr:tex display="inline"><![CDATA[k]]></fr:tex>.</html:li>
  <html:li><html:em>Add</html:em> as many jellybeans as she wants (possibly zero) to each of the jars <fr:tex display="inline"><![CDATA[1 \dots  (k-1)]]></fr:tex> to the left of her chosen jar.</html:li></html:ol></html:p>
                        <html:p>For example, suppose there are five jars which currently hold <fr:tex display="block"><![CDATA[1 \quad  3 \quad  0 \quad  2 \quad  6.]]></fr:tex> One possible valid turn is to pick jar 4 and remove one jellybean from it, then add 6, 29, and one billion jellybeans to jars <fr:tex display="inline"><![CDATA[1]]></fr:tex>, <fr:tex display="inline"><![CDATA[2]]></fr:tex>, and <fr:tex display="inline"><![CDATA[3]]></fr:tex> respectively, resulting in <fr:tex display="block"><![CDATA[7 \quad  32 \quad  10^9 \quad  1 \quad  6.]]></fr:tex></html:p>
                        <html:p>The winner is the player who removes the last jellybean. Put another way, the loser is the first player who is unable to move because all the jars are empty.</html:p>
                        <html:ol><html:li>Prove that the jellybean game always ends eventually. That is, even if the players conspire to try to make the game last forever, they cannot, as long as they follow the rules. (Of course, they certainly can make the game take a very, <html:em>very</html:em> long time...)</html:li>
  <html:li>Describe a winning strategy for the jellybean game.  From which positions is the first player guaranteed to win, as long as they play perfectly?  What strategy should the first player follow in order to guarantee a win, if a win is possible?</html:li></html:ol>
                      </fr:mainmatter>
                    </fr:tree>
                  </fr:mainmatter>
                </fr:tree>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" expanded="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>3</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00K7/</fr:uri>
                <fr:display-uri>00K7</fr:display-uri>
                <fr:route>/~yorgey/forest/00K7/</fr:route>
                <fr:title text="Asymptotic Analysis">Asymptotic Analysis</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>The basic concepts of asymptotic analysis are introduced in a <fr:link href="https://hendrix-cs.github.io/csci382/pub/AA-intro.pdf" type="external">POGIL activity</fr:link>.</html:p>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KN/</fr:uri>
                    <fr:display-uri>00KN</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KN/</fr:route>
                    <fr:title text="Why asymptotic analysis?">Why asymptotic analysis?</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>Why should we examine problems analytically at all? For example, why not just run programs and use a stopwatch to compare them?</html:p>
                    <html:ul><html:li>Actually running programs might take too long!</html:li>
<html:li>The analysis lets us analyze problems for all input sizes at once, rather than having to gather data points.</html:li>
<html:li>The analysis is independent of the algorithm implementation, the language in which the program is implemented, and the architecture in which the program is run. We insulate ourselves to all these variables.</html:li>
<html:li>Theoretically efficient almost always implies practical efficiency.</html:li></html:ul>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KR/</fr:uri>
                    <fr:display-uri>00KR</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KR/</fr:route>
                    <fr:title text="Intuition and motivation for big-O">Intuition and motivation for big-O</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>From now on, we’ll assume that <fr:tex display="inline"><![CDATA[n \geq  0]]></fr:tex>, <fr:tex display="inline"><![CDATA[T(n) \geq  0]]></fr:tex>, and that <fr:tex display="inline"><![CDATA[T]]></fr:tex> represents a generic function <fr:tex display="inline"><![CDATA[\mathbb {N} \to  \mathbb {R}]]></fr:tex> representing, say, the amount of time an algorithm takes to run on an input of size <fr:tex display="inline"><![CDATA[n]]></fr:tex>. Recall that big-O is “like <fr:tex display="inline"><![CDATA[\leq ]]></fr:tex>”, big-Omega is “like <fr:tex display="inline"><![CDATA[\geq ]]></fr:tex>”, and big-Theta is “like <fr:tex display="inline"><![CDATA[=]]></fr:tex>”. However, if we were to define, say, big-O as “<fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[O(n^2)]]></fr:tex> if <fr:tex display="inline"><![CDATA[T(n) \leq  n^2]]></fr:tex>”, that would be too restrictive for us. For one thing, we don’t want it to matter what computer we run things on. What if it takes <fr:tex display="inline"><![CDATA[2n^2]]></fr:tex>, or <fr:tex display="inline"><![CDATA[3n^2]]></fr:tex>? Those are not actually <fr:tex display="inline"><![CDATA[\leq 
n^2]]></fr:tex>, but we want them to be considered “the same as” <fr:tex display="inline"><![CDATA[n^2]]></fr:tex>. Also, we don’t really care what happens for small values of <fr:tex display="inline"><![CDATA[n]]></fr:tex> (after all, for small values we could just run the algorithm ourselves, by hand), so it’s not necessary that <fr:tex display="inline"><![CDATA[T(n) \leq  n^2]]></fr:tex> (or some multiple) for <html:em>all</html:em> values of <fr:tex display="inline"><![CDATA[n]]></fr:tex>, only that it be so <html:em>eventually</html:em>. These considerations lead to the following formal definition.</html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KO/</fr:uri>
                    <fr:display-uri>00KO</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KO/</fr:route>
                    <fr:title text="Big-O">Big-O</fr:title>
                    <fr:taxon>Definition</fr:taxon>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p><fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[O(g(n))]]></fr:tex> iff there exists a real constant <fr:tex display="inline"><![CDATA[c > 0]]></fr:tex> and a natural number <fr:tex display="inline"><![CDATA[n_0 \geq  0]]></fr:tex> such that for all <fr:tex display="inline"><![CDATA[n \geq  n_0]]></fr:tex>, <fr:tex display="block"><![CDATA[T(n) \leq  c \cdot  g(n).]]></fr:tex></html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KP/</fr:uri>
                    <fr:display-uri>00KP</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KP/</fr:route>
                    <fr:title text="Big-Omega">Big-Omega</fr:title>
                    <fr:taxon>Definition</fr:taxon>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>The definition of big-Omega is identical, except that we use <fr:tex display="inline"><![CDATA[\geq ]]></fr:tex> in place of <fr:tex display="inline"><![CDATA[\leq ]]></fr:tex>:</html:p>
                    <html:p><fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[\Omega (g(n))]]></fr:tex> iff there exists a real constant <fr:tex display="inline"><![CDATA[c > 0]]></fr:tex> and a natural number <fr:tex display="inline"><![CDATA[n_0 \geq  0]]></fr:tex> such that for all <fr:tex display="inline"><![CDATA[n \geq  n_0]]></fr:tex>, <fr:tex display="block"><![CDATA[T(n) \geq  c \cdot  g(n).]]></fr:tex></html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KQ/</fr:uri>
                    <fr:display-uri>00KQ</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KQ/</fr:route>
                    <fr:title text="Big-Theta">Big-Theta</fr:title>
                    <fr:taxon>Definition</fr:taxon>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p><fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[\Theta (g(n))]]></fr:tex> iff <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is both <fr:tex display="inline"><![CDATA[O(g(n))]]></fr:tex> and <fr:tex display="inline"><![CDATA[\Omega (g(n))]]></fr:tex>.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>9</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KS/</fr:uri>
                        <fr:display-uri>00KS</fr:display-uri>
                        <fr:route>/~yorgey/forest/00KS/</fr:route>
                        <fr:taxon>Remark</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Note this is <html:em>not</html:em> the same as replacing the <fr:tex display="inline"><![CDATA[\leq ]]></fr:tex> in the <fr:link href="/~yorgey/forest/00KR/" title="Intuition and motivation for big-O" uri="http://ozark.hendrix.edu/~yorgey/forest/00KR/" display-uri="00KR" type="local">definition of big-O</fr:link> with an <fr:tex display="inline"><![CDATA[=]]></fr:tex> sign!  In that case, <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> would have to be <html:em>exactly equal to</html:em> some constant multiple of <fr:tex display="inline"><![CDATA[g(n)]]></fr:tex>, which would be much too restrictive. In the actual definition, <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> must merely fall <html:em>in between</html:em> two <html:em>different</html:em> constant multiples of <fr:tex display="inline"><![CDATA[g(n)]]></fr:tex>.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KX/</fr:uri>
                    <fr:display-uri>00KX</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KX/</fr:route>
                    <fr:title text="Little-o">Little-o</fr:title>
                    <fr:taxon>Definition</fr:taxon>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p><fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(g(n))]]></fr:tex> iff <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[O(g(n))]]></fr:tex> but not <fr:tex display="inline"><![CDATA[\Theta (g(n))]]></fr:tex>.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>9</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KY/</fr:uri>
                        <fr:display-uri>00KY</fr:display-uri>
                        <fr:route>/~yorgey/forest/00KY/</fr:route>
                        <fr:taxon>Remark</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>In other words, intuitively, <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(g(n))]]></fr:tex> if it grows strictly more slowly than <fr:tex display="inline"><![CDATA[g(n)]]></fr:tex>.  For example, <fr:tex display="inline"><![CDATA[n+2]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(n^2)]]></fr:tex>.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KT/</fr:uri>
                    <fr:display-uri>00KT</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KT/</fr:route>
                    <fr:taxon>Example</fr:taxon>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>Consider <fr:tex display="inline"><![CDATA[T(n) = 3n^2 + 17n + 8]]></fr:tex>.  To show that this is <fr:tex display="inline"><![CDATA[O(n^2)]]></fr:tex> according to the definition, we can reason as follows:

  <fr:tex display="block"><![CDATA[\begin {align*}
    T(n) &= 3n^2 + 17n + 8 \\
         &\leq  3n^2 + 17n^2 + 8n^2 \quad  (n \geq  1) \\
         &= 28n^2
  \end {align*}]]></fr:tex>

  So we can choose <fr:tex display="inline"><![CDATA[c = 28]]></fr:tex> and <fr:tex display="inline"><![CDATA[n_0 = 1]]></fr:tex>, which satisfies the definition, so <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[O(n^2)]]></fr:tex>. (In fact we could also pick <fr:tex display="inline"><![CDATA[c = 4]]></fr:tex> along with a bigger <fr:tex display="inline"><![CDATA[n_0]]></fr:tex>.)</html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KU/</fr:uri>
                    <fr:display-uri>00KU</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KU/</fr:route>
                    <fr:title text="Big-O in the real world">Big-O in the real world</fr:title>
                    <fr:taxon>Remark</fr:taxon>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>A lot of the time people use big-<fr:tex display="inline"><![CDATA[O]]></fr:tex> when what they really mean is <fr:tex display="inline"><![CDATA[\Theta ]]></fr:tex>. In this class we will be very careful to use them properly. It’s useful to have all of them at our disposal. For some problems we know exactly how fast they can be solved, so we use <fr:tex display="inline"><![CDATA[\Theta ]]></fr:tex>. For some problems we know some <fr:tex display="inline"><![CDATA[O]]></fr:tex> and some <fr:tex display="inline"><![CDATA[\Omega ]]></fr:tex> but they are not the same. For example, matrix multiplication: we know it must take <fr:tex display="inline"><![CDATA[\Omega (n^2)]]></fr:tex> time, and there are algorithms that show it is <fr:tex display="inline"><![CDATA[O(n^{2.37\dots })]]></fr:tex>, but no one knows what the theoretical limit is (we will look at matrix multiplication later in the semester).</html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KV/</fr:uri>
                    <fr:display-uri>00KV</fr:display-uri>
                    <fr:route>/~yorgey/forest/00KV/</fr:route>
                    <fr:title text="Limit theorems">Limit theorems</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>It is usually really annoying to use these definitions directly.
Instead we can often compare rates of growth using limits.  Note in the below that <fr:tex display="inline"><![CDATA[L < \infty ]]></fr:tex> is used as a shorthand to mean "the limit <fr:tex display="inline"><![CDATA[L]]></fr:tex> exists and does not diverge to <fr:tex display="inline"><![CDATA[\infty ]]></fr:tex>", and <fr:tex display="inline"><![CDATA[L = \infty ]]></fr:tex> is used as a shorthand to mean "the limit <fr:tex display="inline"><![CDATA[L]]></fr:tex> diverges to <fr:tex display="inline"><![CDATA[\infty ]]></fr:tex>".</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>9</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KW/</fr:uri>
                        <fr:display-uri>00KW</fr:display-uri>
                        <fr:route>/~yorgey/forest/00KW/</fr:route>
                        <fr:title text="Asymptotic bounds via limits">Asymptotic bounds via limits</fr:title>
                        <fr:taxon>Theorem</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>
                          <html:ul><html:li>If <fr:tex display="inline"><![CDATA[0 \leq  \lim _{n \to  \infty } T(n)/g(n) < \infty ]]></fr:tex> then <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[O(g(n))]]></fr:tex>.</html:li>
  <html:li>If <fr:tex display="inline"><![CDATA[0 < \lim _{n \to  \infty } T(n)/g(n) \leq  \infty ]]></fr:tex> then <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[\Omega (g(n))]]></fr:tex>.</html:li>
  <html:li>If <fr:tex display="inline"><![CDATA[0 < \lim _{n \to  \infty } T(n)/g(n) < \infty ]]></fr:tex> then <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[\Theta (g(n))]]></fr:tex>.</html:li>
  <html:li>If <fr:tex display="inline"><![CDATA[\lim _{n \to  \infty } T(n)/g(n) = 0]]></fr:tex> then <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[\Theta (g(n))]]></fr:tex>.</html:li></html:ul>
                        </html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>9</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00KZ/</fr:uri>
                        <fr:display-uri>00KZ</fr:display-uri>
                        <fr:route>/~yorgey/forest/00KZ/</fr:route>
                        <fr:taxon>Remark</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Note that the converse is not true, since, for example, <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> might be <fr:tex display="inline"><![CDATA[O(g(n))]]></fr:tex> even if the limit does not exist. As a counterexample, let <fr:tex display="inline"><![CDATA[T(n) = 0]]></fr:tex> when <fr:tex display="inline"><![CDATA[n]]></fr:tex> is even, and <fr:tex display="inline"><![CDATA[1]]></fr:tex> when <fr:tex display="inline"><![CDATA[n]]></fr:tex> is odd. Then <fr:tex display="inline"><![CDATA[T(n)]]></fr:tex> is <fr:tex display="inline"><![CDATA[O(1)]]></fr:tex> but <fr:tex display="inline"><![CDATA[\lim  T(n)/1]]></fr:tex> does not exist. But typically this won’t be an issue with the functions we will see in this class!</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>9</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L0/</fr:uri>
                    <fr:display-uri>00L0</fr:display-uri>
                    <fr:route>/~yorgey/forest/00L0/</fr:route>
                    <fr:title text="Arithmetic with big-O">Arithmetic with big-O</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>The following properties hold for <fr:tex display="inline"><![CDATA[\Omega ]]></fr:tex> and <fr:tex display="inline"><![CDATA[\Theta ]]></fr:tex> as well.</html:p>
                    <html:ul><html:li><fr:tex display="inline"><![CDATA[k O(f) = O(f)]]></fr:tex> when <fr:tex display="inline"><![CDATA[k]]></fr:tex> is a constant, <html:em>i.e.</html:em> does not depend on <fr:tex display="inline"><![CDATA[n]]></fr:tex></html:li>
<html:li><fr:tex display="inline"><![CDATA[O(f) + O(g) = O(\max (f,g))]]></fr:tex> (running algorithms in <html:em>sequence</html:em>)</html:li>
<html:li><fr:tex display="inline"><![CDATA[O(f) O(g) = O(fg)]]></fr:tex> (running <html:em>nested</html:em> algorithms)</html:li></html:ul>
                    <html:p>For example, <fr:tex display="inline"><![CDATA[O(3n^2 + 17n + 8) = O(3n^2) + O(17n) + O(8) = O(n^2) +
O(n) + O(1) = O(n^2)]]></fr:tex>.</html:p>
                  </fr:mainmatter>
                </fr:tree>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>10</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L1/</fr:uri>
                    <fr:display-uri>00L1</fr:display-uri>
                    <fr:route>/~yorgey/forest/00L1/</fr:route>
                    <fr:title text="Time Complexity Zoo">Time Complexity Zoo</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>We now present a “complexity zoo”, with examples of things having each common asymptotic time complexity, with some relevant facts interspersed. Our zoo will be ordered from smallest to biggest; that is, each entry will be <fr:link href="/~yorgey/forest/00KX/" title="Little-o" uri="http://ozark.hendrix.edu/~yorgey/forest/00KX/" display-uri="00KX" type="local">little-o</fr:link> of the next thing. For each <fr:tex display="inline"><![CDATA[\Theta (f(n))]]></fr:tex>, we will also record the largest <fr:tex display="inline"><![CDATA[n]]></fr:tex> such that we can process an input of size <fr:tex display="inline"><![CDATA[n]]></fr:tex> using a <fr:tex display="inline"><![CDATA[\Theta (f(n))]]></fr:tex>-time algorithm in approximately 1 second, assuming we can do <fr:tex display="inline"><![CDATA[10^8]]></fr:tex> operations per second.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>10</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L2/</fr:uri>
                        <fr:display-uri>00L2</fr:display-uri>
                        <fr:route>/~yorgey/forest/00L2/</fr:route>
                        <fr:title text="\Theta (1): constant (any input)"><fr:tex display="inline"><![CDATA[\Theta (1)]]></fr:tex>: constant (any input)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>A <fr:tex display="inline"><![CDATA[\Theta (1)]]></fr:tex> or <html:em>constant time</html:em> algorithm is one whose running time <html:em>does not depend</html:em> on the size of its input. If we have an algorithm that takes <fr:tex display="inline"><![CDATA[\Theta (1)]]></fr:tex>, we can obviously process arbitrary-sized inputs in less than one second.</html:p>
                        <html:p>Examples of <fr:tex display="inline"><![CDATA[\Theta (1)]]></fr:tex> operations include:

<html:ul><html:li>Access an arbitrary index in an array</html:li>
<html:li>Push to or pop from the top of a stack</html:li>
<html:li>Add to or remove from the <html:em>end</html:em> of an extensible list (<html:em>e.g.</html:em> <html:code>ArrayList</html:code> in Java; Python lists)</html:li>
<html:li>Insert, update, or remove from a hash table (<html:em>e.g.</html:em> <html:code>set</html:code> + dictionaries in Python; <html:code>HashSet</html:code>/<html:code>HashMap</html:code> in Java)</html:li>
<html:li>Add to or remove from <html:em>either</html:em> end of a <html:em>deque</html:em> (<html:strong>d</html:strong>ouble-<html:strong>e</html:strong>nded <html:strong>que</html:strong>ue)</html:li>
<html:li>Arithmetic (usually!  sort of!)</html:li></html:ul></html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>10</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L3/</fr:uri>
                        <fr:display-uri>00L3</fr:display-uri>
                        <fr:route>/~yorgey/forest/00L3/</fr:route>
                        <fr:title text="\Theta (\lg  n): logarithmic (unimaginably large inputs)"><fr:tex display="inline"><![CDATA[\Theta (\lg  n)]]></fr:tex>: logarithmic (unimaginably large inputs)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>We say something is <html:em>logarithmic</html:em> if it is proportional to <fr:tex display="inline"><![CDATA[\log  n]]></fr:tex> for inputs of size <fr:tex display="inline"><![CDATA[n]]></fr:tex>.</html:p>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>10</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L4/</fr:uri>
                            <fr:display-uri>00L4</fr:display-uri>
                            <fr:route>/~yorgey/forest/00L4/</fr:route>
                            <fr:title text="\lg ">
                              <fr:tex display="inline"><![CDATA[\lg ]]></fr:tex>
                            </fr:title>
                            <fr:taxon>Notation</fr:taxon>
                          </fr:frontmatter>
                          <fr:mainmatter>
                            <html:p>We will use <fr:tex display="inline"><![CDATA[\lg  n]]></fr:tex> as an abbreviation for <fr:tex display="inline"><![CDATA[\log _2 n]]></fr:tex>.  Two is by far the most common and useful base for logarithms when talking about computers.</html:p>
                          </fr:mainmatter>
                        </fr:tree>
                        <html:p>If we have an algorithm that takes <fr:tex display="inline"><![CDATA[\Theta (\lg  n)]]></fr:tex> time, we could use it to process inputs of size <fr:tex display="inline"><![CDATA[2^{10^8}]]></fr:tex> in one second, which is unimaginably large.</html:p>
                        <html:p>Examples of things that are <fr:tex display="inline"><![CDATA[\Theta (\lg  n)]]></fr:tex>:

<html:ul><html:li>Binary search</html:li>
  <html:li>The height of a balanced binary tree with <fr:tex display="inline"><![CDATA[n]]></fr:tex> nodes</html:li>
  <html:li>The number of bits needed to represent <fr:tex display="inline"><![CDATA[n]]></fr:tex></html:li></html:ul></html:p>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>11</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L9/</fr:uri>
                            <fr:display-uri>00L9</fr:display-uri>
                            <fr:route>/~yorgey/forest/00L9/</fr:route>
                            <fr:title text="Logarithm base doesn't matter to \Theta ">Logarithm base doesn't matter to <fr:tex display="inline"><![CDATA[\Theta ]]></fr:tex></fr:title>
                            <fr:taxon>Theorem</fr:taxon>
                          </fr:frontmatter>
                          <fr:mainmatter><html:p><fr:tex display="inline"><![CDATA[\Theta (\log _a n) = \Theta (\log _b n)]]></fr:tex> for all positive real numbers <fr:tex display="inline"><![CDATA[a]]></fr:tex> and <fr:tex display="inline"><![CDATA[b]]></fr:tex>.  In other words, up to <fr:tex display="inline"><![CDATA[\Theta ]]></fr:tex>, the base of a logarithm doesn't matter; <fr:tex display="inline"><![CDATA[\Theta (\log  n)]]></fr:tex>, <fr:tex display="inline"><![CDATA[\Theta (\lg  n)]]></fr:tex>, <fr:tex display="inline"><![CDATA[\Theta (\ln  n)]]></fr:tex>, <html:em>etc.</html:em> are all the same.</html:p>
  
    
    <fr:tree show-metadata="false" toc="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>11</fr:day></fr:date><fr:taxon>Proof</fr:taxon></fr:frontmatter><fr:mainmatter><fr:link href="/~yorgey/forest/00KL/" title="[O3] Some asymptotic properties (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00KL/" display-uri="00KL" type="local">Homework</fr:link>.</fr:mainmatter></fr:tree>
  
</fr:mainmatter>
                        </fr:tree>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>11</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00L8/</fr:uri>
                            <fr:display-uri>00L8</fr:display-uri>
                            <fr:route>/~yorgey/forest/00L8/</fr:route>
                            <fr:title text="Logarithms grow more slowly than any power">Logarithms grow more slowly than any power</fr:title>
                            <fr:taxon>Theorem</fr:taxon>
                          </fr:frontmatter>
                          <fr:mainmatter><html:p><fr:tex display="inline"><![CDATA[\log _b n]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(n^x)]]></fr:tex> for all <fr:tex display="inline"><![CDATA[x > 0]]></fr:tex> and any <fr:tex display="inline"><![CDATA[b > 1]]></fr:tex>.</html:p>
  
    
    <fr:tree show-metadata="false" toc="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>11</fr:day></fr:date><fr:taxon>Proof</fr:taxon></fr:frontmatter><fr:mainmatter><fr:link href="/~yorgey/forest/00KL/" title="[O3] Some asymptotic properties (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00KL/" display-uri="00KL" type="local">Homework</fr:link>.</fr:mainmatter></fr:tree>
  
</fr:mainmatter>
                        </fr:tree>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>11</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LA/</fr:uri>
                            <fr:display-uri>00LA</fr:display-uri>
                            <fr:route>/~yorgey/forest/00LA/</fr:route>
                            <fr:title text="\lg  n is much closer to 1 than n"><fr:tex display="inline"><![CDATA[\lg  n]]></fr:tex> is much closer to 1 than <fr:tex display="inline"><![CDATA[n]]></fr:tex></fr:title>
                            <fr:taxon>Remark</fr:taxon>
                          </fr:frontmatter>
                          <fr:mainmatter>
                            <html:p>This is somewhat surprising! <fr:tex display="inline"><![CDATA[\Theta (\lg  n)]]></fr:tex> is actually smaller than <fr:tex display="inline"><![CDATA[n]]></fr:tex> to <html:em>any</html:em> positive power: even <fr:tex display="inline"><![CDATA[\Theta (\sqrt [15]{n})]]></fr:tex> or whatever. <fr:tex display="inline"><![CDATA[\Theta (\lg  n)]]></fr:tex> is not “halfway between” <fr:tex display="inline"><![CDATA[\Theta (1)]]></fr:tex> and <fr:tex display="inline"><![CDATA[\Theta (n)]]></fr:tex>; in some sense it is much closer to <fr:tex display="inline"><![CDATA[\Theta (1)]]></fr:tex>.</html:p>
                            <html:p>For example, the biggest number that fits in a 64-bit integer is about <fr:tex display="inline"><![CDATA[10^{19}]]></fr:tex>. How long would it take to count that high? At <fr:tex display="inline"><![CDATA[10^8]]></fr:tex> per second, it would take <fr:tex display="inline"><![CDATA[10^{11}]]></fr:tex> seconds or about 3000 years. But if we can process it using something that repeatedly halves, <fr:tex display="inline"><![CDATA[\lg  10^{19} \approx  63]]></fr:tex>.</html:p>
                          </fr:mainmatter>
                        </fr:tree>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>11</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LB/</fr:uri>
                        <fr:display-uri>00LB</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LB/</fr:route>
                        <fr:title text="\Theta (\sqrt  n) = \Theta (n^{1/2}) (inputs up to 10^{16})"><fr:tex display="inline"><![CDATA[\Theta (\sqrt  n) = \Theta (n^{1/2})]]></fr:tex> (inputs up to <fr:tex display="inline"><![CDATA[10^{16}]]></fr:tex>)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>This will not come up much in this course, but it is definitely a thing. See “square root decomposition”.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>11</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LC/</fr:uri>
                        <fr:display-uri>00LC</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LC/</fr:route>
                        <fr:title text="\Theta (n): linear (inputs up to 100 million)"><fr:tex display="inline"><![CDATA[\Theta (n)]]></fr:tex>: linear (inputs up to <fr:tex display="inline"><![CDATA[100]]></fr:tex> million)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Examples of things that are <fr:tex display="inline"><![CDATA[\Theta (n)]]></fr:tex>:

<html:ul><html:li>Linear search</html:li>
  <html:li>Maximum/minimum/sum of a list</html:li>
  <html:li>Merge two sorted lists</html:li>
  <html:li>Insert or removing at the <html:em>beginning</html:em> of an array/list.</html:li></html:ul></html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>11</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LD/</fr:uri>
                        <fr:display-uri>00LD</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LD/</fr:route>
                        <fr:title text="\Theta (n \lg  n) (inputs up to 4.5 million)"><fr:tex display="inline"><![CDATA[\Theta (n \lg  n)]]></fr:tex> (inputs up to <fr:tex display="inline"><![CDATA[4.5]]></fr:tex> million)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Examples of things that are <fr:tex display="inline"><![CDATA[\Theta (n \lg  n)]]></fr:tex>:

<html:ul><html:li>Mergesort, quicksort</html:li>
  <html:li>In general, divide &amp; conquer algorithms with <fr:tex display="inline"><![CDATA[\Theta (n)]]></fr:tex> work at each level. We’ll study this in more detail later in the semester.</html:li>
  <html:li>If you are only allowed to compare pairs of elements to see which is greater, sorting a list of <fr:tex display="inline"><![CDATA[n]]></fr:tex> elements takes <fr:tex display="inline"><![CDATA[\Omega (n \lg  n)]]></fr:tex>.  In other words, it's impossible to sort any faster than <fr:tex display="inline"><![CDATA[n \lg  n]]></fr:tex> if you are only allowed to compare elements. (If you are allowed extra operations, sorting faster than <fr:tex display="inline"><![CDATA[n \lg  n]]></fr:tex> is possible; for example, a list of integers can be sorted in <fr:tex display="inline"><![CDATA[\Theta (n)]]></fr:tex> time.)</html:li></html:ul></html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>11</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LE/</fr:uri>
                        <fr:display-uri>00LE</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LE/</fr:route>
                        <fr:title text="\Theta (n^2): quadratic (inputs up to 10 thousand)"><fr:tex display="inline"><![CDATA[\Theta (n^2)]]></fr:tex>: quadratic (inputs up to 10 thousand)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Examples of things that are <fr:tex display="inline"><![CDATA[\Theta (n^2)]]></fr:tex>:

<html:ul><html:li>Two nested loops (often, but not necessarily)</html:li>
  <html:li><fr:tex display="inline"><![CDATA[1 + 2 + 3 + \dots  + n = \frac {n(n+1)}{2} = \Theta (n^2)]]></fr:tex></html:li>
  <html:li>The number of pairs of items chosen out of <fr:tex display="inline"><![CDATA[n]]></fr:tex>, <fr:tex display="inline"><![CDATA[\binom {n}{2} = \frac {n(n-1)}{2}]]></fr:tex>.</html:li>
  <html:li>Repeatedly appending <fr:tex display="inline"><![CDATA[n]]></fr:tex> characters to a string one by one</html:li>
  <html:li>Insertion sort, bubble sort</html:li></html:ul></html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>11</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LF/</fr:uri>
                        <fr:display-uri>00LF</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LF/</fr:route>
                        <fr:title text="\Theta (n^k) (inputs up to \sqrt [k]{10^8})"><fr:tex display="inline"><![CDATA[\Theta (n^k)]]></fr:tex> (inputs up to <fr:tex display="inline"><![CDATA[\sqrt [k]{10^8}]]></fr:tex>)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Things that take <fr:tex display="inline"><![CDATA[\Theta (n^k)]]></fr:tex> in general:

<html:ul><html:li><fr:tex display="inline"><![CDATA[k]]></fr:tex> nested loops.</html:li>
  <html:li>The number of subsets of size <fr:tex display="inline"><![CDATA[k]]></fr:tex> out of <fr:tex display="inline"><![CDATA[n]]></fr:tex> things, <html:em>i.e.</html:em> <fr:tex display="inline"><![CDATA[\binom  n k]]></fr:tex> (assuming <fr:tex display="inline"><![CDATA[n]]></fr:tex> is much bigger than <fr:tex display="inline"><![CDATA[k]]></fr:tex>).</html:li></html:ul></html:p>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>11</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LG/</fr:uri>
                            <fr:display-uri>00LG</fr:display-uri>
                            <fr:route>/~yorgey/forest/00LG/</fr:route>
                            <fr:taxon>Theorem</fr:taxon>
                          </fr:frontmatter>
                          <fr:mainmatter><html:p>Each <fr:tex display="inline"><![CDATA[n^j]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(n^k)]]></fr:tex> for <fr:tex display="inline"><![CDATA[j < k]]></fr:tex>.</html:p>
  
    
    <fr:tree show-metadata="false" toc="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>11</fr:day></fr:date><fr:taxon>Proof</fr:taxon></fr:frontmatter><fr:mainmatter><fr:link href="/~yorgey/forest/00KL/" title="[O3] Some asymptotic properties (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00KL/" display-uri="00KL" type="local">Homework</fr:link>.</fr:mainmatter></fr:tree>
  
</fr:mainmatter>
                        </fr:tree>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>11</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LH/</fr:uri>
                        <fr:display-uri>00LH</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LH/</fr:route>
                        <fr:title text="\Theta (2^n): exponential (up to n = 26)"><fr:tex display="inline"><![CDATA[\Theta (2^n)]]></fr:tex>: exponential (up to <fr:tex display="inline"><![CDATA[n = 26]]></fr:tex>)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Examples of things that are <fr:tex display="inline"><![CDATA[\Theta (2^n)]]></fr:tex>:

<html:ul><html:li>Number of subsets of <fr:tex display="inline"><![CDATA[n]]></fr:tex> things</html:li>
  <html:li>Number of bitstrings of length <fr:tex display="inline"><![CDATA[n]]></fr:tex></html:li>
  <html:li>Number of nodes (also number of leaves) in a tree of height <fr:tex display="inline"><![CDATA[n]]></fr:tex></html:li>
  <html:li><fr:tex display="inline"><![CDATA[1 + 2 + 4 + 8 + \dots  + 2^n = 2^{n+1} - 1]]></fr:tex>, so it is <fr:tex display="inline"><![CDATA[\Theta (2^n)]]></fr:tex></html:li></html:ul></html:p>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>11</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LI/</fr:uri>
                            <fr:display-uri>00LI</fr:display-uri>
                            <fr:route>/~yorgey/forest/00LI/</fr:route>
                            <fr:taxon>Theorem</fr:taxon>
                          </fr:frontmatter>
                          <fr:mainmatter><html:p><fr:tex display="inline"><![CDATA[n^k]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(r^n)]]></fr:tex> for all integers <fr:tex display="inline"><![CDATA[k \geq  0]]></fr:tex> and real numbers <fr:tex display="inline"><![CDATA[r > 1]]></fr:tex>.</html:p>
  
    
    <fr:tree show-metadata="false" toc="false"><fr:frontmatter><fr:authors /><fr:date><fr:year>2026</fr:year><fr:month>9</fr:month><fr:day>11</fr:day></fr:date><fr:taxon>Proof</fr:taxon></fr:frontmatter><fr:mainmatter><fr:link href="/~yorgey/forest/00KL/" title="[O3] Some asymptotic properties (2 pts)" uri="http://ozark.hendrix.edu/~yorgey/forest/00KL/" display-uri="00KL" type="local">Homework</fr:link>.</fr:mainmatter></fr:tree>
  
</fr:mainmatter>
                        </fr:tree>
                        <fr:tree show-metadata="false">
                          <fr:frontmatter>
                            <fr:authors />
                            <fr:date>
                              <fr:year>2026</fr:year>
                              <fr:month>9</fr:month>
                              <fr:day>11</fr:day>
                            </fr:date>
                            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LJ/</fr:uri>
                            <fr:display-uri>00LJ</fr:display-uri>
                            <fr:route>/~yorgey/forest/00LJ/</fr:route>
                            <fr:title text="Polynomial vs exponential">Polynomial vs exponential</fr:title>
                            <fr:taxon>Remark</fr:taxon>
                          </fr:frontmatter>
                          <fr:mainmatter>
                            <html:p>There is an insurmountable gulf between polynomial and exponential time. For example, even <fr:tex display="inline"><![CDATA[n^{295}]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(1.001^n)]]></fr:tex>! We usually take this to be the dividing line between “efficient/feasible” and “inefficient/infeasible”. (Of course <fr:tex display="inline"><![CDATA[n^{295}]]></fr:tex> is probably not actually feasible but in practice we don’t see that.)</html:p>
                          </fr:mainmatter>
                        </fr:tree>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>11</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LK/</fr:uri>
                        <fr:display-uri>00LK</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LK/</fr:route>
                        <fr:title text="\Theta (n!): factorial (inputs up to 11)"><fr:tex display="inline"><![CDATA[\Theta (n!)]]></fr:tex>: factorial (inputs up to <fr:tex display="inline"><![CDATA[11]]></fr:tex>)</fr:title>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p><fr:tex display="inline"><![CDATA[n!]]></fr:tex> corresponds to the numbre of distinct orderings of <fr:tex display="inline"><![CDATA[n]]></fr:tex> things. If an algorithm takes <fr:tex display="inline"><![CDATA[\Theta (n!)]]></fr:tex> it is really, really bad. In fact, <fr:tex display="inline"><![CDATA[k^n]]></fr:tex> is <fr:tex display="inline"><![CDATA[o(n!)]]></fr:tex> for all <fr:tex display="inline"><![CDATA[k]]></fr:tex>.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                  </fr:mainmatter>
                </fr:tree>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" expanded="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>13</fr:day>
                </fr:date>
                <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LL/</fr:uri>
                <fr:display-uri>00LL</fr:display-uri>
                <fr:route>/~yorgey/forest/00LL/</fr:route>
                <fr:title text="Graphs">Graphs</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>In this next unit, we will learn about (or review) <html:em>graphs</html:em> and several fundamental graph algorithms.</html:p>
                <fr:tree show-metadata="false">
                  <fr:frontmatter>
                    <fr:authors />
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>13</fr:day>
                    </fr:date>
                    <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LM/</fr:uri>
                    <fr:display-uri>00LM</fr:display-uri>
                    <fr:route>/~yorgey/forest/00LM/</fr:route>
                    <fr:title text="Graph definitions and terminology">Graph definitions and terminology</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>The material in this section is introduced via <fr:link href="https://hendrix-cs.github.io/csci382/pub/graphs.pdf" type="external">POGIL activity</fr:link>; see the activity for illustrations and examples.</html:p>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LN/</fr:uri>
                        <fr:display-uri>00LN</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LN/</fr:route>
                        <fr:title text="(Simple) graph">(Simple) graph</fr:title>
                        <fr:taxon>Definition</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>A (simple) <html:em>graph</html:em> <fr:tex display="inline"><![CDATA[G = (V, E)]]></fr:tex> is a set of <html:em>vertices</html:em> <fr:tex display="inline"><![CDATA[V]]></fr:tex> (singular <html:em>vertex</html:em>) together with a set <fr:tex display="inline"><![CDATA[E]]></fr:tex> of <html:em>edges</html:em>, where each edge consists of a set of two vertices.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LO/</fr:uri>
                        <fr:display-uri>00LO</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LO/</fr:route>
                        <fr:title text="Graphs and graph drawings">Graphs and graph drawings</fr:title>
                        <fr:taxon>Remark</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>We often <html:em>draw</html:em> graphs with a dot for each vertex, and edges represented by (straight or curved) lines drawn between vertices.  Note that the same graph can have many different drawings; the important thing about a graph is which vertices are connected by edges, not the specific way it is drawn.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LP/</fr:uri>
                        <fr:display-uri>00LP</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LP/</fr:route>
                        <fr:title text="Adjacent vertices">Adjacent vertices</fr:title>
                        <fr:taxon>Definition</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Vertices are <html:em>adjacent</html:em> (or <html:em>neighbors</html:em>) if they share an edge.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LQ/</fr:uri>
                        <fr:display-uri>00LQ</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LQ/</fr:route>
                        <fr:title text="Degree">Degree</fr:title>
                        <fr:taxon>Definition</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>The <html:em>degree</html:em> of a vertex is the number of other vertices which are <fr:link href="/~yorgey/forest/00LP/" title="Adjacent vertices" uri="http://ozark.hendrix.edu/~yorgey/forest/00LP/" display-uri="00LP" type="local">adjacent</fr:link> to it.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LR/</fr:uri>
                        <fr:display-uri>00LR</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LR/</fr:route>
                        <fr:title text="Leaf">Leaf</fr:title>
                        <fr:taxon>Definition</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>A <html:em>leaf</html:em> is a vertex with <fr:link href="/~yorgey/forest/00LQ/" title="Degree" uri="http://ozark.hendrix.edu/~yorgey/forest/00LQ/" display-uri="00LQ" type="local">degree</fr:link> <fr:tex display="inline"><![CDATA[1]]></fr:tex>.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LS/</fr:uri>
                        <fr:display-uri>00LS</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LS/</fr:route>
                        <fr:title text="Path">Path</fr:title>
                        <fr:taxon>Definition</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>A <html:em>path</html:em> is a sequence of one or more vertices such that each consecutive pair of vertices is <fr:link href="/~yorgey/forest/00LP/" title="Adjacent vertices" uri="http://ozark.hendrix.edu/~yorgey/forest/00LP/" display-uri="00LP" type="local">adjacent</fr:link>.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LT/</fr:uri>
                        <fr:display-uri>00LT</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LT/</fr:route>
                        <fr:title text="Connected">Connected</fr:title>
                        <fr:taxon>Definition</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>Two vertices are <html:em>connected</html:em> if there is a <fr:link href="/~yorgey/forest/00LS/" title="Path" uri="http://ozark.hendrix.edu/~yorgey/forest/00LS/" display-uri="00LS" type="local">path</fr:link> with the two vertices as endpoints.  A <html:em>connected graph</html:em> is one where every pair of vertices are connected.  A <html:em>connected component</html:em> is a maximal subset of connected vertices.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LU/</fr:uri>
                        <fr:display-uri>00LU</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LU/</fr:route>
                        <fr:title text="Cycle">Cycle</fr:title>
                        <fr:taxon>Definition</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>A <html:em>cycle</html:em> is a path which starts and ends at the same vertex and does not repeat any edges.  A <html:em>cyclic</html:em> graph is a graph containing at least one cycle.  An <html:em>acyclic</html:em> graph is a graph with no cycles.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                    <fr:tree show-metadata="false">
                      <fr:frontmatter>
                        <fr:authors />
                        <fr:date>
                          <fr:year>2026</fr:year>
                          <fr:month>9</fr:month>
                          <fr:day>13</fr:day>
                        </fr:date>
                        <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00LV/</fr:uri>
                        <fr:display-uri>00LV</fr:display-uri>
                        <fr:route>/~yorgey/forest/00LV/</fr:route>
                        <fr:title text="Tree">Tree</fr:title>
                        <fr:taxon>Definition</fr:taxon>
                      </fr:frontmatter>
                      <fr:mainmatter>
                        <html:p>A <html:em>tree</html:em> is an <fr:link href="/~yorgey/forest/00LU/" title="Cycle" uri="http://ozark.hendrix.edu/~yorgey/forest/00LU/" display-uri="00LU" type="local">acyclic</fr:link>, <fr:link href="/~yorgey/forest/00LT/" title="Connected" uri="http://ozark.hendrix.edu/~yorgey/forest/00LT/" display-uri="00LT" type="local">connected</fr:link> graph.</html:p>
                      </fr:mainmatter>
                    </fr:tree>
                  </fr:mainmatter>
                </fr:tree>
              </fr:mainmatter>
            </fr:tree>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:uri>http://ozark.hendrix.edu/~yorgey/forest/00JE/</fr:uri>
            <fr:display-uri>00JE</fr:display-uri>
            <fr:route>/~yorgey/forest/00JE/</fr:route>
            <fr:title text="CSCI 382, Algorithms">CSCI 382, Algorithms</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>I teach CSCI 382, Algorithms, at <fr:link href="/~yorgey/forest/hendrixcollege/" title="Hendrix College" uri="http://ozark.hendrix.edu/~yorgey/forest/hendrixcollege/" display-uri="hendrixcollege" type="local">Hendrix College</fr:link>.</html:p>
            <html:ul><html:li><fr:link href="https://hendrix-cs.github.io/csci382/" type="external">Course syllabus</fr:link></html:li>
  <html:li><fr:link href="/~yorgey/forest/00JF/" title="Algorithms Fall 2026 lecture notes" uri="http://ozark.hendrix.edu/~yorgey/forest/00JF/" display-uri="00JF" type="local">Algorithms Fall 2026 lecture notes</fr:link></html:li>   <html:li><fr:link href="/~yorgey/forest/00JL/" title="Algorithms problems" uri="http://ozark.hendrix.edu/~yorgey/forest/00JL/" display-uri="00JL" type="local">Algorithms problems</fr:link></html:li></html:ul>
          </fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Related">Related</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Contributions">Contributions</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
  </fr:backmatter>
</fr:tree>
