<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>COS 126, Fall 2026</title>
    <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/</link>
      <atom:link href="https://www.cs.princeton.edu/courses/archive/fall26/cos126/index.xml" rel="self" type="application/rss+xml" />
    <description>COS 126, Fall 2026</description>
    <generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Thu, 22 Jan 2026 00:00:00 +0000</lastBuildDate>
    <image>
      <url>https://www.cs.princeton.edu/courses/archive/fall26/cos126/media/icon_hu_7012878a764fbc1d.png</url>
      <title>COS 126, Fall 2026</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/</link>
    </image>
    
    <item>
      <title>0. Hello, World</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hello/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hello/</guid>
      <description>&lt;!--&lt;p style=&#34;color:red;&#34;&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt;  This assignment has not been officially released yet and is subject to change!&lt;/p&gt;

--&gt;
&lt;!-- &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Hello&#34;&gt;Submit to TigerFile&lt;/a&gt;
 --&gt;
&lt;p&gt;&lt;em&gt;This assignment introduces Java programming and the workflow for preparing and submitting COS 126 assignments. You will use &lt;em&gt;IntelliJ&lt;/em&gt; to write, compile, and run Java programs, and &lt;em&gt;TigerFile&lt;/em&gt; to submit your work.&lt;/em&gt;&lt;/p&gt;
&lt;!--
### **At a Glance**
- Implement `HelloWorld.java`, `Greeting.java`, `SayHelloWorld.java`, `GreatCircle.java`, and `RGBtoCMYK.java`.
- Record `MyHelloWorld.wav`.
- Complete `readme.txt` and `acknowledgments.txt`.
- Submit all files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Hello&#34;&gt;TigerFile&lt;/a&gt;
.
--&gt;
&lt;!-- SPRING	- `RGBtoCMYK.java` --&gt;
&lt;!-- SPRING	- `Ordered.java` --&gt;
&lt;!-- FALL	- `SumThree.java` --&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Before you begin, complete the following setup and policy steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Read Sections 1.1 and 1.2 of the course textbook.&lt;/li&gt;
&lt;li&gt;Browse the &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/syllabus/&#34;&gt;course website&lt;/a&gt; and read the collaboration policies.&lt;/li&gt;
&lt;li&gt;Take the &lt;a href=&#34;https://princeton.instructure.com/courses/22541&#34;&gt;Collaboration Policy Quiz&lt;/a&gt; - look under Quizzes.&lt;/li&gt;
&lt;li&gt;Fill out the &lt;a href=&#34;https://princeton.instructure.com/courses/22541&#34;&gt;Course Entry Survey&lt;/a&gt; - look under Quizzes. Completing this will count towards your participation grade (equivalent to participation in one lecture).&lt;/li&gt;
&lt;li&gt;Install the latest COS 126 Java programming environment on your laptop for &lt;a href=&#34;https://lift.cs.princeton.edu/java/mac/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;macOS&lt;/a&gt;, &lt;a href=&#34;https://lift.cs.princeton.edu/java/windows/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Windows&lt;/a&gt;, or &lt;a href=&#34;https://lift.cs.princeton.edu/java/linux/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Linux&lt;/a&gt;.
Reuse the &lt;code&gt;hello&lt;/code&gt; project folder for this assignment.&lt;/li&gt;
&lt;li&gt;Consult the &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/guidelines/&#34;&gt;Assignments FAQ&lt;/a&gt; for common questions and answers.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you get stuck, post on &lt;a href=&#34;https://edstem.org/us/courses/99455/discussion&#34;&gt;Ed&lt;/a&gt;, attend office hours, or visit the &lt;a href=&#34;https://introlab.cs.princeton.edu&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;COS Lab TAs&lt;/a&gt;.
Don&amp;rsquo;t be afraid to ask for help!&lt;/p&gt;
&lt;h3 id=&#34;restrictions&#34;&gt;&lt;strong&gt;Restrictions&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Follow these rules to support the intended learning goals and preserve anonymous grading:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For each assignment, you may use only Java features introduced in COS 126 so far.&lt;/li&gt;
&lt;li&gt;For example, on this assignment, you may call &lt;code&gt;System.out.print()&lt;/code&gt;, &lt;code&gt;Integer.parseInt()&lt;/code&gt;, &lt;code&gt;Math.sqrt()&lt;/code&gt;, and &lt;code&gt;StdAudio.play()&lt;/code&gt;, but you may not use loops or conditionals.&lt;/li&gt;
&lt;li&gt;Do not include your name, NetID, or email in any submitted file except &lt;code&gt;acknowledgments.txt&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;hello-world&#34;&gt;&lt;strong&gt;Hello, World&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a program &lt;code&gt;HelloWorld.java&lt;/code&gt; that prints “&lt;em&gt;Hello, World&lt;/em&gt;.” If you completed the IntelliJ setup,
you have already done this step.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;javac HelloWorld.java&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java HelloWorld&lt;/span&gt;
Hello, World
&lt;/pre&gt;

&lt;!-- ![HelloWorld.java](https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/images//helloworld-intellij.png) --&gt;
&lt;!--
### **DrawCat**

This exercise will give you experience identifying compile-time, run-time and logic errors in Java code.

ASCII Art is a technique that uses sequences of characters printed on successive lines to depict a graphic on non-graphical display.  The program `DrawCat.java` - included in your project folder -  uses ASCII Art to draw a cat. It takes two characters on the command-line - the first for the cat&#39;s eyes and the second for its mouth.  Using these command-line arguments, `DrawCat` should draw a cat, as shown below:

```java
java DrawCat @ +
          ^_^   
    ____( @ @)
  /~____  =+= /
 (______)__m_m)
 ```

Fix all the errors in the provided file `DrawCat.java`.  Your solution should have no errors, including *Checkstyle* warnings.

Background: This [website](https://asciiart.website) contains many interesting ASCII Art pictures.
--&gt;
&lt;h3 id=&#34;personalized-greeting&#34;&gt;&lt;strong&gt;Personalized Greeting&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a program &lt;code&gt;Greeting.java&lt;/code&gt; that takes three command-line arguments: a greeting and two names.
It prints two lines.
The first line uses the names in the given order; the second line in the reverse order.&lt;/p&gt;
&lt;p&gt;Below are some sample executions. Match the output exactly, including punctuation.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;javac Greeting.java&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java Greeting Hi Sonia Samuel&lt;/span&gt;
Hi Sonia and Samuel.
Hi Samuel and Sonia.

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java Greeting Ciao Kellia Yacoub&lt;/span&gt;
Ciao Kellia and Yacoub.
Ciao Yacoub and Kellia.

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java Greeting γεια Alexandria Homer&lt;/span&gt;
γεια Alexandria and Homer.
γεια Homer and Alexandria.

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java Greeting &amp;#34;Nǐ hǎo&amp;#34; Ahmed Hagop&lt;/span&gt;
Nǐ hǎo Ahmed and Hagop.
Nǐ hǎo Hagop and Ahmed.
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I pass a greeting or name that contains spaces as a single command-line argument?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Spaces normally separate command-line arguments. To include a space, wrap the entire argument in double quotes.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;em&gt;For more multilingual examples, see &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11hello/HelloWorldMultilingual.java.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;HelloWorldMultilingual.java&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;hello-world-in-many-voices&#34;&gt;&lt;strong&gt;Hello, World in Many Voices&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a program &lt;code&gt;SayHelloWorld.java&lt;/code&gt; that takes the name of a WAV file as a command-line argument and plays it using &lt;code&gt;StdAudio.play()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;StdAudio.play()&lt;/code&gt; takes a filename, such as &lt;code&gt;&amp;quot;HelloWorld.wav&amp;quot;&lt;/code&gt;, and plays the audio file.&lt;/li&gt;
&lt;li&gt;The filename may include a directory path, such as &lt;code&gt;people/KevinWayne.wav&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When using the command line, compile and run with &lt;code&gt;javac-introcs&lt;/code&gt; and &lt;code&gt;java-introcs&lt;/code&gt;. These commands tell Java where to find our course libraries, such as &lt;code&gt;StdAudio&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;people&lt;/code&gt;, &lt;code&gt;google&lt;/code&gt; and &lt;code&gt;siri&lt;/code&gt; directories contain many WAV files of &lt;em&gt;&amp;lsquo;Hello, World&amp;rsquo;&lt;/em&gt; in different voices and languages, including recordings and  synthetic audio (from &lt;a href=&#34;https://translate.google.com&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Google Translate&lt;/a&gt; and &lt;a href=&#34;https://www.apple.com/siri&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Apple Siri&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Below are some sample executions:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;javac-introcs SayHelloWorld.java&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs SayHelloWorld people/KevinWayne.wav&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/people/KevinWayne.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/people/KevinWayne.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/people/KevinWayne.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/people/KevinWayne.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs SayHelloWorld people/AloeBlacc.wav&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/people/AloeBlacc.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/people/AloeBlacc.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/people/AloeBlacc.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/people/AloeBlacc.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs SayHelloWorld google/Spanish.wav&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/google/Spanish.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/google/Spanish.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/google/Spanish.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/google/Spanish.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs SayHelloWorld siri/Kyoko.wav&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/siri/Kyoko.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/siri/Kyoko.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/siri/Kyoko.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/siri/Kyoko.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;
&lt;/pre&gt;

&lt;p&gt;Record yourself saying &lt;em&gt;&amp;ldquo;Hello, World&amp;rdquo;&lt;/em&gt; (any language) and save the audio file in your device&amp;rsquo;s native format:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Mac OS X:  &lt;em&gt;Voice Memos app → Record&lt;/em&gt;. Drag the recording to a folder to save the file.&lt;/li&gt;
&lt;li&gt;iPhone:  &lt;em&gt;Voice Memo app → Record&lt;/em&gt;. Transfer the file to your laptop.&lt;/li&gt;
&lt;li&gt;Windows:  &lt;em&gt;Sound Recorder → Record → Save&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Android: Use an app that allows you to record audio. Transfer the file to your laptop.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then convert it to WAV format (e.g., using &lt;a href=&#34;https://zamzar.com&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Zamzar&lt;/a&gt;) and name the file &lt;code&gt;MyHelloWorld.wav&lt;/code&gt;.&lt;/p&gt;
&lt;!--    - Mac OS X:  *Quicktime app  →  File  →  New Audio Recording*. After making the recording, select *File  →  Save*. Then convert the M4A file to a WAV file via [Zamzar](https://zamzar.com) --&gt;
&lt;!-- SPRING 
### **Ordered**

This exercise demonstrates the use of the `int` and `boolean` data types. Write a program `Ordered.java` that 
takes three integer command-line arguments, $x$, $y$, and $z$. You must define a `boolean` variable whose value 
is `true` if the three values are either in strictly ascending order $(x &lt; y &lt; z)$ or in strictly descending 
order $(x &gt; y &gt; z)$, and `false` otherwise. Then, print this `boolean` value.  Do not use a conditional 
statement or a loop statement (such as an `if`, `while`, or `for` statement) in your solution.

Examples:

```plaintext 
java-introcs Ordered 10 17 49
true

java-introcs Ordered 49 17 10
true

java-introcs Ordered 10 49 17
false
```
--&gt;
&lt;h3 id=&#34;great-circle-distance&#34;&gt;&lt;strong&gt;Great Circle Distance&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;em&gt;great-circle distance&lt;/em&gt; is the length of the shortest path between two points
$(x_1, y_1)$ and $(x_2, y_2)$
on the surface of a sphere, where the path is constrained to be along the surface.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/images/great-circle.png&#34; width=&#34;200&#34; alt=&#34;great-circle distance between two points&#34;&gt;
&lt;p&gt;Write a program &lt;code&gt;GreatCircle.java&lt;/code&gt; that takes four &lt;code&gt;double&lt;/code&gt; command-line
arguments $x_1$, $y_1$, $x_2$, and $y_2$—the latitude and longitude (in degrees)
of two points on the surface of the Earth—and prints
the great-circle distance (in kilometers) between them.&lt;/p&gt;
&lt;p&gt;Use the following &lt;a href=&#34;https://en.wikipedia.org/wiki/Spherical_law_of_cosines&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;spherical law of cosines&lt;/a&gt; formula:&lt;/p&gt;



\[
distance \; = \; r \cdot \arccos \left ( \sin x_1 \sin x_2 \, + \, \cos x_1 \cos x_2 \cos(y_1 - y_2) \right )
\]

&lt;!--
[Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula):




\[
distance \; = \; 2r \arcsin \left ( \sqrt{ \sin^2 \left ( \frac{x_2 - x_1}{2} \right ) + \cos x_1 \cos x_2  \sin^2 \left ( \frac{y_2 - y_1}{2} \right ) } \right )
\]

--&gt;
&lt;p&gt;where $r = \text{6,371.0}$ is the mean radius of the Earth (in kilometers).&lt;/p&gt;
&lt;!--  according to WGS-84 technical report, the mean radius is 6371008.7714 m --&gt;
&lt;!--  https://gis-lab.info/docs/nima-tr8350.2-wgs84fin.pdf --&gt;
&lt;p&gt;Below are some sample executions. Your output should match exactly,
except possibly in the last digit.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;javac GreatCircle.java&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java GreatCircle 40.35 74.65 48.87 -2.33   // Princeton to Paris&lt;/span&gt;
5902.927099258562 kilometers

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java GreatCircle 30.0 15.0 30.0 75.0       // for debugging&lt;/span&gt;
5706.280401668459 kilometers
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;The command-line arguments are given in degrees but Java’s trigonometric functions use radians. What can I do?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use code like &lt;code&gt;radians = Math.toRadians(degrees)&lt;/code&gt; to convert from degrees to radians.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Which other math library functions will I need?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;You will also need &lt;code&gt;Math.sin()&lt;/code&gt;, &lt;code&gt;Math.cos()&lt;/code&gt;, and &lt;code&gt;Math.acos()&lt;/code&gt;.`.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I&amp;rsquo;m getting the wrong result. How can I check my formula?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Create a small example that you can work out by hand. Then verify that each intermediate term matches.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/images/great-circle-trace.png&#34; width=&#34;550&#34; alt=&#34;great circle trace&#34;&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I use a different formula to compute the great-circle distance?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. Use the spherical law of cosines formula, as specified.
Later in the course, we will use the &lt;a href=&#34;https://en.wikipedia.org/wiki/Haversine_formula&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Haversine formula&lt;/a&gt;, which is more accurate for nearby points with floating-point arithmetic.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Is this formula exact, given that the Earth is not a perfect sphere?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. However, this formula is a good approximation to the true distance.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;rgb-to-cmyk-conversion&#34;&gt;&lt;strong&gt;RGB to CMYK Conversion&lt;/strong&gt;&lt;/h3&gt;
&lt;!-- This exercise demonstrates type conversions. --&gt;
&lt;p&gt;Colors are represented in different formats, including &lt;em&gt;RGB&lt;/em&gt; and &lt;em&gt;CMYK&lt;/em&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;RGB format&lt;/strong&gt; is used for screens and web graphics. It specifies each component (red, green, blue) on an integer scale from 0 to 255.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CMYK format&lt;/strong&gt; is used for print publishing. It specifies each component (cyan, magenta, yellow, black) on a real scale from 0.0 to 1.0&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Write a program &lt;code&gt;RGBtoCMYK.java&lt;/code&gt; that converts from RGB format to CMYK format. The program takes three &lt;em&gt;integer&lt;/em&gt; command-line arguments: &lt;code&gt;red&lt;/code&gt;, &lt;code&gt;green&lt;/code&gt;, and &lt;code&gt;blue&lt;/code&gt; (each between 0 and 255). It prints the RGB components, followed by the corresponding CMYK components.&lt;/p&gt;
&lt;p&gt;Use the following conversion formulas:&lt;/p&gt;



\[
\begin{aligned}
white    &amp; \;\; = \;  \max \left ( { \frac{red}{255}, \; \frac{\textit{green}}{255}, \; \frac{blue}{255}} \right ) \\[.2in]
cyan     &amp; \;\; = \;  \left ( white - \frac{red}{255} \right ) \;\;\;\, \div \; white \\[.2in]
magenta  &amp; \;\; = \;  \left ( white - \frac{green}{255} \right ) \; \div \; white\\[.2in]
yellow   &amp; \;\; = \;  \left ( white - \frac{blue}{255} \right ) \;\;\, \div \; white\\[.2in]
black    &amp; \;\; = \;   1 - white
\end{aligned}
\]

&lt;p&gt;&lt;em&gt;Restriction:&lt;/em&gt; You may assume the three RGB arguments are not all zero (to ensure $white$ is nonzero).&lt;/p&gt;
&lt;!-- CMYK is a subtractive color space, because its primary colors are subtracted from white light to produce the resulting color: cyan absorbs red, magenta absorbs green, and yellow absorbs blue.  --&gt;
&lt;p&gt;Below are some sample executions. Your output format must match the examples exactly, including whitespace and punctuation.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;javac RGBtoCMYK.java&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java RGBtoCMYK 75 0 130   // indigo&lt;/span&gt;
red     = 75
green   = 0
blue    = 130
cyan    = 0.423076923076923
magenta = 1.0
yellow  = 0.0
black   = 0.4901960784313726

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hello&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java RGBtoCMYK 255 143 0   // Princeton orange&lt;/span&gt;
red     = 255
green   = 143
blue    = 0
cyan    = 0.0
magenta = 0.4392156862745098
yellow  = 1.0
black   = 0.0
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I compute the maximum of three numbers?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Java does not include a built-in function for that. However, &lt;code&gt;Math.max(x, y)&lt;/code&gt; returns the maximum of &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I align the equals signs in the output?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;We will learn about &lt;em&gt;formatted printing&lt;/em&gt; later in the course. For now, add the appropriate number of spaces in the string you print, before each equals sign.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;!-- FALL
### **SumThree**

Write a program `SumThree.java` that takes three integer command-line arguments and prints the three integers and their sum in the form of an equation. 

```plaintext
java-introcs SumThree 2 5 8
```
```
2 + 5 + 8 = 15
```

```plaintext
java-introcs SumThree -2 5 -8
```
```
-2 + 5 + -8 = -5
```
--&gt;
&lt;h3 id=&#34;readme&#34;&gt;&lt;strong&gt;Readme&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Complete &lt;code&gt;readme.txt&lt;/code&gt; to describe your work. Use the provided template and answer every question.&lt;/p&gt;
&lt;h3 id=&#34;acknowledgments&#34;&gt;&lt;strong&gt;Acknowledgments&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Complete &lt;code&gt;acknowledgments.txt&lt;/code&gt; using the provided template.
It contains two sections:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;List the names and dates of anyone who helped you with this assignment. When you attend office hours or a Lab TA session, introduce yourself and write down the person’s name.&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;1/23/26 Alan Turing (lab TA)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Helped me cast the result of Math.round() to an int.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;1/24/26 Grace Hopper (faculty)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Explained how to use the StdAudio library.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Include the &lt;em&gt;Student Acknowledgment of Original Work&lt;/em&gt; from &lt;a href=&#34;https://rrr.princeton.edu&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Rights, Rules, Responsibilities&lt;/a&gt;. Add your digital signature as &lt;code&gt;/s/&lt;/code&gt; followed by your full name.&lt;p&gt;&lt;Br&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;This programming assignment represents my own work in
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;accordance with University regulations. /s/ Ada Lovelace
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Log in to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Hello&#34;&gt;TigerFile&lt;/a&gt;
 with your OIT NetID and upload the required files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;HelloWorld.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Greeting.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SayHelloWorld.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GreatCircle.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;RGBtoCMYK.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;MyHelloWorld.wav&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then click &lt;em&gt;Check Submitted Files&lt;/em&gt; to check your work.
Fix every reported issue (including issues in &lt;code&gt;readme.txt&lt;/code&gt; and &lt;code&gt;acknowledgments.txt&lt;/code&gt;) and resubmit.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You may submit files individually or in a batch.&lt;/li&gt;
&lt;li&gt;You may click &lt;em&gt;Check Submitted Files&lt;/em&gt; at most 20 times per assignment.&lt;/li&gt;
&lt;li&gt;We will not grade your submission until &lt;code&gt;acknowledgments.txt&lt;/code&gt; is submitted.
If you plan to submit late, do not submit that file until you are
finished and ready for grading.&lt;/li&gt;
&lt;li&gt;Read the output of Tigerfile carefully! You should address all failed test cases, warnings, and error messages in your solution. These indicate that there may be issues that need to be fixed.  If you are unsure how to address a failed test, warning, or error, please ask for help!&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;!-- FALL
| Files                | Points   |
| ---------------      | ------:  |
| HelloWorld.java      |   8      |
| Greeting.java        |   8      |
| SayHelloWorld.java   |   8      |
| SumThree.java        |   8      |
| readme.txt           |   4      |
| Survey               |   4      |
--&gt;
&lt;!-- SPRING  --&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Item&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;HelloWorld.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Greeting.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;8&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;SayHelloWorld.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;8&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;GreatCircle.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;8&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;RGBtoCMYK.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;8&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;You must complete the Collaboration Policy Quiz with a perfect score to receive credit for any programming assignment.&lt;/em&gt;&lt;/p&gt;
&lt;!--
### **Enrichment**

***Hello World in 200 Languages***.  Here is [Hello World](http://helloworldcollection.de) in over 200 different programming languages.
--&gt;
</description>
    </item>
    
    <item>
      <title>1. Conditionals and Loops</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/loops/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/loops/</guid>
      <description>&lt;!--&lt;p style=&#34;color:red;&#34;&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt;  This assignment has not been officially released yet and is subject to change!&lt;/p&gt;

--&gt;
&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/loops.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Loops&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this assignment, you will use conditionals and loops to write small programs
involving sound and images. You will also diagnose and fix bugs in a provided program.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Read Section 1.3 of the textbook and review the corresponding lectures and precepts.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/loops.zip&#34;&gt;loops.zip&lt;/a&gt;
, then open the &lt;code&gt;loops&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Refer to the &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/guidelines/&#34;&gt;Programming Assignments FAQ&lt;/a&gt; as needed.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Reminder:&lt;/em&gt; You may use only Java features introduced so far.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- - You may also find it instructive to work through some of the other exercises and look at the solutions on the [booksite](https://introcs.cs.princeton.edu/java/home) afterwards. --&gt;
&lt;!-- -  Refer to  our [style guide for writing clear programs](https://introcs.cs.princeton.edu/java/11style), as needed. --&gt;
&lt;h3 id=&#34;saying-military-time&#34;&gt;&lt;strong&gt;Saying Military Time&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Military time&lt;/em&gt; specifies the time of day in the form &lt;code&gt;HHMM&lt;/code&gt;,
where &lt;code&gt;HH&lt;/code&gt; is the hour since midnight and &lt;code&gt;MM&lt;/code&gt; is the minutes since the last full hour.
For example, &lt;code&gt;1200&lt;/code&gt; is noon; &lt;code&gt;2359&lt;/code&gt; is one minute before midnight; and &lt;code&gt;0100&lt;/code&gt; is one hour after midnight.&lt;/p&gt;
&lt;p&gt;To parse and say military time, following these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Extract the hours &lt;code&gt;HH&lt;/code&gt; and minutes &lt;code&gt;MM&lt;/code&gt; from the four-digit time &lt;code&gt;HHMM&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Say the hours &lt;code&gt;HH&lt;/code&gt;. If &lt;code&gt;HH&lt;/code&gt; is between 1 and 9, precede it with the word &lt;em&gt;&amp;ldquo;zero.&amp;rdquo;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Say the word &amp;ldquo;&lt;em&gt;hundred&lt;/em&gt;.&amp;rdquo;&lt;/li&gt;
&lt;li&gt;Say the minutes &lt;code&gt;MM&lt;/code&gt;, unless &lt;code&gt;MM&lt;/code&gt; is &lt;code&gt;00&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Say the word &amp;ldquo;&lt;em&gt;hours&lt;/em&gt;.&amp;rdquo;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example, &lt;code&gt;2359&lt;/code&gt; is spoken as &amp;ldquo;&lt;em&gt;twenty-three hundred fifty-nine hours&lt;/em&gt;&amp;rdquo; and &lt;code&gt;0100&lt;/code&gt; as &amp;ldquo;&lt;em&gt;zero one hundred hours&lt;/em&gt;.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Write a program &lt;code&gt;SayMilitaryTime.java&lt;/code&gt; to say a given military time using these rules. The program takes two command-line arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Time:&lt;/strong&gt; A 4-digit string in military time (e.g., &lt;code&gt;1200&lt;/code&gt;, &lt;code&gt;2359&lt;/code&gt;, or &lt;code&gt;0100&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Voice:&lt;/strong&gt; The name of a voice subdirectory (e.g., &lt;code&gt;Alex&lt;/code&gt; or &lt;code&gt;Siri&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The subdirectories &lt;code&gt;Alex&lt;/code&gt;, &lt;code&gt;Siri&lt;/code&gt;, &lt;code&gt;Amélie&lt;/code&gt;, &lt;code&gt;Luca&lt;/code&gt;, &lt;code&gt;Paulina&lt;/code&gt;, &lt;code&gt;Samantha&lt;/code&gt;, and &lt;code&gt;Veena&lt;/code&gt; contain voice recordings of people saying the numbers 0 through 59, along with the words for &lt;em&gt;hundred&lt;/em&gt; and &lt;em&gt;hours&lt;/em&gt;.
For example, &lt;code&gt;Alex/59.wav&lt;/code&gt; is Alex saying the number 59 and &lt;code&gt;Siri/hundred.wav&lt;/code&gt; is Siri saying the word &lt;em&gt;hundred&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Below are some sample executions:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs SayMilitaryTime 2359 Alex&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Alex2359.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Alex2359.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Alex2359.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Alex2359.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs SayMilitaryTime 1100 Siri&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Siri1100.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Siri1100.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Siri1100.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Siri1100.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs SayMilitaryTime 0609 Veena&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Veena0609.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Veena0609.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Veena0609.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Veena0609.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs SayMilitaryTime 0011 Paulina&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Paulina0011.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Paulina0011.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Paulina0011.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/Paulina0011.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What happens if the argument to &lt;code&gt;Integer.parseInt()&lt;/code&gt; has leading zeros, such as &lt;code&gt;0011&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Leading zeros are allowed and simply ignored. For example, &lt;code&gt;Integer.parseInt(&amp;quot;0011&amp;quot;)&lt;/code&gt; returns the integer &lt;code&gt;11&lt;/code&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What are the valid values for &lt;code&gt;HHMM&lt;/code&gt; (24-hour time)?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Your program should correctly handle any &lt;code&gt;HHMM&lt;/code&gt; time from &lt;code&gt;0000&lt;/code&gt; to &lt;code&gt;2359&lt;/code&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;em&gt;Context: The 24-hour clock is used widely in Asia, Europe, Africa, and Latin America.
In the United States, it is used in the military, aviation, navigation, computing, logistics, and hospitals.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;random-walkers&#34;&gt;&lt;strong&gt;Random Walkers&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Fix the bugs in &lt;a href=&#34;static/assignments/loops/files/RandomWalkers.java&#34;&gt;&lt;code&gt;RandomWalkers.java&lt;/code&gt;&lt;/a&gt;.
It must compile with no errors and no warnings, and it must pass all &lt;em&gt;TigerFile&lt;/em&gt; checks, including style checks.
The intended behavior is as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The program takes two integer command-line arguments:
$n$ (the number of steps) and $trials$ (the number of trials).&lt;/li&gt;
&lt;li&gt;One &lt;em&gt;trial&lt;/em&gt; simulates a random walk for $n$ steps, starting from the origin:
&lt;ul&gt;
&lt;li&gt;maintain the current location $(x, y)$, initially $(0, 0)$&lt;/li&gt;
&lt;li&gt;repeat $n$ times: move one unit north, east, south, or west, each with probability $\tfrac14$&lt;/li&gt;
&lt;li&gt;after $n$ steps, compute the &lt;em&gt;squared distance&lt;/em&gt; from the origin:  $x^2 + y^2$&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Print the &lt;em&gt;mean squared distance&lt;/em&gt; (the average of the squared distances over all trials).&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/images/random-walk.png&#34; width=&#34;400&#34; alt=&#34;A random walk with n = 15 steps&#34;&gt;
&lt;p&gt;Here are sample executions of the corrected &lt;code&gt;RandomWalkers&lt;/code&gt;.
Because the walk is random, your output will vary. However, when $trials$ is large,
your output should be close to the output below.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs RandomWalkers 100 10000&lt;/span&gt;
mean squared distance = 101.446

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs RandomWalkers 100 10000&lt;/span&gt;
mean squared distance = 99.1674

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs RandomWalkers 200 1000&lt;/span&gt;
mean squared distance = 195.75

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs RandomWalkers 200 1000&lt;/span&gt;
mean squared distance = 198.21

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs RandomWalkers 1600 100000&lt;/span&gt;
mean squared distance = 1600.13064

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs RandomWalkers 1600 100000&lt;/span&gt;
mean squared distance = 1603.72
&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Context: Random walks model Brownian motion and diffusion, with applications ranging from ink dispersing in water to polymer formation and neural activity.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;duotone-filter&#34;&gt;&lt;strong&gt;Duotone Filter&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;A &lt;em&gt;duotone filter&lt;/em&gt; maps each pixel to a weighted average of two palette colors,
using the pixel&amp;rsquo;s &lt;em&gt;brightness&lt;/em&gt; as the weight.&lt;/p&gt;
&lt;p&gt;To apply a duotone filter, process each pixel independently:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Let $(r, g, b)$ be the pixel&amp;rsquo;s &lt;em&gt;red&lt;/em&gt;, &lt;em&gt;green&lt;/em&gt;, and &lt;em&gt;blue&lt;/em&gt; components.
Each component is an integer between $0$ and $255$.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compute the &lt;em&gt;pixel brightness&lt;/em&gt; $\alpha$
using the &lt;a href=&#34;https://en.wikipedia.org/wiki/NTSC&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;NTSC luma coefficients&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;$$\alpha = \tfrac{1}{255} (0.299r + 0.587g + 0.114b)$$&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This guarantees that $0 \le \alpha \le 1$.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Let $(r_1, g_1, b_1)$  and $(r_2, g_2, b_2)$ be the RGB components of the two palette colors.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compute the new color $(r^\prime, g^\prime, b^\prime)$ as follows:



\begin{aligned}
r&#39; &amp; = \alpha \, r_1 \; + \; (1 - \alpha) \, r_2 \\
g&#39; &amp; = \alpha \, g_1 \; + \; (1 - \alpha) \, g_2 \\
b&#39; &amp; = \alpha \, b_1 \; + \; (1 - \alpha) \, b_2
\end{aligned}

Round each component to the &lt;em&gt;nearest integer&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Write a program &lt;code&gt;Duotone.java&lt;/code&gt; that takes seven command-line arguments:
&lt;code&gt;filename&lt;/code&gt;, &lt;code&gt;r1&lt;/code&gt;, &lt;code&gt;g1&lt;/code&gt;, &lt;code&gt;b1&lt;/code&gt;, &lt;code&gt;r2&lt;/code&gt;, &lt;code&gt;g2&lt;/code&gt;, and &lt;code&gt;b2&lt;/code&gt;.
It should apply the duotone filter and display the result using &lt;code&gt;StdPicture&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The sample execution below applies a duotone filter to a
photo of Johnson Arch using &lt;em&gt;Princeton orange&lt;/em&gt;  $(245, 128, 37)$
for the first palette color and  &lt;em&gt;black&lt;/em&gt; $(0, 0, 0)$ for the second.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs StdPicture JohnsonArch.jpg&lt;/span&gt;

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/images/JohnsonArch.jpg&#34; width=&#34;350&#34; alt=&#34;photo of Johnson Arch&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Duotone JohnsonArch.jpg 245 128 37 0 0 0&lt;/span&gt;

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/images/JohnsonArch-duotone.jpg&#34; width=&#34;350&#34; alt=&#34;photo of Johnson Arch with duotone filter&#34;&gt;
&lt;/pre&gt;

&lt;p&gt;Take a photo of a campus structure (building, archway, gate, etc.) and apply your duotone filter.
Submit the original photo as &lt;code&gt;MyPhoto.jpg&lt;/code&gt;, and record the two palette colors you used in your &lt;code&gt;readme.txt&lt;/code&gt;.&lt;/p&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Which methods are available in &lt;code&gt;StdPicture&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;See the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/index.html#StdPicture&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Java cheatsheet&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Why does &lt;code&gt;StdPicture&lt;/code&gt; use the conventions that the indices are $(col, row)$ and $(0, 0)$ is upper left?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;These are common conventions in image processing.
It&amp;rsquo;s a tradeoff between coordinate-system consistency and array-indexing consistency.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using $(col, row)$ means that the first coordinate correspond to $x$ (horizontal) and the
second corresponds to $y$ (vertical).&lt;/li&gt;
&lt;li&gt;Using the upper-left as the origin reflects early display hardware,
which scanned from top to bottom. As you move down the screen, the row index increases.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What does &lt;code&gt;java-introcs StdPicture filename&lt;/code&gt; do?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It runs &lt;code&gt;main()&lt;/code&gt; in &lt;code&gt;StdPicture&lt;/code&gt;, which takes an image filename
as a command-line argument and displays that image in a window.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I round a &lt;code&gt;double&lt;/code&gt; to the nearest &lt;code&gt;int&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use &lt;code&gt;(int) Math.round(x)&lt;/code&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Why use the NTSC luma coefficients instead of a simple average of the RGB components?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;They better approximate &lt;em&gt;perceived brightness&lt;/em&gt;, since the human eye is more sensitive to green than to red or blue.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;My photo appears to be rotated 90 degrees in &lt;code&gt;StdPicture&lt;/code&gt;. Why?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It&amp;rsquo;s likely that your image is rotated 90 degrees but has an EXIF tag that tells certain
apps to rotate it back 90 degrees. On macOS, open your image in &lt;em&gt;Preview&lt;/em&gt;, rotate it 90 degrees
clockwise, then &lt;em&gt;Tools -&amp;gt; Rotate Left -&amp;gt; Rotate Right&lt;/em&gt; and &lt;em&gt;Save&lt;/em&gt;. That should make it
no longer depend on the EXIF tag.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;My photo is too large to display in &lt;code&gt;StdPicture&lt;/code&gt;. How can I fix?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Create a smaller version of your photo.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;em&gt;Context: Duotone is a popular effect for photographers and digital artists.
See &lt;a href=&#34;https://medialoot.com/duotones&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this site&lt;/a&gt; for examples.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;musical-dice-game&#34;&gt;&lt;strong&gt;Musical Dice Game&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;A &lt;em&gt;musical dice game&lt;/em&gt; (&lt;a href=&#34;https://en.wikipedia.org/wiki/Musikalisches_W%c3%bcrfelspiel&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Musikalisches Würfelspiel&lt;/a&gt;)
generates music by stitching together precomposed measures chosen at random.
In this exercise, you will assemble a 32-measure Viennese waltz in the style of Mozart.
The waltz has two parts: a &lt;em&gt;minuet&lt;/em&gt; followed by a &lt;em&gt;trio&lt;/em&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Minuet.&lt;/strong&gt; The minuet consists of 16 measures (numbered 0 to 15).
&lt;ul&gt;
&lt;li&gt;For measure $i$, roll &lt;em&gt;two&lt;/em&gt; fair six-sided dice and let $s$ be the sum.&lt;/li&gt;
&lt;li&gt;Play &lt;code&gt;minuet&amp;lt;i&amp;gt;-&amp;lt;s&amp;gt;.wav&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For example, if you roll an 8 for measure 3, play &lt;code&gt;minuet3-8.wav&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Note: sums range from 2 to 12; 7 is most likely, and 2 and 12 are least likely.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/images/two-fair-dice.png&#34; alt=&#34;two fair six-sided dice&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Trio.&lt;/strong&gt; The trio consists of 16 measures (numbered 0 to 15).
&lt;ul&gt;
&lt;li&gt;For measure $i$, roll &lt;em&gt;one&lt;/em&gt; fair six-sided die and  let $r$ be the roll.&lt;/li&gt;
&lt;li&gt;Play &lt;code&gt;trio&amp;lt;i&amp;gt;-&amp;lt;r&amp;gt;.wav&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For example, if you roll a 6 for measure 15, play &lt;code&gt;trio15-6.wav&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/images/one-fair-die.png&#34; alt=&#34;one fair six-sided die&#34;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Instruments and files.&lt;/strong&gt; The project folder includes several instrument subdirectories.
For example, &lt;code&gt;mozart-piano&lt;/code&gt; contains 272 WAV files  named using the conventions above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Minuet: 16 measures × 11 possible sums = 176 files.&lt;/li&gt;
&lt;li&gt;Trio: 16 measures × 6 possible die outcomes  = 96 files.&lt;/li&gt;
&lt;li&gt;The other subdirectories (&lt;code&gt;mozart-clarinet&lt;/code&gt;, &lt;code&gt;mozart-flute-harp&lt;/code&gt;, and &lt;code&gt;mozart-mbira&lt;/code&gt;)
provide the same measures for different instruments.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To play &lt;code&gt;minuet3-8.wav&lt;/code&gt; using a clarinet, call &lt;code&gt;StdAudio.play(&amp;quot;mozart-clarinet/minuet3-8.wav&amp;quot;)&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Write a program &lt;code&gt;MusicalDiceGame.java&lt;/code&gt; to play a waltz according to the rules above.
The program takes one command-line argument: the instrument subdirectory name (e.g., &lt;code&gt;mozart-piano&lt;/code&gt;).
Here are some sample executions:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs MusicalDiceGame mozart-piano&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-piano1.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-piano1.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-piano1.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-piano1.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs MusicalDiceGame mozart-piano&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-piano2.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-piano2.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-piano2.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-piano2.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs MusicalDiceGame mozart-clarinet&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-clarinet.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-clarinet.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-clarinet.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-clarinet.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs MusicalDiceGame mozart-flute-harp&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-flute-harp.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-flute-harp.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-flute-harp.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-flute-harp.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/loops&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs MusicalDiceGame mozart-mbira&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-mbira.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-mbira.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-mbira.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/loops/audio/waltz-mbira.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;
&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Context: Each run generates a new waltz from precomposed measures that follow a rigid harmonic structure. It sounds convincingly Mozart-like, but it rarely produces anything truly extraordinary.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all required files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Loops&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;SayMilitaryTime.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;RandomWalkers.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Duotone.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;MusicalDiceGame.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;MyPhoto.jpg&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;!--
Then click *Check Submitted Files* to check your work.
Fix all reported issues (including in `readme.txt` and `acknowledgments.txt`), then resubmit.
- You may upload files individually or in a batch.
- You may click *Check Submitted Files* at most 20 times per assignment.
--&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;File&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;SayMilitaryTime.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;8&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;RandomWalkers.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;8&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Duotone.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;9&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;MusicalDiceGame.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;9&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;MyPhoto.jpg&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;This assignment was developed by &lt;a href=&#34;https://www.cs.princeton.edu/~wayne&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Kevin Wayne&lt;/a&gt;. Copyright © 2022–2026.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>2. Arrays and Input/Output</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/arrays/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/arrays/</guid>
      <description>&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/arrays.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Arrays&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this assignment, you will write array-based programs that
read input with &lt;code&gt;StdIn&lt;/code&gt;,
print results with &lt;code&gt;StdOut&lt;/code&gt;,
draw graphics with &lt;code&gt;StdDraw&lt;/code&gt;,
play sound using &lt;code&gt;StdAudio&lt;/code&gt;.
You will also redirect standard input to read from a file.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Read Sections 1.4 and 1.5 of the textbook and review the corresponding lectures and precepts.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/arrays.zip&#34;&gt;arrays.zip&lt;/a&gt;
, then open the &lt;code&gt;arrays&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Take the &lt;a href=&#34;https://princeton.instructure.com/courses/22541&#34;&gt;Getting Help in COS 126 Quiz&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Consult the &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/guidelines/&#34;&gt;Programming Assignments FAQ&lt;/a&gt; as needed.&lt;/li&gt;
&lt;li&gt;Refer to the relevant textbook library APIs in the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/index.html#StdOut&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Java Cheatsheet&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Reminder:&lt;/em&gt; You may use only Java features introduced so far.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;dice-and-the-gaussian-distribution&#34;&gt;&lt;strong&gt;Dice and the Gaussian Distribution&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a program &lt;code&gt;DiceHistogram.java&lt;/code&gt; that takes two command-line arguments:
$n$ (the number of fair six-sided dice) and $trials$ (the number of trials).
Each trial consists of rolling all $n$ dice, summing the results, and recording the total.
Use an integer array to tabulate how many times each possible total occurs (from $n$ to $6n$)
over all trials. Then print a text histogram of the results.&lt;/p&gt;
&lt;p&gt;Print one line per total. Each line contains:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the total, right justified in a field of width 3,&lt;/li&gt;
&lt;li&gt;a colon,&lt;/li&gt;
&lt;li&gt;one space,&lt;/li&gt;
&lt;li&gt;a sequence of &lt;code&gt;*&lt;/code&gt; characters whose length equals the number of times that total occurred.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are a few sample executions.
Because the rolls are random, your output may vary.
However, when the number of trials is large, the histogram should resemble the examples below.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DiceHistogram 2 500&lt;/span&gt;
  2: **************
  3: ***************************
  4: *********************************
  5: *************************************************************
  6: **********************************************************************
  7: ******************************************************************************
  8: ***********************************************************************
  9: **********************************************************
 10: **********************************************
 11: ****************************
 12: **************

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DiceHistogram 10 1000&lt;/span&gt;
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18: *
 19: ****
 20:
 21: ***
 22: ******
 23: ********
 24: ****************
 25: *************
 26: **********
 27: *********************************
 28: ****************************************
 29: *********************************
 30: ***************************************************
 31: *****************************************************************
 32: ********************************************************
 33: **************************************************************************************
 34: ***********************************************************
 35: *********************************************************************
 36: ***********************************************************************************
 37: **************************************************************
 38: *****************************************************************
 39: ***************************************
 40: *****************************************************
 41: ************************************
 42: ****************************
 43: ************************
 44: ************************
 45: *********
 46: ***********
 47: *******
 48: ***
 49: **
 50:
 51:
 52: *
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 60:
&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Context: The central limit theorem, a key result in probability and statistics,
asserts that when the number of dice and trials is large, the histogram of the sums approaches
the familiar bell curve (Gaussian distribution).&lt;/em&gt;&lt;/p&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What values should my program handle for &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;trials&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Assume that $0 \leq n &amp;lt; 166$ (fits in a field of width 3)  and $trials \geq 0$.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I print an integer right-justified in a field of width 3?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Use  &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/index.html#printf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;formatted printing&lt;/a&gt;.
For example,&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;%3d&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;value&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I have the magic number 6 sprinkled through &lt;code&gt;DiceHistogram.java&lt;/code&gt;. Is there a better way?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Yes. Define a named constant and use it throughout. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;SIDES&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;6&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;echo-filter&#34;&gt;&lt;strong&gt;Echo Filter&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Consider what happens if you superpose a sound file with a delayed copy of itself.
You will hear the same sound twice, with the second instance slightly delayed.
If the $delay$ is relatively short (say, 15,000 samples or about 1/3 of a second)
and you reduce the loudness of the delayed copy by scaling its samples by a $decay$ factor
(e.g, multiply by 0.5),
the result is an echo effect, similar to what you might hear in a tunnel or large empty room.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example.&lt;/strong&gt; Consider the following sound wave:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/original.png&#34; width=&#34;500&#34; alt=&#34;delay = 3 and scale = 0.5&#34;&gt;&lt;/p&gt;
&lt;p&gt;Here is the same sound wave with $delay = 3$ (shift 3 positions to the right)
and $decay = 0.8$ (multiply by 0.8):
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/delay-decay.png&#34; width=&#34;500&#34; alt=&#34;original sound wave&#34;&gt;&lt;/p&gt;
&lt;p&gt;Superposing the two sound waves (adding them element-by-element) results in the following:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/result.png&#34; width=&#34;500&#34; alt=&#34;result&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Task.&lt;/strong&gt;
Write a program &lt;code&gt;EchoFilter.java&lt;/code&gt; that takes three command-line arguments:
a string filename, an integer delay, and a real-valued decay factor.
It applies an echo filter to the given sound file and plays the resulting sound.&lt;/p&gt;
&lt;p&gt;The length of the resulting sound (in samples) is the original length plus the delay.&lt;/p&gt;
&lt;p&gt;Here are some sample executions:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs EchoFilter IHaveADream.wav 0 0.0&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/IHaveADream.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/IHaveADream.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/IHaveADream.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/IHaveADream.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs EchoFilter IHaveADream.wav 15000 0.5&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoIHaveADream.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoIHaveADream.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoIHaveADream.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoIHaveADream.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs EchoFilter PearlHarbor.wav 15000 0.5&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoPearlHarbor.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoPearlHarbor.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoPearlHarbor.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoPearlHarbor.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs EchoFilter TheHillWeClimb.wav 10000 0.5&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoTheHillWeClimb.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoTheHillWeClimb.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoTheHillWeClimb.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoTheHillWeClimb.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs EchoFilter Crow.wav 10000 0.5&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoCrow.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoCrow.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoCrow.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoCrow.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs EchoFilter HelloWorld.wav 5000 1.0&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoHelloWorld.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoHelloWorld.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoHelloWorld.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoHelloWorld.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs EchoFilter RowYourBoat.wav 117600 1.0&lt;/span&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoRowYourBoat.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoRowYourBoat.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoRowYourBoat.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/audio/EchoRowYourBoat.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;
&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Context: An echo filter is a popular &lt;a href=&#34;https://backlightblog.com/voice-effects-on-tiktok&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;voice effect&lt;/a&gt;
that you can apply on social media platforms such as TikTok.&lt;/em&gt;&lt;/p&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Is &lt;code&gt;delay&lt;/code&gt; measured in samples?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. The echo begins &lt;code&gt;delay&lt;/code&gt; samples after the original sound.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I assume that &lt;code&gt;delay&lt;/code&gt; is a non-negative integer?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Negative delays correspond to &lt;a href=&#34;https://en.wikipedia.org/wiki/Reverse_echo&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;reverse echo&lt;/a&gt; effects,
but we will not test those cases.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I assume that &lt;code&gt;decay&lt;/code&gt; is between 0 and 1?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. We will test your program only with &lt;code&gt;decay&lt;/code&gt; values between 0 and 1.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Is it possible for &lt;code&gt;delay&lt;/code&gt; to be longer than the number of samples in the original array?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Think about an echo from a far-away mountain: the echo might not start until after the original
sound has ended.
If designed properly, your code will handle this case without extra conditional logic.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I test my program?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Start with a small example. For example, use &lt;code&gt;decay = 0.8&lt;/code&gt;, &lt;code&gt;delay = 3&lt;/code&gt;, and&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;original&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;25&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;to match the daigram above (and the sound in &lt;code&gt;tiny.wav&lt;/code&gt;).
This example is too small to play,
but you can print the resulting array to verify your calculations.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I print the contents of an array for debugging?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;If &lt;code&gt;a[]&lt;/code&gt; is an array, &lt;code&gt;System.out.println(a)&lt;/code&gt; prints a reference to the array
(not its elements).
To print the elements, use a &lt;code&gt;for&lt;/code&gt; loop.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How many times should my program call &lt;code&gt;StdAudio.play()&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Only once.  Call &lt;code&gt;StdAudio.play()&lt;/code&gt; with a &lt;code&gt;double[]&lt;/code&gt; array as argument.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;The echo filter repeats the sound only once. How could I get a repeating, decaying echo?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Superpose several delayed copies of the original sound,
with each successive copy shifted by a larger delay and scaled by a smaller decay factor.
Feel free to experiment with this idea.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;!--
### **Sound Wave Visualizer**

With digital audio, we model a sound wave as a sequence of real numbers between –1 and +1. In this exercise you will write a program to plot these values (using [`StdDraw`](https://introcs.cs.princeton.edu/java/11cheatsheet/index.html#StdDraw)) while playing the sound (using [`StdAudio`](https://introcs.cs.princeton.edu/java/11cheatsheet/index.html#StdAudio)), to produce a visualization like the following:

&lt;video class=&#34;video-shortcode&#34;  controls  width=750 poster=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/PianoSonata11ViewSoundWave.png&#34;&gt;
    &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/videos/PianoSonata11ViewSoundWave.webm&#34; type=&#34;video/webm&#34;&gt;
    There should have been a video here but your browser does not seem
    to support it.
&lt;/video&gt;


To produce the visualization, consider a sound wave and do the following:

-  Let $n$ denote the number of audio samples (each between –1 and +1).
-  Let $k$ be a parameter that specifies the number of groups. For now, assume $n$ is a multiple of $k$.
-  Treat the $n$ samples as being divided into \\(k\\) groups, with each group containing \\(n / k\\) successive samples, starting with sample 0.

- For each group \\(i\\):
  - Identify the largest *magnitude* (absolute value) of any sample in the group and let \\(y_i\\) denote that value.
   - Plot a vertical line segment between \\((i, y_i)\\) and \\((i, −y_i)\\).

Here is a tiny example with \\(n = 12\\) samples and \\(k = 3\\) groups:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/view-sound-wave.png&#34; width=&#34;500&#34; alt=&#34;Tiny view sound wave example&#34;&gt;


 Write a program `SoundWaveVisualizer.java` that takes two command-line arguments (the name of an audio file and an integer \\(k\\) for the number of groups) and plots the sound wave using the method described above. Additionally, as you process each individual sample in group \\(i\\), play it using `StdAudio.play(sample)`. That way, the visualization will be in sync with the audio.

- Set the canvas size to 1000-by-100 pixels by calling `StdDraw.setCanvasSize(1000, 100)`. This will make the window have a wide aspect ratio, suitable for visualizing sound waves.

- Set the range of the \\(x\\)-coordinates to be between \\(–1\\) and \\(k\\) by calling `StdDraw.setXscale(-1, k)` and set the range of the \\(y\\)-coordinates to be between \\(–1\\) and \\(+1\\) by calling `StdDraw.setYscale(-1, +1)`. This will make the line segments fit snugly in the drawing window.

- Change the pen color to a shade of blue by calling `StdDraw.setPenColor(StdDraw.BOOK_BLUE)`.

- Play the individual samples in group \\(i\\) and then plot the line segment corresponding to group \\(i\\).

- If \\(n\\) is not an exact multiple of \\(k\\), each group will have exactly \\(\lfloor n/k\rfloor\\) samples. Ignore the leftover samples. 

Here are some sample executions:



```plaintext
java-introcs SoundWaveVisualizer tiny.wav 3
```
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/TinyViewSoundWave.png&#34; width=&#34;500&#34; alt=&#34;visualization of tiny example with 12 samples&#34;&gt;

```plaintext
java-introcs SoundWaveVisualizer HelloWorld.wav 1000
&lt;video class=&#34;video-shortcode&#34;  controls  width=750 poster=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/HelloWorldViewSoundWave.png&#34;&gt;
    &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/videos/HelloWorldViewSoundWave.webm&#34; type=&#34;video/webm&#34;&gt;
    There should have been a video here but your browser does not seem
    to support it.
&lt;/video&gt;

```
```plaintext
java-introcs SoundWaveVisualizer PianoSonata11.wav 1000
&lt;video class=&#34;video-shortcode&#34;  controls  width=750 poster=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/PianoSonata11ViewSoundWave.png&#34;&gt;
    &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/videos/PianoSonata11ViewSoundWave.webm&#34; type=&#34;video/webm&#34;&gt;
    There should have been a video here but your browser does not seem
    to support it.
&lt;/video&gt;

```
```plaintext
java-introcs SoundWaveVisualizer IHaveADream.wav 1000
&lt;video class=&#34;video-shortcode&#34;  controls  width=750 poster=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/IHaveADreamViewSoundWave.png&#34;&gt;
    &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/videos/IHaveADreamViewSoundWave.webm&#34; type=&#34;video/webm&#34;&gt;
    There should have been a video here but your browser does not seem
    to support it.
&lt;/video&gt;

```


#### FAQs ####

Click on the &amp;#9658;  icon to expand and the  &amp;#9660; icon to hide each FAQ.

&lt;details&gt;
  &lt;summary&gt;How can I calculate the elements of &lt;code&gt;samples[]&lt;/code&gt; in group &lt;code&gt;i&lt;/code&gt;?&lt;/summary&gt;
  If each group has &lt;code&gt;groupSize&lt;/code&gt; samples, then the first element in group &lt;code&gt;i&lt;/code&gt; is &lt;code&gt;samples[i * groupSize]&lt;/code&gt; and the last element is &lt;code&gt;samples[(i + 1) * groupSize - 1]&lt;/code&gt;.
&lt;/details&gt;


&lt;details&gt;
  &lt;summary&gt;My program is slightly off when \(n\) is not a multiple of \(k\). It also produces an &lt;code&gt;ArrayIndexOutOfBoundsException&lt;/code&gt; on longer sound files. Why might this be?&lt;/summary&gt;
  It could be a result of integer division and integer overflow. For example, the expression &lt;code&gt;i * n / k&lt;/code&gt; for identifying the index of the first element in group &lt;code&gt;i&lt;/code&gt; is not equivalent to &lt;code&gt;i * (n / k)&lt;/code&gt;. Moreover, the former expression is susceptible to integer overflow.
&lt;/details&gt;


&lt;details&gt;
  &lt;summary&gt;If \(k\) is very large, the sound and visualization are choppy. Why is this?&lt;/summary&gt;
  Drawing on the screen is an expensive operation (in terms of CPU time). If \(k = n\), then you would be attempting to redraw the standard drawing window 44,100 times per second. (For reference, many LCD monitors and video games have a refresh rate of 60 Hz, so you wouldn&amp;rsquo;t be able to detect redraws at a rate higher than 60 times per second.)
&lt;/details&gt;


&lt;details&gt;
  &lt;summary&gt;Is this the actual algorithm used by various apps to visualize audio files?&lt;/summary&gt;
  Yes. It is known as the &lt;em&gt;MinMax algorithm&lt;/em&gt;. The &lt;em&gt;root mean square (RMS) algorithm&lt;/em&gt; is a popular competitor: instead of using the maximum absolute value of the samples in a group, it uses the square root of the sums of the squares of the samples in the group. You can also combine the two—plot the line segment for the &lt;em&gt;MinMax&lt;/em&gt; in in dark blue and the line segment for &lt;em&gt;RMS&lt;/em&gt; in light blue.
&lt;/details&gt;

--&gt;
&lt;h3 id=&#34;world-maps&#34;&gt;&lt;strong&gt;World Maps&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a program &lt;code&gt;WorldMap.java&lt;/code&gt; that reads boundary data for a country (or other geographic entity)
from standard input (using &lt;code&gt;StdIn&lt;/code&gt;) and draws it to standard drawing (using &lt;code&gt;StdDraw&lt;/code&gt;).
A country consists of a set of &lt;em&gt;regions&lt;/em&gt; (e.g., states or provinces).
Each region is described by a polygon.
Represent a polygon using &lt;em&gt;two&lt;/em&gt; floating-point arrays:
one containing the $x$-coordinates and the other containing the $y$-coordinates of the polygon&amp;rsquo;s vertices.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Input format.&lt;/em&gt;   The first line contains two integers: width and height.
The remainder of the input is divided into regions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The first token in each region is the region name. For simplicity, names contain no spaces.&lt;/li&gt;
&lt;li&gt;The next token is an integer specifying the number of vertices in the region&amp;rsquo;s polygon.&lt;/li&gt;
&lt;li&gt;The remaining tokens in the region are the $x$- and $y$-coordinates of the vertices.
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/map-input.png&#34; width=&#34;350&#34; alt=&#34;Map input example&#34;&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Output format.&lt;/em&gt;  Draw the polygons to standard drawing, using the following guidelines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Call &lt;code&gt;StdDraw.setCanvasSize()&lt;/code&gt; to set the size of the canvas to &lt;em&gt;width-by-height&lt;/em&gt; pixels.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Call &lt;code&gt;StdDraw.setXscale()&lt;/code&gt; and &lt;code&gt;StdDraw.setYscale()&lt;/code&gt; so that the $x$-coordinates
range from 0 to &lt;em&gt;width&lt;/em&gt; and the $y$-coordinates range from 0 to &lt;em&gt;height&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Call &lt;code&gt;StdDraw.polygon()&lt;/code&gt; to draw each polygon. This method takes two arrays as arguments: the array of
$x$-coordinates and the array of $y$-coordinates.
It draws the polygon whose vertices are given by those $x$- and $y$-coordinates.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- - Use *double buffering* to speed up your program. --&gt;
&lt;!-- - Do *not* call any other drawing methods in `StdDraw`. --&gt;
&lt;p&gt;&lt;em&gt;Data files.&lt;/em&gt;  The project folder includes the following data files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;static/assignments/arrays/files/shapes.txt&#34;&gt;shapes.txt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;static/assignments/arrays/files/usa.txt&#34;&gt;usa.txt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;static/assignments/arrays/files/iceland.txt&#34;&gt;iceland.txt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;static/assignments/arrays/files/world.txt&#34;&gt;world.txt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;static/assignments/arrays/files/world&#34;&gt;100+ country files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;static/assignments/arrays/files/usa&#34;&gt;all 50 U.S. state files&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are some sample executions:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs WorldMap &amp;lt; shapes.txt&lt;/span&gt;

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/shapes.png&#34; width=&#34;200&#34; alt=&#34;Different shapes&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs WorldMap &amp;lt; usa.txt&lt;/span&gt;

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/usa.png&#34; width=&#34;400&#34; alt=&#34;USA&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs WorldMap &amp;lt; iceland.txt&lt;/span&gt;

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/iceland.png&#34; width=&#34;400&#34; alt=&#34;Iceland&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/arrays&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs WorldMap &amp;lt; world.txt&lt;/span&gt;

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/arrays/images/world.png&#34; width=&#34;400&#34; alt=&#34;World&#34;&gt;
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I assume the input file is properly formatted?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. You may assume it matches the specified format (the expected number, order,
and types of tokens).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What if a region has multiple boundary polygons?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;In the input file, it appears as multiple regions, one polygon per region.
So, you don&amp;rsquo;t need to handle multi-polygon regions.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I draw the boundary of a region as a sequence of line segments instead of a polygon?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. You must draw each region using &lt;code&gt;StdDraw.polygon()&lt;/code&gt;, as specified.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;My program runs slowly for inputs with a large number of regions. Any way to speed it up?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Yes. By default, as soon as you call a drawing method such as &lt;code&gt;StdDraw.polygon()&lt;/code&gt;,
the result appears on screen.
Updating the screen is relatively expensive (in terms of CPU time).
If there are thousands of geometric objects to draw, this can slow down your program considerably.
To avoid this slowdown, use the &lt;em&gt;double-buffering feature&lt;/em&gt; of standard draw:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Call &lt;code&gt;StdDraw.enableDoubleBuffering()&lt;/code&gt; once before any drawing code.
Now all drawing is done on an offscreen canvas.&lt;/li&gt;
&lt;li&gt;Call the drawing commands such as &lt;code&gt;StdDraw.polygon()&lt;/code&gt;. Nothing will appear on screen yet.&lt;/li&gt;
&lt;li&gt;Call &lt;code&gt;StdDraw.show()&lt;/code&gt;. This transfers the offscreen canvas to the onscreen canvas.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can think of double buffering as collecting all drawing commands and then displaying them all at once.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;My favorite country is not supplied as one of the data files. Why not?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Some of the source data files we used had technical discrepancies,
which made converting them into our format more challenging.
If you wish to add a country, please send us an input file in the specified format.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;The displayed map distorts the areas of regions. How can I fix this?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Every &lt;a href=&#34;https://en.wikipedia.org/wiki/Map_projection&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;map projection&lt;/a&gt; that represents a sphere
on a plane introduces some distortion.
For example, with the &lt;a href=&#34;https://en.wikipedia.org/wiki/Mercator_projection&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Mercator projection&lt;/a&gt;,
Greenland appears to be about the same size as Africa;
in reality, Africa is 14 times larger by area.
The &lt;a href=&#34;https://en.wikipedia.org/wiki/Gall%E2%80%93Peters_projection&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Gall–Peters projection&lt;/a&gt;
reduces area distortion but distorts shapes instead.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all required files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Arrays&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;DiceHistogram.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;EchoFilter.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;WorldMap.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- Also, complete the [Getting Help quiz](https://princeton.instructure.com/courses/22541). --&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Files&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;DiceHistogram.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;EchoFilter.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;WorldMap.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Getting Help Quiz&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;This assignment was developed by &lt;a href=&#34;https://www.cs.princeton.edu/~wayne&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Kevin Wayne&lt;/a&gt;. Copyright © 2022–2026.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>3. Conjunction Function</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/functions/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/functions/</guid>
      <description>&lt;!--&lt;p style=&#34;color:red;&#34;&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt;  This assignment has not been officially released yet and is subject to change!&lt;/p&gt;

--&gt;
&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/functions/functions.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Functions&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this assignment, you will implement functions that manipulates digital audio,
then use them to create an audio collage.
You will learn how to develop reusable functions, pass and return arrays, and manipulate audio.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Read Sections 2.1 and 2.2 of the textbook and review the corresponding lectures and precepts.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/functions/functions.zip&#34;&gt;functions.zip&lt;/a&gt;
, then open the &lt;code&gt;functions&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Refer to the &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/guidelines/&#34;&gt;Programming Assignments FAQ&lt;/a&gt; as needed.&lt;/li&gt;
&lt;li&gt;Review the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#StdAudio&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;StdAudio API&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;part-i-audio-library&#34;&gt;&lt;strong&gt;Part I: Audio Library&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a program &lt;code&gt;AudioCollage.java&lt;/code&gt; to manipulate digital audio.
As in lecture, we represent sound as an array of real numbers between –1 and +1, with 44,100 samples per second.
You will implement functions that produce audio effects by transforming these arrays.&lt;/p&gt;
&lt;p&gt;Implement the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;AudioCollage&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a new array that rescales a[] by a factor of alpha.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;amplify&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;alpha&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a new array that clamps each sample to  the range [-1, +1].&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;clamp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a new array that contains the samples of a[] in reverse order.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;reverse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a new array that is the concatenation of a[] followed by b[].&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;merge&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a new array that mixes a[] and b[] by adding corresponding&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// samples. If one array is shorter, treat missing samples as 0.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;mix&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a new array that changes the speed of a[] by a factor of alpha.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;changeSpeed&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;alpha&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates an audio collage and plays it on standard audio.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// See Part II of the assignment specification for requirements.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here is additional documentation for the API:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Each function returns a new array and does not modify its argument array(s).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You may assume that all array arguments are non-null.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Do not add &lt;code&gt;public&lt;/code&gt; methods; you may add &lt;code&gt;private&lt;/code&gt; helper methods.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4 id=&#34;amplifydouble-a-alpha&#34;&gt;&lt;code&gt;amplify(double[] a, alpha)&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Returns a new array with the same length as &lt;code&gt;a[]&lt;/code&gt;, where each sample is
multiplied by a constant $\alpha$.
If  $|\alpha| &amp;gt; 1$, the result is louder; if  $|\alpha| &amp;lt; 1$, it is quieter.
For example:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/functions/images/amplify.png&#34; width=&#34;400&#34; alt=&#34;Amplifying a single sample array&#34;&gt;&lt;/p&gt;
&lt;p&gt;Note: &lt;code&gt;amplify()&lt;/code&gt; may produce samples whose absolute value exceed 1, even if all input samples are between –1 and +1.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4 id=&#34;clampdouble-a&#34;&gt;&lt;code&gt;clamp(double[] a)&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Returns a new array where each sample in &lt;code&gt;a[]&lt;/code&gt; is &amp;ldquo;clamped&amp;rdquo; to the range [–1, +1]:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;values greater than +1 become +1&lt;/li&gt;
&lt;li&gt;values less than –1 become –1&lt;/li&gt;
&lt;li&gt;values between –1 and +1 are unchanged&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/functions/images/clamp.png&#34; width=&#34;400&#34; alt=&#34;Clamping a single sample array&#34;&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4 id=&#34;reversedouble-a&#34;&gt;&lt;code&gt;reverse(double[] a)&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Returns a new array with the same samples as &lt;code&gt;a[]&lt;/code&gt;, but in reverse order.
This can lead to unexpected (and sometimes entertaining) results.
For example:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/functions/images/reverse.png&#34; width=&#34;400&#34; alt=&#34;Reversing a single sample array&#34;&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4 id=&#34;mergedouble-a-double-b&#34;&gt;&lt;code&gt;merge(double[] a, double[] b)&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Returns a new array that contains the samples of &lt;code&gt;a[]&lt;/code&gt; followed by the samples of &lt;code&gt;b[]&lt;/code&gt;.
If the two sounds have lengths $m$ and $n$, the resulting array has length $m + n$.
This enables you to play two sounds sequentially. For example:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/functions/images/merge.png&#34; width=&#34;400&#34; alt=&#34;Merging two audio sample arrays&#34;&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4 id=&#34;mixdouble-a-double-b&#34;&gt;&lt;code&gt;mix(double[] a, double[] b)&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Returns a new array that adds the corresponding samples of &lt;code&gt;a[]&lt;/code&gt; and &lt;code&gt;b[]&lt;/code&gt; (sample-by-sample).
If one array is shorter, treat missing samples as 0.
This enables you to play two sounds simultaneously.
For example:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/functions/images/mix.png&#34; width=&#34;400&#34; alt=&#34;Mixing two audio sample arrays&#34;&gt;&lt;/p&gt;
&lt;p&gt;Note: &lt;code&gt;mix()&lt;/code&gt; may produce samples whose absolute value exceed 1, even if all input samples are between –1 and +1.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4 id=&#34;changespeeddouble-a-double-alpha&#34;&gt;&lt;code&gt;changeSpeed(double[] a, double alpha)&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Returns a new array that changes the duration of &lt;code&gt;a[]&lt;/code&gt; by resampling, using  speed factor $\alpha &amp;gt; 0$.
The returned array has length $\lfloor n / \alpha \rfloor$,
where $n$ is the length of &lt;code&gt;a[]&lt;/code&gt;.
Sample $i$ of the returned array has the same value as sample $\lfloor i \alpha \rfloor$ of &lt;code&gt;a[]&lt;/code&gt;.
Larger $\alpha$ plays the sound faster (shorter duration);
smaller $\alpha$ plays it slower (longer duration).
For example:
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/functions/images/changeSpeed.png&#34; width=&#34;400&#34; alt=&#34;Changing the speed of a single audio sample array&#34;&gt;&lt;/p&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Which does the notation $\lfloor  x \rfloor$ mean?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It is the floor function: the largest integer less than or equal to  $x$.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How can I compute $\lfloor  x \rfloor$ in Java?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Cast &lt;code&gt;x&lt;/code&gt; to an &lt;code&gt;int&lt;/code&gt;, which discards the fractional part (rounds toward 0).
If &lt;code&gt;x&lt;/code&gt; is nonnegative, this equals $\lfloor  x \rfloor$.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;The &lt;code&gt;changeSpeed()&lt;/code&gt; function changes not only the speed of the sound, but also its pitch. Why?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Resampling changes the playback rate. Speeding up the sound raises the pitch, producing the
&lt;a href=&#34;https://en.wikipedia.org/wiki/Alvin_and_the_Chipmunks#Recording_technique&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&amp;ldquo;chipmunk&amp;rdquo;&lt;/a&gt; effect.
More sophisticated &lt;a href=&#34;https://en.wikipedia.org/wiki/Audio_time_stretching_and_pitch_scaling&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;time-stretching techniques&lt;/a&gt;
can change speed without changing pitch.
That&amp;rsquo;s the kind of technique used, for example, when you watch a lecture recording at 2× speed
while keeping the speaker’s voice at a natural pitch.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;part-ii-audio-collage&#34;&gt;&lt;strong&gt;Part II: Audio Collage&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Now use your library methods to create an audio collage.
In &lt;code&gt;main()&lt;/code&gt;, build a single array of samples that represents your collage,
then play it using &lt;code&gt;StdAudio&lt;/code&gt;. Follow these requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;At least 5 WAV files.&lt;/strong&gt; Use at least five different WAV files. Several are provided, and you may also supply your own.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use all audio effects.&lt;/strong&gt; The collage must use every function from the API: amplify, reverse, merge, mix, change speed, and clamp.
You may also add additional effects (see ideas below).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Duration.&lt;/strong&gt; The collage must be between 10 and 60 seconds (441,000 to 2,646,000 samples).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No command-line arguments.&lt;/strong&gt; Do not use command-line arguments.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Valid samples.&lt;/strong&gt; All samples passed to standard audio must be between –1 and +1.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Be creative.&lt;/strong&gt; We plan to post your audio collages.&lt;/li&gt;
&lt;/ul&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I read a WAV file and extract its samples?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Call &lt;code&gt;StdAudio.read()&lt;/code&gt;. It returns a &lt;code&gt;double[]&lt;/code&gt; containing samples between –1 and +1.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdAudio&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;read&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;cow.wav&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How can I convert an audio file to WAV format?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use an online conversion utility, such as &lt;a href=&#34;https://audio.online-convert.com/convert-to-wav&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Online-Convert&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is a WAV file?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;A WAV file (Waveform Audio File Format) is a popular format for storing raw, typically uncompressed, audio data.
For details, see the &lt;a href=&#34;https://en.wikipedia.org/wiki/WAV&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Wikipedia page&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can intermediate samples be outside the prescribed range?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Intermediate arrays may contain values outside –1 and +1,
but the samples you pass to standard audio must be between –1 and +1.
One way to ensure this is to call &lt;code&gt;clamp()&lt;/code&gt; on final array.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;implementing-other-audio-effects&#34;&gt;Implementing Other Audio Effects&lt;/h3&gt;
&lt;p&gt;You may implement additional functions that produce other audio effects.
Any such helper must be &lt;code&gt;private&lt;/code&gt;. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;private&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;mirror&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;...&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Some ideas include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;normalize&lt;/em&gt;: rescale a sound so that all samples are between –1 and +1.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;cut&lt;/em&gt;: extract a contiguous subarray from a sound.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;trim&lt;/em&gt;: remove leading and trailing samples that are 0 (or nearly 0).&lt;/li&gt;
&lt;li&gt;&lt;em&gt;loop&lt;/em&gt;: repeat a sound a specified number of times.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;mirror&lt;/em&gt;: concatenate a sound with its reverse.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;hip–hop&lt;/em&gt;: speed up a sound, mirror it, then loop it.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;echo / delay / reverb&lt;/em&gt;: add a time-delayed copy of a sound to itself, attenuated by a scale factor.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;fade-in / fade-out&lt;/em&gt;: gradually increase or decrease the volume at the beginning or end of a sound.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;crossfade&lt;/em&gt;: fade out the first sound while fading in the second, with an overlap.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;tremolo&lt;/em&gt;: create a trembling effect by modulating the amplitude over time.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You may also synthesize your own sounds by generating a sine, square, triangle, or sawtooth wave with a given amplitude, frequency, and duration.&lt;/p&gt;
&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Functions&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;AudioCollage.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Any supplementary WAV files (do not submit the WAV files we provided).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you submit supplementary WAV files, cite their source in &lt;code&gt;readme.txt&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We may publish selected collages (anonymously) on the course website.
Publishing is optional: if you do not wish your work to be published,
indicate this in &lt;code&gt;readme.txt&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;File&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;AudioCollage.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;36&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&#34;credits&#34;&gt;&lt;strong&gt;Credits&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;This assignment was inspired by an audio effects &lt;a href=&#34;http://katie.mtech.edu/classes/archive/f11/csci135/assign/audio/index.php&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;programming assignment&lt;/a&gt; by Keith Vertanen.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The assignment name is a play on the &lt;a href=&#34;https://en.wikipedia.org/wiki/Schoolhouse_Rock!&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;https://en.wikipedia.org/wiki/Schoolhouse_Rock!&lt;/a&gt; title &lt;em&gt;Conjunction Junction&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>4. Recursion</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/recursion/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/recursion/</guid>
      <description>&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/recursion.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Recursion&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this assignment,
you will compute Delannoy numbers using recursion and dynamic programming.
You will plot a Sierpinski triangle using recursion,
then create an original recursive pattern of your own design.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Read Sections 2.3 and 4.1 of the textbook and review the corresponding lectures and precepts.&lt;/li&gt;
&lt;li&gt;Review the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#StdDraw&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;StdDraw API&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/recursion.zip&#34;&gt;recursion.zip&lt;/a&gt;
, then open the &lt;code&gt;recursion&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- - Make sure you understand the lecture materials and the precept exercises before proceeding. Refer to the lecture and precept examples while you are coding. --&gt;
&lt;!-- - Refer to  our [style guide for writing clear programs](https://introcs.cs.princeton.edu/java/11style) and  our [programming assignment coding guidelines](https://www.cs.princeton.edu/courses/archive/fall26/cos126/guidelines/), as needed. --&gt;
&lt;!-- - Remember to comment **while** you code, not after!  This will help you understand your approach, as well as assist those who might be helping you to debug your solution. --&gt;
&lt;!-- - Do not add public methods to the API. You may add private methods. --&gt;
&lt;h3 id=&#34;delannoy-numbers-brute-force&#34;&gt;&lt;strong&gt;Delannoy Numbers (brute force)&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a program &lt;code&gt;DelannoyBrute.java&lt;/code&gt; that takes two integer command-line arguments $m$ and $n$
and prints the &lt;em&gt;Delannoy number&lt;/em&gt; $D(m, n)$.
The Delannoy number $D(m, n)$ is the number of paths from $(0,0)$ to $(m, n)$ in an $m$-by-$n$ grid
using only single steps north, east, and northeast.&lt;/p&gt;
&lt;p&gt;For example, $D(2, 2) = 13$ because these are $13$ Delannoy paths in a 2-by-2 grid:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/delannoy22.png&#34; width=&#34;650&#34; alt=&#34;[13  Delannoy paths in a 2-by-2 grid&#34;&gt;
&lt;p&gt;Use the following recurrence to compute $D(m,n)$:&lt;/p&gt;
&lt;p&gt;$$
\displaystyle D(m, n) \; = \;
\begin{cases}
\;\; 1 &amp;amp; \text{if } m = 0 \\[.5em]
\;\; 1 &amp;amp; \text{if } n = 0 \\[.5em]
\;\; D(m-1, n) + D(m-1, n-1) + D(m, n-1) &amp;amp; \text{otherwise}
\end{cases}
$$
&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Organize your program according to the following public API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;DelannoyBrute&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the Delannoy number D(m, n).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;long&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Takes two integer command-line arguments m and n and prints D(m, n).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This brute-force approach is far too slow, even for moderately small $m$ and $n$.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 2 2&lt;/span&gt;
13

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 3 2&lt;/span&gt;
25

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 2 3&lt;/span&gt;
25

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 3 3&lt;/span&gt;
63

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 20 20&lt;/span&gt;
[takes too long]
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I assume $m \ge 0$ and $n \ge 0$?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Delannoy numbers are defined only for nonnegative integers  $m$ and $n$.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;em&gt;Context: Delannoy numbers arise in combinatorics and computational biology.
For example, $D(m,n)$ is the number of global alignments of two strings of lengths $m$ and $n$.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;delannoy-numbers-dynamic-programming&#34;&gt;&lt;strong&gt;Delannoy Numbers (dynamic programming)&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Now, write a program &lt;code&gt;DelannoyMemo.java&lt;/code&gt; that takes two integer command-line arguments $m$ and $n$
and computes the Delannoy number $D(m, n)$ using dynamic programming (memoization).
Model your solution after &lt;code&gt;FibonacciMemo.java&lt;/code&gt; (lecture) and &lt;code&gt;PalindromeMemo.java&lt;/code&gt; (precept).
Use a &lt;code&gt;private&lt;/code&gt; &lt;code&gt;static&lt;/code&gt; two-dimensional array &lt;code&gt;memo[][]&lt;/code&gt; such that &lt;code&gt;memo[i][j]&lt;/code&gt; stores $D(i, j)$.&lt;/p&gt;
&lt;p&gt;Organize your program according to the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;DelannoyMemo&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the Delannoy number D(m, n).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;long&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Takes two integer command-line arguments m and n and prints D(m, n).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Below are some sample executions.
Unlike the brute-force version, the memoization version is fast enough to handle much larger values of $m$ and $n$.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 2 2&lt;/span&gt;
13

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 3 2&lt;/span&gt;
25

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 2 3&lt;/span&gt;
25

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 3 3&lt;/span&gt;
63

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 20 20&lt;/span&gt;
260543813797441
&lt;/pre&gt;

&lt;h3 id=&#34;analysis&#34;&gt;Analysis&lt;/h3&gt;
&lt;p&gt;Conduct the following computational experiments and measure the running time:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 2 2&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 4 4&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 8 8&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyBrute 16 16&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 2 2&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 4 4&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 8 8&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs DelannoyMemo 16 16&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xss10m DelannoyMemo 3000 3000&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xss10m DelannoyMemo 6000 6000&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xss10m DelannoyMemo 12000 12000&lt;/span&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xss10m DelannoyMemo 24000 24000&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;Based on the results, answer the following questions in &lt;code&gt;readme.txt&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Which runs faster:  &lt;code&gt;DelannoyBrute.count()&lt;/code&gt; or &lt;code&gt;DelannoyMemo.count()&lt;/code&gt; ?&lt;/li&gt;
&lt;li&gt;Estimate the order of growth of the running time of &lt;code&gt;DelannoyBrute.count(n, n)&lt;/code&gt; as a function of $n$?&lt;/li&gt;
&lt;li&gt;Estimate the order of growth of the running time of &lt;code&gt;DelannoyMemo.count(n, n)&lt;/code&gt; as a function of $n$.&lt;/li&gt;
&lt;/ul&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What does the command-line option &lt;code&gt;-Xss10m&lt;/code&gt; do?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It increases the Java thread stack size to 10 MB (more room for deep recursion).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I&amp;rsquo;m getting a &lt;code&gt;java.lang.OutOfMemoryError&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Try allocating more heap memory with &lt;code&gt;-Xmx&lt;/code&gt;.
The heap is used for arrays and other objects.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt;java-introcs -Xss50m -Xmx5g DelannoyMemo &lt;span class=&#34;m&#34;&gt;24000&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;24000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Should I worry if &lt;code&gt;count()&lt;/code&gt; overflows a &lt;code&gt;long&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. For the analysis, you can ignore the return value of&lt;code&gt;count()&lt;/code&gt; since it does not impact the running time.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How should I measure the running time of &lt;code&gt;count()&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Instrument your program as in precept using &lt;code&gt;System.currentTimeMillis()&lt;/code&gt;.
But be sure to remove this code before submitting.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;sierpinski-triangle&#34;&gt;&lt;strong&gt;Sierpinski Triangle&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;The Sierpinski triangle is a classic fractal pattern, like the H-tree from Section 2.3 of the textbook.&lt;/p&gt;
&lt;style&gt;
.sier-grid { 
  display: grid; 
  grid-template-columns: repeat(3, 1fr); 
  gap: 22px 112px; 
  text-align: center; 
}
.sier-grid p,
.sier-grid figure { margin: 0; }          /* kill shortcode wrapper margins */
.sier-grid img { display: block; margin: 0 auto; } /* remove inline baseline gap */
.sier-label { margin-top: 18px; font-size: 0.85em; line-height: 1.1; }
&lt;/style&gt;
&lt;div class=&#34;sier-grid&#34;&gt;
  &lt;div&gt;
    &lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski1.svg&#34; width=&#34;200&#34; alt=&#34;Sierpinski triangle of order 1&#34;&gt;
    &lt;div class=&#34;sier-label&#34;&gt;&lt;strong&gt;Order 1&lt;/strong&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski2.svg&#34; width=&#34;200&#34; alt=&#34;Sierpinski triangle of order 2&#34;&gt;
    &lt;div class=&#34;sier-label&#34;&gt;&lt;strong&gt;Order 2&lt;/strong&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski3.svg&#34; width=&#34;200&#34; alt=&#34;Sierpinski triangle of order 3&#34;&gt;
    &lt;div class=&#34;sier-label&#34;&gt;&lt;strong&gt;Order 3&lt;/strong&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski4.svg&#34; width=&#34;200&#34; alt=&#34;Sierpinski triangle of order 4&#34;&gt;
    &lt;div class=&#34;sier-label&#34;&gt;&lt;strong&gt;Order 4&lt;/strong&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski5.svg&#34; width=&#34;200&#34; alt=&#34;Sierpinski triangle of order 5&#34;&gt;
    &lt;div class=&#34;sier-label&#34;&gt;&lt;strong&gt;Order 5&lt;/strong&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski6.svg&#34; width=&#34;200&#34; alt=&#34;Sierpinski triangle of order 6&#34;&gt;
    &lt;div class=&#34;sier-label&#34;&gt;&lt;strong&gt;Order 6&lt;/strong&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;
&lt;p&gt;Despite its complexity, the Sierpinski triangle can be generated with a short recursive function.
Your primary task is to write &lt;code&gt;sierpinski()&lt;/code&gt;, which draws a Sierpinski triangle of order $n$
at a specified location and size.
It should draw one filled, downward-pointing equilateral triangle,
then call itself three times (with an appropriate base case).&lt;/p&gt;
&lt;p&gt;Organize your program into four functions, as specified in the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Sierpinski&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Height of an equilateral triangle with the given side length.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;height&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Draws a filled equilateral triangle with the given side length&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// whose bottom vertex is at (x, y).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;filledTriangle&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;y&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Draws a Sierpinski triangle of order n in which the largest filled&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// triangle has the given side length and bottom vertex at (x, y).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;sierpinski&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;y&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Takes an integer command-line argument n; draws the outline of an&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// upward-pointing equilateral triangle of side length 1 with vertices&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// (0, 0), (1, 0), and (1/2, sqrt(3) / 2); and draws a Sierpinski&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// triangle of order n that fits inside the outline.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;geometry&#34;&gt;Geometry&lt;/h4&gt;
&lt;p&gt;The diagram below shows the outline triangle and an order-2 Sierpinski triangle inside it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The outline triangle has vertices $(0, 0)$, $(1, 0)$, and $( 1 / 2, \sqrt{3} / 2)$.&lt;/li&gt;
&lt;li&gt;The order-2 Sierpinski triangle  has side length $1 / 2$ and bottom vertex is $(1 / 2 , 0)$.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/equilateral-triangle-initial.png&#34; width=&#34;350&#34; alt=&#34;Equilateral triangle&#34;&gt;
&lt;p&gt;The diagram below shows a downward-pointing equilateral triangle of side length $s$
whose bottom vertex is $(x, y)$.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The height is $h =  s \sqrt{3} \; / \; 2$.&lt;/li&gt;
&lt;li&gt;The vertices are $(x, y)$, $(x - s/2, y + h)$, and $(x + s/2, y + h)$.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/equilateral-triangle-downward.png&#34; width=&#34;420&#34; alt=&#34;Equilateral triangle&#34;&gt;
&lt;!-- -  The bottom vertices (highlighted in red) of the three recursive subtriangles are
    $(x - s/2, y)$, $(x + s/2, y)$, and $(x, y + h)$.
--&gt;
&lt;h4 id=&#34;requirements&#34;&gt;Requirements&lt;/h4&gt;
&lt;p&gt;When implementing &lt;code&gt;Sierpinski.java&lt;/code&gt;, follow these requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Draw filled triangles using &lt;code&gt;StdDraw.filledPolygon()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Draw the outline triangle using &lt;code&gt;StdDraw.polygon()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Do not call any method in &lt;code&gt;StdDraw&lt;/code&gt; besides &lt;code&gt;polygon()&lt;/code&gt; and &lt;code&gt;filledPolygon()&lt;/code&gt;.
These restrictions ensure consistent grading output.&lt;/li&gt;
&lt;li&gt;Do not add any public methods. You may add private helper methods.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are some sample executions. Your output should match exactly.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 1&lt;/span&gt; 

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski1.svg&#34; width=&#34;250&#34; alt=&#34;Order 1 Sierpinski triangle&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 2&lt;/span&gt;

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski2.svg&#34; width=&#34;250&#34; alt=&#34;Order 2 Sierpinski triangle&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 3&lt;/span&gt;

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/recursion/images/sierpinski3.svg&#34; width=&#34;250&#34; alt=&#34;Order 3 Sierpinski triangle&#34;&gt;

&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;&lt;strong&gt;I&amp;rsquo;m stuck. Can you suggest some steps for making steady, incremental progress?&lt;/strong&gt;&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;These steps are optional. Use them as needed.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Review &lt;a href=&#34;https://introcs.cs.princeton.edu/23recursion/Htree.java.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Htree.java&lt;/a&gt;
from the textbook, lecture, and precept.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create &lt;code&gt;Sierpinski.java&lt;/code&gt;. Copy the provided API into the file,
then make the minimal changes needed for it to compile.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write the function &lt;code&gt;height()&lt;/code&gt;.
The body of this method should be a one-liner (no recursion).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test:&lt;/strong&gt; In &lt;code&gt;main()&lt;/code&gt;, call &lt;code&gt;height()&lt;/code&gt; a few times with different arguments and verify the results.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;code&gt;main()&lt;/code&gt;, draw the outline of the initial equilateral triangle. Use &lt;code&gt;height()&lt;/code&gt; to compute the top vertex.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write &lt;code&gt;filledTriangle(x, y, length)&lt;/code&gt;. Again, no recursion.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test:&lt;/strong&gt; In &lt;code&gt;main()&lt;/code&gt;, call &lt;code&gt;filledTriangle()&lt;/code&gt; a few times with different arguments and verify the results.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now implement the &lt;em&gt;recursive&lt;/em&gt; function &lt;code&gt;sierpinski()&lt;/code&gt;. Use an incremental approach:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Write a recursive function &lt;code&gt;sierpinski()&lt;/code&gt; that takes one argument &lt;code&gt;n&lt;/code&gt;,
prints the value &lt;code&gt;n&lt;/code&gt;, and then calls itself three times with the value &lt;code&gt;n-1&lt;/code&gt;.
The recursion should stop when &lt;code&gt;n&lt;/code&gt; becomes 0.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test:&lt;/strong&gt; in &lt;code&gt;main()&lt;/code&gt;, read &lt;code&gt;n&lt;/code&gt; from the command line and call &lt;code&gt;sierpinski(n)&lt;/code&gt;.
Ignoring whitespace, your output should match the output below.
Make sure you understand why the values are printed in that order.&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 0&lt;/span&gt;
[no output]

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 1&lt;/span&gt;
1

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 2&lt;/span&gt;
2
1
1
1

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 3&lt;/span&gt;
3
2 1 1 1
2 1 1 1
2 1 1 1

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 4&lt;/span&gt;
4
3 2 1 1 1 2 1 1 1 2 1 1 1
3 2 1 1 1 2 1 1 1 2 1 1 1
3 2 1 1 1 2 1 1 1 2 1 1 1
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Modify &lt;code&gt;sierpinski()&lt;/code&gt; so that it prints both &lt;code&gt;n&lt;/code&gt; and the triangle side length.
The method should now take two arguments: &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;length&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;code&gt;main()&lt;/code&gt;, call &lt;code&gt;sierpinski(n, 0.5)&lt;/code&gt;, since the largest filled triangle has side length 0.5.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;At each recursive level, halve &lt;code&gt;length&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test:&lt;/strong&gt;  Ignoring whitespace, your program should produce the output below:&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 0&lt;/span&gt;
[no output]

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 1&lt;/span&gt;
1 0.5

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 2&lt;/span&gt;
2 0.5
1 0.25
1 0.25
1 0.25

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 3&lt;/span&gt;
3 0.5
2 0.25  1 0.125  1 0.125  1 0.125
2 0.25  1 0.125  1 0.125  1 0.125
2 0.25  1 0.125  1 0.125  1 0.125

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/recursion&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Sierpinski 4&lt;/span&gt;
4 0.5
3 0.25  2 0.125  1 0.0625  1 0.0625  1 0.0625
2 0.125  1 0.0625  1 0.0625  1 0.0625
2 0.125  1 0.0625  1 0.0625  1 0.0625
3 0.25  2 0.125  1 0.0625  1 0.0625  1 0.0625
2 0.125  1 0.0625  1 0.0625  1 0.0625
2 0.125  1 0.0625  1 0.0625  1 0.0625
3 0.25  2 0.125  1 0.0625  1 0.0625  1 0.0625
2 0.125  1 0.0625  1 0.0625  1 0.0625
2 0.125  1 0.0625  1 0.0625  1 0.0625
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Modify &lt;code&gt;sierpinski()&lt;/code&gt; so that it takes four arguments:   &lt;code&gt;n&lt;/code&gt;, &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, and &lt;code&gt;length&lt;/code&gt;.
The method should &lt;em&gt;draw&lt;/em&gt; a Sierpinski triangle of order &lt;code&gt;n&lt;/code&gt; with side length &lt;code&gt;length&lt;/code&gt;
and bottom vertex $(x, y)$.
This is one of the more challenging steps, so sketch a few levels on paper first.
Which arguments change between the three recursive calls?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test:&lt;/strong&gt; Your program should draw the Sierpinski triangles that match the sample
executions above the Possible Progress Steps.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Remove all print statements before submitting to &lt;em&gt;TigerFile&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;em&gt;Context: The Polish mathematician Wacław Sierpiński described this pattern in 1915,
but similar motifs appear in Italian art dating back to the 13th century.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;create-your-recursive-art&#34;&gt;&lt;strong&gt;Create Your Recursive Art&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;In this part, you will write&lt;code&gt;Art.java&lt;/code&gt;, a program that produces a recursive drawing of your own design.
This part is meant to be fun, but the guidelines below may help if you are not sure where to start.&lt;/p&gt;
&lt;p&gt;A good approach is to choose a self-referential pattern as your target output.
For inspiration, see this &lt;a href=&#34;https://en.wikipedia.org/wiki/List_of_fractals_by_Hausdorff_dimension&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Wikipedia list of fractals&lt;/a&gt;.
Some patterns are harder to generate than others, and some require trigonometry.&lt;/p&gt;
&lt;p&gt;Design your drawing before you code it. Sketch your idea on paper and plan your approach.
As usual, comment your code as you go.&lt;/p&gt;
&lt;h4 id=&#34;requirements-1&#34;&gt;Requirements&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;Art.java&lt;/code&gt; must take one integer command-line argument &lt;code&gt;n&lt;/code&gt; that controls the recursion depth.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Your drawing must stay within the drawing window for all &lt;code&gt;n&lt;/code&gt; between 1 and 6 (inclusive).
The autograder will not test values of &lt;code&gt;n&lt;/code&gt; outside this range.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You may not change the canvas size. You may change the scale.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Do not play sound.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Your drawing may be a geometric pattern, a randomized construction,
or anything else that takes advantage of recursion.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: You may use the &lt;code&gt;Transform2D&lt;/code&gt; library from precept.
You may also define additional transforms in &lt;code&gt;Art.java&lt;/code&gt;
(e.g., shear, reflection across the $x$- or $y$-axis,
or rotation about an arbitrary point).
You may copy &lt;code&gt;Transform2D.java&lt;/code&gt; into your local project for reference, but do not submit it.
We will use the Ed Lessons implementation when grading.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Organize your program into at least &lt;em&gt;three&lt;/em&gt; functions, including &lt;code&gt;main()&lt;/code&gt;.
All functions except &lt;code&gt;main()&lt;/code&gt; must be &lt;code&gt;private&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Your artwork must genuinely rely on recursion and must be substantially different from
the in-class examples (&lt;code&gt;HTree&lt;/code&gt;, &lt;code&gt;Sierpinski&lt;/code&gt;, &lt;code&gt;NestedCircles&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To earn full credit, do &lt;strong&gt;at least two&lt;/strong&gt; of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use mutually recursive methods.&lt;/li&gt;
&lt;li&gt;Use multiple recursive methods.&lt;/li&gt;
&lt;li&gt;Use recursion that does not always recurse from level &lt;code&gt;n&lt;/code&gt; to level &lt;code&gt;n-1&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Draw between recursive calls, not only before or after all recursive calls.&lt;/li&gt;
&lt;li&gt;Use the recursion level for a secondary purpose (e.g., to control the color).&lt;/li&gt;
&lt;li&gt;Call one or more &lt;code&gt;Transform2D&lt;/code&gt; methods (or implement additional transforms)&lt;/li&gt;
&lt;li&gt;Use different &lt;code&gt;StdDraw&lt;/code&gt; primitives than the examples (e.g., ellipses, arcs, or text).&lt;/li&gt;
&lt;li&gt;Use a non-constant number of recursive calls per level (e.g., conditional recursion).&lt;/li&gt;
&lt;li&gt;Use additional parameters that affect the recursion or drawing, such as an angle, aspect ratio, color/opacity, branching factor, or a random seed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You may use GIF, JPG, or PNG files in your artwork. If you do, submit them with your other files. In
&lt;code&gt;readme.txt&lt;/code&gt;, clearly indicate which parts of the design are yours and which parts come from the image files.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What will cause me to lose points on the artistic part?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;See the rubric in the bulleted list above. In particular, you may lose points for either of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Recursion is not essential.&lt;/strong&gt; You will lose points if the same artwork can be created
just as easily without recursion (for example, with a simple loop).
As a rule of thumb, if your recursive call tree is essentially
straight line (one recursive call per level), it is probably too simple.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Too similar to in-class examples.&lt;/strong&gt; Even if the picture looks different,
you will lose points if the code and recursion structure are essentially the
same as &lt;code&gt;HTree&lt;/code&gt;, &lt;code&gt;Sierpinski&lt;/code&gt;, or &lt;code&gt;NestedCircles&lt;/code&gt;.
For example, the &lt;a href=&#34;https://en.wikipedia.org/wiki/File:Quadriccross.gif&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Quadricross&lt;/a&gt; looks different,
but the code to generate it is very similar to &lt;code&gt;HTree&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h4 id=&#34;student-art&#34;&gt;Student Art&lt;/h4&gt;
&lt;p&gt;Here is an animation we produced  using student art: &lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
      &lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/G-Oktrfe9-E?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
    &lt;/div&gt;
&lt;/p&gt;
&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Recursion&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;DelannoyBrute.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;DelannoyMemo.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Sierpinski.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Art.java&lt;/code&gt; (and optional image files)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: We may anonymously publish your art. If you object, please indicate so in your
&lt;code&gt;readme.txt&lt;/code&gt; when asked. We also reserve the right to pull any art, at any time, for whatever
reason; by submitting your assignment, you implicitly agree with this policy.&lt;/p&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;File&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;DelannoyBrute.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;6&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;DelannoyMemo.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;6&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Sierpinski.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;16&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Art.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;6&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;6&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;!--
### **Enrichment**

**Fractals in the wild.** Here&#39;s a Sierpinski triangle in [polymer clay](https://www.evilmadscientist.com/article.php/fimofractals), a [Sierpinski carpet cookie](https://www.evilmadscientist.com/article.php/fractalcookies), a [fractal pizza](https://slice.seriouseats.com/archives/2010/09/john-riepenhoffs-recursive-pizza.html), and a [Sierpinski hamantaschen](https://seattlelocalfood.com/2011/03/20/sierpinski-hamantaschen-sierpinskitaschen/).

**Fractal dimension (optional diversion).** In grade school, you learn that the dimension of a line segment is 1, the dimension of a square is 2, and the dimension of a cube is 3. But you probably didn&#39;t learn what is really meant by the term *dimension*. How can we express what it means mathematically or computationally? Formally, we can define the *Hausdorff dimension* or *similarity dimension* of a self-similar figure by partitioning the figure into a number of self-similar pieces of smaller size. We define the dimension to be the $\log$ (# self similar pieces) / $\log$ (scaling factor in each spatial direction). For example, we can decompose the unit square into four smaller squares, each of side length 1/2; or we can decompose it into 25 squares, each of side length 1/5. Here, the number of self-similar pieces is 4 (or 25) and the scaling factor is 2 (or 5). Thus, the dimension of a square is 2, since $\log (4) / \log(2) = \log (25) / \log (5) = 2$. Furthermore, we can decompose the unit cube into 8 cubes, each of side length 1/2; or we can decompose it into 125 cubes, each of side length 1/5. Therefore, the dimension of a cube is $\log(8) / \log (2) = \log(125) / \log(5) = 3$.

We can also apply this definition directly to the (set of white points in) Sierpinski triangle. We can decompose the unit Sierpinski triangle into three Sierpinski triangles, each of side length 1/2. Thus, the dimension of a Sierpinski triangle is $\log (3) / \log (2) ≈ 1.58$. Its dimension is fractional—more than a line segment, but less than a square! With Euclidean geometry, the dimension is always an integer; with fractal geometry, it can be something in between. Fractals are similar to many physical objects; for example, the coastline of Britain resembles a fractal; its fractal dimension has been measured to be approximately 1.25.
--&gt;
</description>
    </item>
    
    <item>
      <title>5. Object Oriented Programming</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/oop/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/oop/</guid>
      <description>&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/oop.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/OOP&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this assignment, you will write programs that use and create data types.
You will use &lt;code&gt;Picture&lt;/code&gt; and &lt;code&gt;Color&lt;/code&gt; to process images and &lt;code&gt;In&lt;/code&gt; to read input from files.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Read Sections 3.1 and 3.2 of the textbook and review the corresponding lectures and precepts.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/oop.zip&#34;&gt;oop.zip&lt;/a&gt;
, then open the &lt;code&gt;oop&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Consult the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#Picture&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Picture&lt;/a&gt;,
&lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#Color&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Color&lt;/a&gt;,
and &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#In&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;In&lt;/a&gt; APIs as needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;partnering&#34;&gt;&lt;strong&gt;Partnering&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;This is a partner assignment.
Partnering is optional, but we strongly recommend doing at least one partnered assignment.
Pair programming improves how you communicate about code and is often faster, less
error-prone, and less frustrating than working alone.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;See Ed for instructions on finding a partner and creating a &lt;em&gt;TigerFile&lt;/em&gt; group.&lt;/li&gt;
&lt;li&gt;Follow these &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/syllabus/#partners&#34;&gt;partnering rules&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;rectangular-tile-of-an-image&#34;&gt;&lt;strong&gt;Rectangular Tile of an Image&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;A &lt;em&gt;rectangular tile&lt;/em&gt; repeats an image in a grid with a specified number of columns and rows.
For example, consider the following image:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/heart.png&#34; width=&#34;63&#34; alt=&#34;1-by-1 heart&#34;&gt;
&lt;p&gt;Here is a 6-by-3 rectangular tile:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/heart6x3.png&#34; width=&#34;378&#34; alt=&#34;6-by-3 heart&#34;&gt;
&lt;p&gt;Write a program &lt;code&gt;Tile.java&lt;/code&gt; that takes three command-line arguments
(the image filename, the number of columns, and the number of rows)
and displays the corresponding rectangular tile.&lt;/p&gt;
&lt;p&gt;Organize your program according to the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Tile&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a cols-by-rows tiling of the given image.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Picture&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;tile&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Picture&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;picture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;cols&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rows&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Takes three command-line arguments (the image filename, the number&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// of columns, and the number of rows), and displays a rectangular&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// tiling of the image with the given number of columns and rows.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here are some sample executions:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Tile heart.png 1 1&lt;/span&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/heart.png&#34; width=&#34;63&#34; alt=&#34;1-by-1 heart&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Tile heart.png 6 3&lt;/span&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/heart6x3.png&#34; width=&#34;378&#34; alt=&#34;6-by-3 heart&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Tile princeton.png 1 1&lt;/span&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/princeton.png&#34; width=&#34;100&#34; alt=&#34;1-by-1 Princeton&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Tile princeton.png 5 2&lt;/span&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/princeton5x2.png&#34; width=&#34;500&#34; alt=&#34;5-by-2 Princeton&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Tile bricks.png 1 1&lt;/span&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/bricks.png&#34; width=&#34;90&#34; alt=&#34;1-by-1 bricks&#34;&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Tile bricks.png 9 4&lt;/span&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/bricks9x4.png&#34; width=&#34;810&#34; alt=&#34;9-by-4 bricks&#34;&gt;
&lt;/pre&gt;

&lt;h3 id=&#34;tracker&#34;&gt;&lt;strong&gt;Tracker&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;In this part, you will create a data type for a &lt;em&gt;tracking device&lt;/em&gt;,
such as an &lt;a href=&#34;https://www.apple.com/airtag/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;AirTag&lt;/a&gt; or &lt;a href=&#34;https://www.tile.com/products/tile-pro&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Tile Pro&lt;/a&gt;.
Each tracking device has a name and a location.
A device may also be in &lt;em&gt;lost mode&lt;/em&gt;, which conserves power and limits access to personal information.&lt;/p&gt;
&lt;p&gt;Implement &lt;code&gt;Tracker.java&lt;/code&gt; as specified by the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Tracker&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates a tracker with the given name and initial location.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Lost mode is initially disabled.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;Tracker&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;initialLatitude&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;initialLongitude&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Is this tracker in lost mode?&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;boolean&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;isInLostMode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Enables lost mode on this tracker.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;enableLostMode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Disables lost mode on this tracker.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;disableLostMode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Moves this tracker to the given location.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;move&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;newLatitude&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;newLongitude&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the great-circle distance between the two trackers.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;distanceTo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Tracker&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;other&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a string representation of this tracker.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;toString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Unit tests the Tracker data type.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here is some more information about the required behavior:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test client.&lt;/strong&gt; The &lt;code&gt;main()&lt;/code&gt; method must call every public instance method.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;String representation.&lt;/strong&gt; Return a string consisting of the tracker name and its current location
(latitude, longitude) in the following format:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;quot;backpack (40.34386, -74.6593)&amp;quot;&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Corner cases.&lt;/strong&gt; You may assume that all arguments are meaningful values (e.g., not &lt;code&gt;null&lt;/code&gt;, &lt;code&gt;NaN&lt;/code&gt;,
&lt;code&gt;Double.POSITIVE_INFINITY&lt;/code&gt;, or &lt;code&gt;Double.NEGATIVE_INFINITY&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Locations.&lt;/strong&gt; Locations are specified using latitude and longitude in degrees.
For example, Nassau Hall is located at $40.34386^\circ$ latitude and $-74.6593^\circ$ longitude.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Distance.&lt;/strong&gt;
Let $(x_1, y_1)$ and $(x_2, y_2)$ be the latitude and longitude of two points on the
surface of a sphere of radius $r$. The &lt;em&gt;great-circle distance&lt;/em&gt; between them is the length of the
shortest path along the surface.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/great-circle.png&#34; width=&#34;200&#34; alt=&#34;great-circle distance between two points&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://en.wikipedia.org/wiki/Haversine_formula&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Haversine formula&lt;/a&gt; gives the great-circle distance:&lt;/p&gt;
&lt;p&gt;$$
distance \; = \; 2r \arcsin \left ( \sqrt{ \sin^2 \left ( \frac{x_2 - x_1}{2} \right ) + \cos x_1 \cos x_2  \sin^2 \left ( \frac{y_2 - y_1}{2} \right ) } \right )
$$&lt;/p&gt;
&lt;p&gt;Use the mean Earth radius $r = \text{6,371.0}$ kilometers, which gives a good approximation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;The arguments are given in degrees but Java&amp;rsquo;s trig functions use radians. What can I do?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use code like &lt;code&gt;radians = Math.toRadians(degrees)&lt;/code&gt; to convert from degrees to radians.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Which &lt;code&gt;Math&lt;/code&gt; library functions should I use?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use whichever functions from Java&amp;rsquo;s &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#In&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Math library&lt;/a&gt;
that you need.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I&amp;rsquo;m getting the wrong result. How can I check my formula?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Create a small example that you can work out by hand. Then verify that each intermediate term matches.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/great-circle-trace.png&#34; width=&#34;550&#34; alt=&#34;great circle trace&#34;&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I use a different formula to compute the great-circle distance?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. Use the formula provided.
Different formulas can produce slightly different results due to floating-point rounding,
especially for nearly antipodal points.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;musical-notes&#34;&gt;&lt;strong&gt;Musical Notes&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Musical notes are the building blocks of music.
In this assignment, each note is specified by its &lt;a href=&#34;https://en.wikipedia.org/wiki/MIDI&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;MIDI&lt;/a&gt;
number and an instrument.&lt;/p&gt;
&lt;p&gt;Implement &lt;code&gt;Note.java&lt;/code&gt; as specified by the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Note&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates a note with the given MIDI number and instrument name.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;Note&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;midiNumber&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;instrumentName&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns this note&amp;#39;s MIDI number.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;midi&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns this note&amp;#39;s frequency.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;frequency&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Plays this note to standard audio using the associated WAV file.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;play&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns this note&amp;#39;s name (e.g., C or A#).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns this note&amp;#39;s octave.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;octave&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a new Note transposed by delta semitones.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Note&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;transpose&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;delta&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a string representation of this note.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;toString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Unit tests the Note data type.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here is additional information about the required behavior:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Corner cases.&lt;/strong&gt; You may assume that all  arguments are meaningful values
(e.g., MIDI numbers are between 0 and 127).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Note names and octaves.&lt;/strong&gt;
Musicians often use &lt;a href=&#34;https://en.wikipedia.org/wiki/Scientific_pitch_notation&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;scientific pitch notation&lt;/a&gt;,
such as A4 for concert A (MIDI number 69) and C4 for middle C (MIDI number 60).
Scientific pitch notation consists of a note name (C, C#, D, D#, E, F, F#, G, G#, A, A#, or B)
followed by an octave number.
Each octave contains 12 notes.
The following (partial) table shows the mapping between the two notations:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;md-table md-table-clean&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;MIDI&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;pitch&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;MIDI&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;pitch&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;MIDI&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;pitch&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;MIDI&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;pitch&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;48&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;C3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;60&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;C4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;72&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;C5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;84&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;C6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;49&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;C#3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;61&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;C#4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;73&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;C#5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;85&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;C#6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;50&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;D3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;62&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;D4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;74&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;D5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;86&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;D6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;51&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;D#3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;63&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;D#4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;75&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;D#5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;87&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;D#6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;52&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;E3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;64&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;E4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;76&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;E5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;88&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;E6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&amp;hellip;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;53&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;F3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;65&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;F4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;77&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;F5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;89&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;F6&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&amp;hellip;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;54&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;F#3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;66&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;F#4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;78&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;F#5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;90&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;F#6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;55&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;G3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;67&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;G4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;79&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;G5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;91&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;G6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;56&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;G#3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;68&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;G#4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;80&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;G#5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;92&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;G#6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;57&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;A3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;69&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;A4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;81&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;A5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;93&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;A6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;58&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;A#3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;70&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;A#4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;82&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;A#5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;94&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;A#6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;59&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;B3&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;71&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;B4&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;83&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;B5&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;95&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;B6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;For the sake of brevity, we use only sharp accidentals (such as A#) for the note names, and not the equivalent flat accidentals such as (B♭).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;String representation.&lt;/strong&gt;
Return a string consisting of the MIDI number, the note name, the octave,
and the instrument in the following format: &lt;code&gt;&amp;quot;69 A4 (piano)&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Play.&lt;/strong&gt; Play the WAV file whose filename is the instrument name followed by the MIDI number,
with extension &lt;code&gt;.wav&lt;/code&gt;. For example, for instrument &lt;code&gt;piano&lt;/code&gt; and MIDI number &lt;code&gt;69&lt;/code&gt;, call
&lt;code&gt;StdAudio.play(&amp;quot;piano/piano69.wav&amp;quot;)&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Frequency.&lt;/strong&gt; The frequency $f$ corresponding to MIDI number $m$ is&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;$$
f \; = \; 440 \; \times \; 2^{\, (m - 69) \, / \, 12}
$$&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Transpose.&lt;/strong&gt; Transposing a note with MIDI number $m$ by $\Delta$ semitones
yields a note with MIDI number $m + \Delta$.
This method must return a new &lt;code&gt;Note&lt;/code&gt; object; it must not modify the invoking &lt;code&gt;Note&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test client.&lt;/strong&gt; The &lt;code&gt;main()&lt;/code&gt; method must call every public method.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How can I define constants that are global to a class?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Recall from the &lt;em&gt;Creating Data Types&lt;/em&gt; lecture that you can declare a constant using the &lt;code&gt;private static final&lt;/code&gt; modifiers. For example: &lt;code&gt;private static final int MINUTES_PER_HOUR = 60;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Which &lt;code&gt;Math&lt;/code&gt; library functions should I use?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use whichever functions from Java’s &lt;code&gt;Math&lt;/code&gt; library that you need. The function ``Math.pow()` is particularly useful for computing frequency.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;MIDI values go from 0 to 127, however the table provided only shows the relationship between MIDI and octaves from 36 to 95. Should we only focus on those MIDI values? Or are we expected to generalize the relationship for the other values as well?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;You need to generalize.  See the &lt;em&gt;Table of note frequencies&lt;/em&gt; in &lt;a href=&#34;https://en.wikipedia.org/wiki/Scientific_pitch_notation&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Scientific pitch notation&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;There are only instrument audio files for MIDI numbers 12 through 116. Are our programs purposefully not intended to play MIDI numbers 0 through 11 and 117 through 127?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;While MIDI is defined for values 0 to 127, most instruments do not support that full range. For example, a typical piano has only 88 keys, not 128. You need not worry about that. The autograder won&amp;rsquo;t call play() on a MIDI note for which there is no accompanying WAV file.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Do I need conditionals to determine a note name or octave?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;You can implement &lt;code&gt;name()&lt;/code&gt; and &lt;code&gt;octave()&lt;/code&gt; without any &lt;code&gt;if&lt;/code&gt; statements. If you a have large multiway &lt;code&gt;if&lt;/code&gt; statement ladder, you are probably not finding the most elegant way to implement these methods. Consider using integer division/remainder and an array.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;play-these-notes&#34;&gt;Play These Notes&lt;/h3&gt;
&lt;p&gt;Your final task is to write a client program &lt;code&gt;PlayTheseNotes.java&lt;/code&gt; that reads a sequence of notes from a
file, transposes them by a given $\Delta$, plays them on standard audio, and prints the transposed notes to
standard output.&lt;/p&gt;
&lt;p&gt;The program takes three command-line arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the  name of the input file&lt;/li&gt;
&lt;li&gt;the instrument name: &lt;code&gt;piano&lt;/code&gt;, &lt;code&gt;guitar&lt;/code&gt;, &lt;code&gt;clarinet&lt;/code&gt;, or &lt;code&gt;mbira&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the transposed amount  $\Delta$ (in semitones)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Organize your client according to the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;PlayTheseNotes&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Reads a sequence of notes from filename and returns them &lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// as an array, using the given instrument.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Note&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;read&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;filename&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;instrument&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Takes three command-line arguments (a filename, an instrument name,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// and a transposition amount delta), reads the notes; transposes them;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// plays them on standard audio; and prints the transposed notes.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here are some details about the API:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Approach.&lt;/strong&gt;
In &lt;code&gt;main()&lt;/code&gt;, first call &lt;code&gt;read()&lt;/code&gt; to obtain an array of &lt;code&gt;Note&lt;/code&gt; objects for the specified instrument.
Then, in order, transpose each note by $\Delta$, play it, and print it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Input file format.&lt;/strong&gt; A notes file consists of a sequence of lines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The first line contains the number of notes.&lt;/li&gt;
&lt;li&gt;Each remaining line contains a MIDI number followed by a floating-point duration (in seconds),
separated by whitespace.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/oop/images/inputfile.png&#34; width=&#34;250&#34; alt=&#34;input file format&#34;&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Input files.&lt;/strong&gt; We provide several files containing simple songs in this format.
You may also create and submit your own song in a file named &lt;code&gt;music.txt&lt;/code&gt;.
It may be original or by another artist; include credits at the end of the file.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reading from a file.&lt;/strong&gt;
Use &lt;code&gt;In&lt;/code&gt; in to read data from a file.
The &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#In&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;In&lt;/code&gt;&lt;/a&gt; data type (Section 3.1)
is an object-oriented version of
&lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#StdIn&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;StdIn&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Duration.&lt;/strong&gt; Duration is typically used to represent note lengths
(eighth notes, quarter notes, half notes, and whole notes).
In this assignment, we provide only quarter notes.
You must read the duration, but you will not use it when creating or playing notes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Output.&lt;/strong&gt; Print the transposed pitch (note name and octave) for each note as it plays.
Print all pitches on one line, separated by single spaces, and end the line with a newline.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are some sample executions:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs PlayTheseNotes C4-major-scale.txt piano 0&lt;/span&gt;
C4 D4 E4 F4 G4 A4 B4 C5

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs PlayTheseNotes C4-major-scale.txt guitar 0&lt;/span&gt;
C4 D4 E4 F4 G4 A4 B4 C5

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/oop&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs PlayTheseNotes C4-major-scale.txt piano 8&lt;/span&gt;
G#4 A#4 C5 C#5 D#5 F5 G5 G#5 
&lt;/pre&gt;

&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/OOP&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Tile.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Tracker.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Note.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PlayTheseNotes.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;music.txt&lt;/code&gt; (if you created your own composition)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;File&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;Tile.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Tracker.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Note.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;PlayTheseNotes.java&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;6&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;This assignment was developed by &lt;a href=&#34;http://www.cs.princeton.edu/~wayne&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Kevin Wayne&lt;/a&gt;.
Copyright © 2024–2026.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>6. Guitar Hero</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/guitar/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/guitar/</guid>
      <description>&lt;!--&lt;p style=&#34;color:red;&#34;&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt;  This assignment has not been officially released yet and is subject to change!&lt;/p&gt;

--&gt;
&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/guitar.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Guitar&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this assignment, you will simulate plucking a guitar string with the Karplus–Strong algorithm,
turning your computer into a musical instrument.
You will implement a ring buffer to support efficient simulation.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Read Section 3.3 of the textbook.&lt;/li&gt;
&lt;li&gt;Review the &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/syllabus/#partners&#34;&gt;partnering rules&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/guitar.zip&#34;&gt;guitar.zip&lt;/a&gt;
, then open the &lt;code&gt;guitar&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;background-and-approach&#34;&gt;&lt;strong&gt;Background and Approach&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;We model a vibrating guitar string as a discrete sequence of audio samples in a fixed-size buffer.
The Karplus–Strong algorithm generates a plucked-string sound by repeatedly updating this buffer and playing the
resulting samples as audio.&lt;/p&gt;
&lt;p&gt;When a guitar string is plucked, it vibrates and produces sound.
The string length determines its fundamental frequency $f$.
We represent the string&amp;rsquo;s &lt;em&gt;displacement&lt;/em&gt; using $n$ real-valued samples, where&lt;/p&gt;
&lt;p&gt;\[
n = \left\lceil \frac{44100}{f} \right\rceil .
\]&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Plucking the string.&lt;/em&gt;
To simulate the initial excitation, fill the $n$ samples with &lt;em&gt;white noise&lt;/em&gt;:
set each displacement to a random real number between $-0.5$ and $0.5$.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/images/white-noise.png&#34; width=&#34;500&#34; alt=&#34;white noise&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Simulating vibration (Karplus–String).&lt;/em&gt;
Maintain a &lt;strong&gt;ring buffer&lt;/strong&gt; of the $n$ samples.
Repeatedly remove the first sample and append a new sample equal to the average of the removed
sample and the new first sample, multiplied by an &lt;em&gt;energy-decay factor&lt;/em&gt; (0.996). For example:&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/images/k-p-average.png&#34; width=&#34;500&#34; alt=&#34;Karplus–Strong averaging noise&#34;&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Why does it work?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;The Karplus–Strong algorithm works because of two features: &lt;em&gt;feedback&lt;/em&gt; (via a ring buffer) and &lt;em&gt;averaging&lt;/em&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Feedback (ring buffer).&lt;/em&gt;
The ring buffer models a wave traveling back and forth along a string fixed at both ends.
Its length sets the fundamental frequency, and the feedback reinforces that frequency and its harmonics.
The energy-decay factor (0.996) models gradual energy loss.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Averaging.&lt;/em&gt; Each update averages adjacent samples, which acts as a gentle low-pass filter.
Over time, this attenuates higher frequencies faster than lower ones,
producing a realistic “plucked string” timbre.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;From a mathematical-physics viewpoint, Karplus–Strong can be seen as a crude numerical
approximation to the 1D wave equation.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Why is the Karplus–Strong algorithm historically important?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It played a seminal role in the emergence of physically modeled sound synthesis, where a physical description of a musical instrument is used to synthesize sound electronically.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;ring-buffer&#34;&gt;Ring Buffer&lt;/h3&gt;
&lt;p&gt;Your first task is to implement a data type that models a ring buffer.
Write a class &lt;code&gt;RingBuffer&lt;/code&gt; that implements the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;RingBuffer&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates an empty ring buffer with the given capacity.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;RingBuffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;capacity&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the capacity of this ring buffer.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;capacity&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the number of items currently in this ring buffer.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;size&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Is this ring buffer empty (size equals zero)?&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;boolean&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;isEmpty&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Is this ring buffer full (size equals capacity)?&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;boolean&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;isFull&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Adds x to the end of this ring buffer.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;enqueue&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Removes and returns the item at the front of this ring buffer.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;dequeue&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns (but does not remove) the item at the front of this ring buffer.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;peek&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Tests this class by directly calling all instance methods.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;implementation-strategy&#34;&gt;Implementation strategy&lt;/h4&gt;
&lt;p&gt;Since the ring buffer has a fixed maximum capacity, you can implement it with a &lt;code&gt;double[]&lt;/code&gt; array of that length.
For efficiency, use &lt;strong&gt;cyclic wrap-around&lt;/strong&gt; and maintain the following integer instance variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;first&lt;/code&gt;: the index of the least recently inserted item (the front of the buffer)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;last&lt;/code&gt;: the index one past the most recently inserted item (the end of the buffer)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;size&lt;/code&gt;: the current number of items in the buffer&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, here a ring buffer of size 4 with capacity 10:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/images/ring-buffer.png&#34; width=&#34;450&#34; alt=&#34;a ring buffer of size 4 and capacity 10&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Insert.&lt;/em&gt; Store the new item at index &lt;code&gt;last&lt;/code&gt;, then increment &lt;code&gt;last&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Remove.&lt;/em&gt; Take the item at index &lt;code&gt;first&lt;/code&gt;, then increment &lt;code&gt;first&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Cyclic wrap-around.&lt;/em&gt;  If &lt;code&gt;first&lt;/code&gt; or &lt;code&gt;last&lt;/code&gt; reaches &lt;code&gt;capacity&lt;/code&gt;, wrap it to 0.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;requirements&#34;&gt;Requirements&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Performance.&lt;/em&gt; The constructor must run in time proportional to the capacity.
Every other method must run in constant time.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Data structure.&lt;/em&gt;  You must use an array as the underlying data structure.
You may not use &lt;code&gt;ArrayList&lt;/code&gt;, &lt;code&gt;LinkedList&lt;/code&gt;, or &lt;code&gt;Queue&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Corner cases.&lt;/em&gt; &lt;code&gt;RingBuffer&lt;/code&gt; must throw an &lt;code&gt;IllegalStateException&lt;/code&gt; (with a custom message)
if the client calls&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dequeue()&lt;/code&gt; when the ring buffer is &lt;em&gt;empty&lt;/em&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;peek()&lt;/code&gt; when the ring buffer is &lt;em&gt;empty&lt;/em&gt;, or&lt;/li&gt;
&lt;li&gt;&lt;code&gt;enqueue()&lt;/code&gt; when the ring buffer is &lt;em&gt;full&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;API.&lt;/em&gt; You must not add &lt;code&gt;public&lt;/code&gt; methods.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details&gt;
  &lt;summary&gt;&lt;em&gt;Click here for possible progress steps.&lt;/em&gt;&lt;/summary&gt;
  &lt;h4 id=&#34;implementing-ringbufferjava&#34;&gt;Implementing &lt;code&gt;RingBuffer.java&lt;/code&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Implement &lt;code&gt;RingBuffer&lt;/code&gt; in an incremental and iterative manner.  Edit your initial &lt;code&gt;RingBuffer.java&lt;/code&gt; so that it can compile (recall the &lt;code&gt;Data.java&lt;/code&gt; exercise from precept).  Then, implement &lt;em&gt;one constructor/method at a time&lt;/em&gt;, together with at least one &lt;em&gt;corresponding test&lt;/em&gt; in &lt;code&gt;main()&lt;/code&gt;.  We provide &lt;em&gt;some&lt;/em&gt; test cases below.  You should also include your own test cases in &lt;code&gt;main()&lt;/code&gt;, such as the ones from the precept worksheet.&lt;/li&gt;
&lt;li&gt;Define the instance variables you will need to represent a &lt;code&gt;RingBuffer&lt;/code&gt;. Hint: review the worksheet from precept.&lt;/li&gt;
&lt;li&gt;Implement the constructor for &lt;code&gt;RingBuffer&lt;/code&gt;. You will need to allocate and initialize an array of &lt;code&gt;doubles&lt;/code&gt; using the &lt;code&gt;new&lt;/code&gt; operator. Observe that you have to do this in the constructor (and not when you declare the instance variables) because you do not know the length of the array until the constructor is called.&lt;/li&gt;
&lt;li&gt;Test the constructor in &lt;code&gt;main()&lt;/code&gt;.  You can run this test by trying various &lt;code&gt;RingBuffer&lt;/code&gt; sizes specified on the command line.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test for the constructor, based on command-line argument&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Integer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;parseInt&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// get the size of n from the command-line&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #0 - create a RingBuffer object with %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;RingBuffer&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;RingBuffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;5&#34;&gt;
&lt;li&gt;Implement &lt;code&gt;capacity()&lt;/code&gt; and then test it:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test for capacity()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #1 - check capacity - should be %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Capacity is %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;capacity&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;6&#34;&gt;
&lt;li&gt;Implement &lt;code&gt;size()&lt;/code&gt; and then test it:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test for size()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #2 - check size - should be %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Size is %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;size&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;7&#34;&gt;
&lt;li&gt;Implement &lt;code&gt;isFull()&lt;/code&gt; and &lt;code&gt;enqueue()&lt;/code&gt; and then test them:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test for isFull() and enqueue()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #3 - perform %d enqueues: 1.0, 2.0, ...\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** isFull() should be false- is %b\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;isFull&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// enqueue n values:  1.0, 2.0, ...&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;       &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;enqueue&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;       &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #3.%d - check size after %d enqueues- should be %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                        &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;       &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Size is %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;size&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** isFull() should be true- is %b\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;isFull&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;8&#34;&gt;
&lt;li&gt;Implement &lt;code&gt;isEmpty() and &lt;/code&gt;peek()` and then test them:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test for isEmpty() and peek()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #4 - check peek value == %.1f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** isEmpty() should be false- is %b\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;isEmpty&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;val1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;peek&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Value is %.1f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;val1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;9&#34;&gt;
&lt;li&gt;Implement &lt;code&gt;dequeue()&lt;/code&gt; and then test it:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test for dequeue()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;val2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;dequeue&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #5 - dequeue a value, then check value == %.1f and &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                      &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;size == %d after a dequeue\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Value is %.1f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;val2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Size is %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;size&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;dequeue&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// dequeue everything left&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** remove %d items and isEmpty() should be true- is %b\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                      &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;isEmpty&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Is the size of a RingBuffer equal to its capacity?&lt;/strong&gt;&lt;/em&gt; The size is the number of elements currently in it; the &lt;code&gt;capacity&lt;/code&gt; is its maximum possible size.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Is the size of a RingBuffer equal to the number of its non-zero elements?&lt;/strong&gt;&lt;/em&gt;  No. Some of the elements in the RingBuffer can be zero.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;How do I throw a &lt;code&gt;IllegalStateException&lt;/code&gt; with a custom message?&lt;/strong&gt;&lt;/em&gt;  Read the &lt;em&gt;Exceptions&lt;/em&gt; paragraph on pages 465–466 of the textbook. Also, see the precept exercises for examples.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;I get an &lt;code&gt;ArrayIndexOutOfBoundsException&lt;/code&gt; or &lt;code&gt;NullPointerException&lt;/code&gt;. What could cause this?&lt;/strong&gt;&lt;/em&gt; Does your constructor correctly initialize all of the instance variables? Did you allocate memory for your array? Did you inadvertently re-declare an instance variable in a method or constructor, thereby shadowing the instance variable with the same name?&lt;/p&gt;

&lt;/details&gt;

&lt;h3 id=&#34;guitar-string&#34;&gt;&lt;strong&gt;Guitar String&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Create a data type to model a vibrating guitar string.
Write a class &lt;code&gt;GuitarString&lt;/code&gt; that implements the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates a guitar string of the given frequency, using a sampling&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// rate of 44,100. Initializes the ring buffer with ceil(44100 / frequency)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// samples, all set to 0.0.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;frequency&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates a guitar string whose initial ring buffer values&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// are given by init[].&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;init&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the number of samples in the ring buffer.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the current sample (the value at the front of the ring buffer)..&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Plucks this guitar string by replacing the ring buffer contents&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// with white noise (random values between -0.5 and +0.5).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;pluck&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Advances the Karplus-Strong simulation one time step.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;tic&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Tests this class by directly calling both constructors&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// and all instance methods.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;requirements-1&#34;&gt;Requirements&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Data structure.&lt;/em&gt; Implement &lt;code&gt;GuitarString&lt;/code&gt; using the &lt;code&gt;RingBuffer&lt;/code&gt; data type.
Do not use &lt;code&gt;Stack&lt;/code&gt;, &lt;code&gt;Queue&lt;/code&gt;, &lt;code&gt;ArrayList&lt;/code&gt;, or other data types to represent a guitar string.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Karplus–Strong update.&lt;/em&gt; The &lt;code&gt;tic()&lt;/code&gt; method method removes the sample at the front of the ring buffer,
then adds to the end of the ring buffer the average of the removed sample and the new first sample,
multiplied by the energy-decay factor (0.996).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;API:&lt;/em&gt; you must not add &lt;code&gt;public&lt;/code&gt; methods to the API.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details&gt;
  &lt;summary&gt;&lt;em&gt;Click here to show possible progress steps.&lt;/em&gt;&lt;/summary&gt;
  &lt;h4 id=&#34;implementing-guitarstringjava&#34;&gt;Implementing &lt;code&gt;GuitarString.java&lt;/code&gt;&lt;/h4&gt;
&lt;ol start=&#34;0&#34;&gt;
&lt;li&gt;Again, employ an &lt;em&gt;incremental/iterative implementation/testing/debugging&lt;/em&gt; approach.  Edit your initial &lt;code&gt;GuitarString.java&lt;/code&gt; so that it can compile (recall the &lt;code&gt;Data.java&lt;/code&gt; exercise from precept).  Then, implement &lt;em&gt;one constructor/method at a time&lt;/em&gt;, together with at least one &lt;em&gt;corresponding test&lt;/em&gt; in &lt;code&gt;main()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Implement and test the &lt;code&gt;GuitarString(double frequency)&lt;/code&gt; constructor, which creates a &lt;code&gt;RingBuffer&lt;/code&gt; of the desired capacity &lt;code&gt;n&lt;/code&gt; (the sampling rate 44,100 divided by the frequency, rounded up to the nearest integer), and initializes it to represent a guitar string at rest by enqueueing &lt;code&gt;n&lt;/code&gt; zeros. (Use &lt;a href=&#34;https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html#ceil%28double%29&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;Math.ceil&lt;/code&gt;&lt;/a&gt; and cast the result to an integer.)&lt;/li&gt;
&lt;li&gt;Implement the &lt;code&gt;length()&lt;/code&gt; method, which returns the number of samples in the ring buffer.&lt;/li&gt;
&lt;li&gt;Implement the &lt;code&gt;sample()&lt;/code&gt; method, which returns the value of the item at the front of the ring buffer. Use &lt;code&gt;peek()&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;How can I test the &lt;code&gt;GuitarString(double frequency)&lt;/code&gt; constructor and these methods?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;main()&lt;/code&gt;, instantiate a few different &lt;code&gt;GuitarString&lt;/code&gt; objects using the &lt;code&gt;GuitarString(double frequency)&lt;/code&gt; constructor.&lt;/li&gt;
&lt;li&gt;Invoke &lt;code&gt;length()&lt;/code&gt; on each &lt;code&gt;GuitarString&lt;/code&gt; object. Is the value returned by &lt;code&gt;length()&lt;/code&gt; what you expect?&lt;/li&gt;
&lt;li&gt;Invoke &lt;code&gt;sample()&lt;/code&gt; on each &lt;code&gt;GuitarString&lt;/code&gt; object. Is the value returned by &lt;code&gt;sample()&lt;/code&gt; what you expect?&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;4&#34;&gt;
&lt;li&gt;Implement and test the &lt;code&gt;GuitarString(double[])&lt;/code&gt; constructor, which creates a &lt;code&gt;RingBuffer&lt;/code&gt; of capacity equal to the length &lt;code&gt;n&lt;/code&gt; of the array, and initializes the contents of the ring buffer to the corresponding values in the array. In this assignment, this constructor&amp;rsquo;s primary purpose is to facilitate testing and debugging.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;How can I test the  &lt;code&gt;GuitarString(double[])&lt;/code&gt; constructor and these methods?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Instantiate a few different &lt;code&gt;GuitarString&lt;/code&gt; objects using the &lt;code&gt;GuitarString(double frequency)&lt;/code&gt; constructor.&lt;/li&gt;
&lt;li&gt;Invoke &lt;code&gt;length()&lt;/code&gt; on each &lt;code&gt;GuitarString&lt;/code&gt; object. Is the value returned by &lt;code&gt;length()&lt;/code&gt; what you expect?&lt;/li&gt;
&lt;li&gt;Invoke &lt;code&gt;sample()&lt;/code&gt; on each &lt;code&gt;GuitarString&lt;/code&gt; object. Is the value returned by &lt;code&gt;sample()&lt;/code&gt; what you expect?&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;5&#34;&gt;
&lt;li&gt;Implement &lt;code&gt;pluck()&lt;/code&gt;, which replaces the &lt;code&gt;n&lt;/code&gt; items in the ring buffer with &lt;code&gt;n&lt;/code&gt; &lt;em&gt;random&lt;/em&gt; values between −0.5 and +0.5. Use a combination of &lt;code&gt;RingBuffer&lt;/code&gt; methods including &lt;code&gt;dequeue()&lt;/code&gt; and &lt;code&gt;enqueue()&lt;/code&gt; to replace the buffer with values between −0.5 and 0.5. Hint: &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#StdRandom&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;StdRandom&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;When generating random values between −0.5 and +0.5, should I include the two endpoints?&lt;/strong&gt;&lt;/em&gt; The assignment specification does not specify, so you are free to choose whichever convention you find most convenient. In Java, we typically include the left endpoint of an interval and exclude the right endpoint. For example, &lt;code&gt;StdRandom.uniformDouble(-0.5, 0.5)&lt;/code&gt; generates a uniformly random value in the interval $[−0.5, 0.5)$ and &lt;code&gt;s.substring(i, j)&lt;/code&gt; returns the substring of the &lt;code&gt;String s&lt;/code&gt; beginning at index &lt;code&gt;i&lt;/code&gt; and ending at index &lt;code&gt;j - 1&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;How can I test the constructor and these methods?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Instantiate a &lt;code&gt;GuitarString&lt;/code&gt; object.&lt;/li&gt;
&lt;li&gt;Invoke &lt;code&gt;length()&lt;/code&gt; and &lt;code&gt;sample()&lt;/code&gt; on this object.&lt;/li&gt;
&lt;li&gt;Next invoke &lt;code&gt;pluck()&lt;/code&gt; on this object.&lt;/li&gt;
&lt;li&gt;Next invoke &lt;code&gt;length()&lt;/code&gt; and &lt;code&gt;sample()&lt;/code&gt; again on each object. Are the values returned what you expect?&lt;/li&gt;
&lt;li&gt;Try this with a few &lt;code&gt;GuitarString&lt;/code&gt; objects.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;6&#34;&gt;
&lt;li&gt;Implement &lt;code&gt;tic()&lt;/code&gt;. Use the &lt;code&gt;enqueue()&lt;/code&gt;, &lt;code&gt;dequeue()&lt;/code&gt;, and &lt;code&gt;peek()&lt;/code&gt; methods. This method applies the Karplus–Strong update: delete the first sample from the ring buffer and adds to the end of the ring buffer the average of the deleted sample and the first sample, scaled by an energy decay factor.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;How can I test the constructor and these methods?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Instantiate a &lt;code&gt;GuitarString&lt;/code&gt; object.&lt;/li&gt;
&lt;li&gt;Invoke &lt;code&gt;length()&lt;/code&gt; and &lt;code&gt;sample()&lt;/code&gt; on this object.&lt;/li&gt;
&lt;li&gt;Next invoke &lt;code&gt;tic()&lt;/code&gt; on this object.&lt;/li&gt;
&lt;li&gt;Next invoke &lt;code&gt;length()&lt;/code&gt; and &lt;code&gt;sample()&lt;/code&gt; again on each object. Are the values returned what you expect?&lt;/li&gt;
&lt;li&gt;Try this with a few &lt;code&gt;GuitarString&lt;/code&gt; objects.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;7&#34;&gt;
&lt;li&gt;&lt;em&gt;After&lt;/em&gt; you have implemented and tested each of the methods for &lt;code&gt;GuitarString&lt;/code&gt;, run &lt;code&gt;GuitarString&lt;/code&gt; using the test client in the &lt;em&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/em&gt; section.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;testing-your-guitarstringjava-implementation&#34;&gt;Testing Your &lt;code&gt;GuitarString.java&lt;/code&gt; Implementation&lt;/h4&gt;
&lt;p&gt;You can test your &lt;code&gt;GuitarString&lt;/code&gt;  data type using the following &lt;code&gt;main()&lt;/code&gt;. Note - this test is &lt;em&gt;not&lt;/em&gt; exhaustive, but it should help you debug.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// get frequency from command-line&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Double&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;parseDouble&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// create a GuitarString object with given frequency&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #0 - create GuitarString obj with frequency %f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// check length (sampling rate/frequency)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #1 - check length based on frequency %f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Length is %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// get one sample&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #2 - check sample is %.1f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Sample is %.1f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// create a simple GuitarString with 4 samples&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;7&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;8&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;9&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;6&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;len&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #3 - check length based on given samples == %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;              &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;len&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Length is %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// get a sample&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #4 - check sample is %.2f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Sample is %.2f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// now pluck and check length&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;pluck&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #5 - check length after pluck is still == %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;              &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;len&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Length is %d\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// check that a random sample is  [-0.5, +0.5)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #6 - check sample is range [-0.5, +0.5)\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Sample is %.2f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test tic and sample&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs3&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #7 - check sample is %.2f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Sample is %.1f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;tic&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #8 - check sample is %.2f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;samples&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;**** Sample is %.2f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test 25 tics&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;25&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// number of tics&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;moreSamples&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test #9 - test %d tics\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs4&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GuitarString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;moreSamples&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;%6d %8.4f\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;gs4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;tic&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run this test from the command line with some input n:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs GuitarString 440
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;(Test #1 - Test #8 not shown)...
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Test #9 - test 25 tics
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     0   0.2000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     1   0.4000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     2   0.5000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     3   0.3000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     4  -0.2000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     5   0.4000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     6   0.3000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     7   0.0000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     8  -0.1000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     9  -0.3000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    10   0.2988
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    11   0.4482
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    12   0.3984
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    13   0.0498
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    14   0.0996
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    15   0.3486
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    16   0.1494
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    17  -0.0498
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    18  -0.1992
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    19  -0.0006
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    20   0.3720
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    21   0.4216
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    22   0.2232
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    23   0.0744
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    24   0.2232
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;guitar-hero-client&#34;&gt;&lt;strong&gt;`Guitar Hero Client&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Implement an interactive guitar player.
&lt;code&gt;GuitarHeroLite.java&lt;/code&gt; is a &lt;code&gt;GuitarString&lt;/code&gt; client that plays guitar sounds in real time.
It relies on &lt;code&gt;Keyboard.java&lt;/code&gt;, which provides a simple GUI for reading keystrokes.
When the user types &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;v&lt;/code&gt;, the program plucks the guitar string corresponding
to middle C or concert A, respectively.
Since multiple sound waves add by &lt;em&gt;superposition&lt;/em&gt;, the program plays the sum of the
active string samples.&lt;/p&gt;
&lt;h4 id=&#34;requirements-2&#34;&gt;Requirements&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Write a program &lt;code&gt;GuitarHero&lt;/code&gt; that is similar to &lt;code&gt;GuitarHeroLite&lt;/code&gt;.
It must support 37 notes on the chromatic scale from 110 Hz to 880 Hz.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On each time step, sum the samples of all strings and play the result.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the following 37 keys (from lowest to highest note):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;keyboardString&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;q2we4r5ty7u8i9op-[=zxdcfvgbnjmk,.;/&amp;#39; &amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This keyboard arrangement imitates a piano keyboard:
the white keys are on the &lt;em&gt;qwerty&lt;/em&gt; and &lt;em&gt;zxcv&lt;/em&gt; rows, and
the black keys are on the &lt;em&gt;12345&lt;/em&gt; and &lt;em&gt;asdf&lt;/em&gt; rows.
For brevity, we name notes using sharps (e.g., A#) rather than the equivalent flats (e.g., B♭).&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/images/keyboard.png&#34; width=&#34;550&#34; alt=&#34;Guitar Hero keyboard&#34;&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Character index &lt;code&gt;i&lt;/code&gt; in &lt;code&gt;keyboardString&lt;/code&gt; corresponds to the frequency
$$ 440 \times 2^{(i − 24) / 12}\text{ } \text{ Hz} $$
Thus, &lt;code&gt;&#39;q&#39;&lt;/code&gt; is 110 Hz, &lt;code&gt;&#39;i&#39;&lt;/code&gt; is 220 Hz, and &lt;code&gt;&#39;v&#39;&lt;/code&gt; is 440 Hz.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Do not declare 37 individual &lt;code&gt;GuitarString&lt;/code&gt; variables or write a 37-way &lt;code&gt;if&lt;/code&gt; statement.
Instead, create an array of 37 &lt;code&gt;GuitarString&lt;/code&gt; objects and use &lt;code&gt;keyboardString.indexOf(key)&lt;/code&gt;
to determine which string to pluck.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details&gt;
  &lt;summary&gt;&lt;em&gt;Click here to show possible progress steps.&lt;/em&gt;&lt;/summary&gt;
  &lt;h4 id=&#34;implementing-guitarherojava&#34;&gt;Implementing &lt;code&gt;GuitarHero.java&lt;/code&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Test &lt;code&gt;GuitarString&lt;/code&gt; and &lt;code&gt;RingBuffer&lt;/code&gt; using &lt;code&gt;GuitarHeroLite&lt;/code&gt;. Which additional constructor and method does &lt;code&gt;GuitarHeroLite&lt;/code&gt; test?&lt;/li&gt;
&lt;li&gt;To implement &lt;code&gt;GuitarHero.java&lt;/code&gt;, use the code in &lt;code&gt;GuitarHeroLite.java&lt;/code&gt; as a starting point.&lt;/li&gt;
&lt;li&gt;Create an array of &lt;code&gt;GuitarString&lt;/code&gt; objects. Remember: to create an array of objects, you need to create the array, then you need to create each individual object.&lt;/li&gt;
&lt;li&gt;Can you play individual notes? Do the notes have the correct frequencies? Can you play a chord?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Where do I play notes in &lt;code&gt;GuitarHeroLite&lt;/code&gt; and &lt;code&gt;GuitarHero&lt;/code&gt;?&lt;/strong&gt;&lt;/em&gt; Be sure that the interactive &lt;code&gt;Keyboard&lt;/code&gt; window has focus by clicking it. Then, either click the piano keys or type the keystrokes.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;What happens if I call &lt;code&gt;StdAudio.play(x)&lt;/code&gt; where &lt;code&gt;x&lt;/code&gt; is greater than 1 or less than −1?&lt;/strong&gt;&lt;/em&gt; The value is clipped – it is replaced by the value +1.0 or −1.0, respectively. This is fine and can happen when you play chords.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Why do I get a &lt;code&gt;RuntimeException&lt;/code&gt; or an &lt;code&gt;ArrayIndexOutOfBoundsException&lt;/code&gt; in &lt;code&gt;GuitarHeroLite&lt;/code&gt; before I type any keystrokes?&lt;/strong&gt;&lt;/em&gt; Did you forget to initialize the ring buffer to contain &lt;code&gt;n&lt;/code&gt; zeros in your &lt;code&gt;GuitarString&lt;/code&gt; constructor?&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;When I run &lt;code&gt;GuitarHeroLite&lt;/code&gt; for the first time, I hear no sound. What am I doing wrong?&lt;/strong&gt;&lt;/em&gt; Make sure you have tested with the &lt;code&gt;main()&lt;/code&gt; provided for &lt;code&gt;GuitarString&lt;/code&gt;. If that works, there is likely something wrong with &lt;code&gt;pluck()&lt;/code&gt; since the &lt;code&gt;main()&lt;/code&gt; provided for &lt;code&gt;GuitarString&lt;/code&gt; does not test that method. To diagnose the problem, print the values of &lt;code&gt;sample()&lt;/code&gt; and check that they become nonzero after you type the keystrokes &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;When I run &lt;code&gt;GuitarHeroLite&lt;/code&gt;, I hear static (either just one click and then silence, or continual static). What am I doing wrong?&lt;/strong&gt;&lt;/em&gt; It&amp;rsquo;s likely that &lt;code&gt;pluck()&lt;/code&gt; is working, but &lt;code&gt;tic()&lt;/code&gt; is not. The best test is to run the &lt;code&gt;main()&lt;/code&gt; provided for &lt;code&gt;GuitarString&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;How do I use &lt;code&gt;keyboardString.indexOf(key)&lt;/code&gt;?&lt;/strong&gt;&lt;/em&gt; If &lt;code&gt;keyboardString&lt;/code&gt; is a &lt;code&gt;String&lt;/code&gt; and &lt;code&gt;key&lt;/code&gt; is a character, then &lt;code&gt;keyboardString.indexOf(key)&lt;/code&gt; returns the integer index of the first occurrence of the character &lt;code&gt;key&lt;/code&gt; in the &lt;code&gt;String keyboardString&lt;/code&gt;, or &lt;code&gt;–1&lt;/code&gt; if it does not occur.  You can read about it in the &lt;a href=&#34;https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/String.html#indexOf%28int%29&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;String&lt;/code&gt; Javadoc page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Can I hardwire the constants 44,100, 0.996, 440.0, and 37 in my program?&lt;/strong&gt;&lt;/em&gt; As usual, we may deduct style points for using an unnamed constant, especially if you use it more than once. We recommend using &lt;code&gt;SAMPLING_RATE&lt;/code&gt; for &lt;code&gt;44100&lt;/code&gt;, &lt;code&gt;DECAY_FACTOR&lt;/code&gt; for &lt;code&gt;0.996&lt;/code&gt;, &lt;code&gt;CONCERT_A&lt;/code&gt; for &lt;code&gt;440.0&lt;/code&gt;, and the expression &lt;code&gt;keyboardString.length()&lt;/code&gt; for &lt;code&gt;37&lt;/code&gt;. You do not need to name all of the constants in the formula:
\[ 440 \times 2^{(i − 24)/12} \]&lt;/p&gt;

&lt;/details&gt;

&lt;h3 id=&#34;rock-on-play-your-guitarhero&#34;&gt;&lt;strong&gt;Rock on! Play your GuitarHero&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Here are some example tunes you can play on your GuitarHero. Try these below, and then compose some of your own:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;An A major chord.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; i - z    i
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;          -
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;          z
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/Amajor.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/Amajor.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/Amajor.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/Amajor.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;
&lt;p&gt;An A major scale.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;i o - [ z d f v   v f d z [ - o i
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/Ascale.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/Ascale.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/Ascale.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/Ascale.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;
&lt;ol start=&#34;3&#34;&gt;
&lt;li&gt;
&lt;p&gt;Type the following into your guitar to get the beginning of Led Zeppelin&amp;rsquo;s &lt;em&gt;Stairway to Heaven&lt;/em&gt;. Multiple notes in a column are dyads and chords.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;                                              w q q
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        8       u       7       y             o p p
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;i p z v b z p b n z p n d [ i d z p i p z p i u i i
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;audio controls preload=&#34;auto&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/sth.wav&#34; type=&#34;audio/wav&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/sth.mpeg&#34; type=&#34;audio/mpeg&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/sth.mp3&#34; type=&#34;audio/mp3&#34;&gt;
  &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/audio/sth.ogg&#34; type=&#34;audio/ogg&#34;&gt;
  Your browser does not support the audio element.
&lt;/audio&gt;
&lt;ol start=&#34;4&#34;&gt;
&lt;li&gt;
&lt;p&gt;What is this familiar melody? (&lt;strong&gt;S&lt;/strong&gt; == space)&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;nn//SS/ ..,,mmn //..,,m //..,,m nn//SS/ ..,,mmn
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all required files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Guitar&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;RingBuffer.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GuitarString.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GuitarHero.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Files&lt;/th&gt;
          &lt;th&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;RingBuffer.java&lt;/td&gt;
          &lt;td&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;GuitarString.java&lt;/td&gt;
          &lt;td&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;GuitarHero.java&lt;/td&gt;
          &lt;td&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&#34;challenge&#34;&gt;&lt;strong&gt;Challenge&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a program &lt;code&gt;AutoGuitar.java&lt;/code&gt; that will automatically play music using &lt;code&gt;GuitarString&lt;/code&gt; objects.&lt;/p&gt;
&lt;h4 id=&#34;requirements-3&#34;&gt;Requirements&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;You &lt;strong&gt;may&lt;/strong&gt; use a &lt;code&gt;.txt&lt;/code&gt; file and read it using the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#In&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;In&lt;/code&gt;&lt;/a&gt; data type.&lt;/li&gt;
&lt;li&gt;The duration of your composition &lt;strong&gt;must&lt;/strong&gt; be between 10 and 120 seconds. Since the sampling rate is 44,100 Hz, this translates to between 441,000 and 5,292,000 calls to &lt;code&gt;StdAudio.play()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;You &lt;strong&gt;may&lt;/strong&gt; create chords, repetition, and phrase structure using loops, conditionals, arrays, and functions. Also, feel free to incorporate randomness.&lt;/li&gt;
&lt;li&gt;You &lt;strong&gt;may&lt;/strong&gt; also create a new music instrument by modifying the Karplus–Strong algorithm; consider changing the excitation of the string (from white noise to something more structured) or changing the averaging formula (from the average of the first two samples to a more complicated rule) or anything else you might imagine. See below for some ideas.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;enrichment&#34;&gt;&lt;strong&gt;Enrichment&lt;/strong&gt;&lt;/h3&gt;
&lt;details&gt;
  &lt;summary&gt;Click each item  to expand.&lt;/summary&gt;
  Click again to collapse the answer.
&lt;/details&gt;

&lt;!-- Need to update
&lt;details&gt;
  &lt;summary&gt;&lt;strong&gt;Challenge 2&lt;/strong&gt;: Write a program MidiGuitarHero that is similar to GuitarHero, but works with a MIDI keyboard controller keyboard or a MIDI Controller app running on your smartphone. The MIDI standard - Musical Instrument Digital Interface - is used by many electronic musical instruments.&lt;/summary&gt;
  &lt;h4 id=&#34;background&#34;&gt;Background&lt;/h4&gt;
&lt;p&gt;You will write a program &lt;code&gt;MidiGuitarHero.java&lt;/code&gt; that is similar to &lt;code&gt;GuitarHero.java&lt;/code&gt;, but works with a MIDI keyboard controller keyboard or a MIDI keyboard controller app (running on your smartphone or tablet connected to your laptop).  MIDI (Musical Instrument Digital Interface) is a technical standard for digital music. More details can be found on the &lt;a href=&#34;https://en.wikipedia.org/wiki/MIDI&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Wikipedia&lt;/a&gt; page.&lt;/p&gt;
&lt;h4 id=&#34;approach&#34;&gt;Approach&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;MidiSource.java&lt;/code&gt; class, provided in the assignment project folder,   maintains a &lt;em&gt;queue of short MIDI messages&lt;/em&gt;. See &lt;a href=&#34;https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/sound/midi/ShortMessage.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;javax.sound.midi.ShortMessage&lt;/a&gt; for details. The basic steps are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Connect a MIDI controller keyboard or app to a computer using USB.  See the figure below.&lt;/li&gt;
&lt;li&gt;Implement a client, &lt;code&gt;MidiGuitarHero&lt;/code&gt;, that uses the &lt;code&gt;MidiSource&lt;/code&gt; and &lt;code&gt;GuitarString&lt;/code&gt; classes.&lt;/li&gt;
&lt;li&gt;Create an array of &lt;code&gt;GuitarString&lt;/code&gt; objects, where each &lt;code&gt;GuitarString&lt;/code&gt; object corresponds to a key on a MIDI controller keyboard or app.&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;MidiSource&lt;/code&gt; object (with &lt;code&gt;connectToSynth&lt;/code&gt; set to &lt;code&gt;false&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Start the &lt;code&gt;MidiSource&lt;/code&gt; object so it can generate short MIDI messages each time a key is pressed/tapped. A MIDI message contains  an integer code that corresponds to a pressed key.
Access and interpret each short MIDI message generated.  Similarly to  &lt;code&gt;GuitarHero&lt;/code&gt;, &lt;code&gt;pluck&lt;/code&gt; the appropriate string, then sum all the samples, &lt;code&gt;play&lt;/code&gt; the resulting sample, then &lt;code&gt;tic&lt;/code&gt; all the strings&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;















&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/images/MIDI-USB-Computer.png&#34; alt=&#34;Midi controller connected to computer via usb&#34; loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h4 id=&#34;midisourcejava-api&#34;&gt;&lt;code&gt;MidiSource.java&lt;/code&gt; API&lt;/h4&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;MidiSource&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates a MidiSource object that listens to the first found connected &lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Midi input device.  Set verbose to true for verbose output (standard out).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Set  connectToSynth to true use Java’s MIDI player; false to use the&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// GuitarString sound&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;MidiSource&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;boolean&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;verbose&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;boolean&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;connectToSynth&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                                                                                            
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Starts the MidiSource object so it can produce messages.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;start&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;               
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                                          
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Closes the MidiSource object.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;close&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;     
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                                                     
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Does the MidiSource have more messages (keys pressed)?&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;boolean&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;isEmpty&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;    
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                                                 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns  code of the MIDI Controller key pressed&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;nextKeyPressed&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Demonstrates the MidiSource class - playing from a&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// keyboard or a Midi file - using the default Java synthesizer&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;   
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                                    
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;implementation-tasks&#34;&gt;Implementation Tasks&lt;/h4&gt;
&lt;h4 id=&#34;midiguitarherojava&#34;&gt;&lt;code&gt;MidiGuitarHero.java&lt;/code&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Connect your Midi keyboard controller (via USB) to your laptop - see below for using a smartphone or tablet.&lt;/li&gt;
&lt;li&gt;On the command line terminal, enter the command:
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs MidiSource -p
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Press some keys on your MIDI keyboard controller. You should see output similar to:
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;MidiSource version .2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DEVICE 0: Gervill, OpenJDK, Software MIDI Synthesizer, Midi device available, Not a MIDI keyboard controller, trying next...
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DEVICE 1: Port1, YAMAHA, YAMAHA PSR-1100 Port1, Midi device available, Valid MIDI controller connected.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ShortMessage:  Command: NOTE_ON (144)  Channel: 0 Number:   77 Velocity: 21
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ShortMessage:  Command: NOTE_ON (144)  Channel: 0 Number:   77 Velocity: 0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Each time you press a key on the MIDI keyboard controller, a MIDI message is produced. The message contains:
&lt;ul&gt;
&lt;li&gt;the command type&lt;/li&gt;
&lt;li&gt;the channel&lt;/li&gt;
&lt;li&gt;the data1 value&lt;/li&gt;
&lt;li&gt;the date2 value&lt;/li&gt;
&lt;li&gt;(For details, see &lt;a href=&#34;https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/sound/midi/ShortMessage.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;javax.sound.midi.ShortMessage&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;For the most part, you will want to capture messages whose command type is &lt;code&gt;NOTE_ON&lt;/code&gt;. The &lt;code&gt;data1&lt;/code&gt; value corresponds to the key number (similarly to the index in the &lt;code&gt;String&lt;/code&gt; keyboard in &lt;code&gt;GuitarHero.java&lt;/code&gt;) and the &lt;code&gt;data2&lt;/code&gt; value corresponds to the velocity of the pressed key. (Some MIDI controllers generate a &lt;code&gt;NOTE_ON&lt;/code&gt; and a velocity value of 0 when releasing a key - you will want to ignore those messages.)&lt;/li&gt;
&lt;li&gt;The general structure of your code should look like this:
&lt;ul&gt;
&lt;li&gt;Create an array of &lt;code&gt;GuitarString&lt;/code&gt; objects. The size of the array depends on how many notes you want to be able to produce.&lt;/li&gt;
&lt;li&gt;You need to generalize the formula for the frequency of each &lt;code&gt;GuitarString&lt;/code&gt; object, i.e., $440 \times 2^{(k − 24) / 12$).   One way to do this is to determine the key number of A4 (concert A or 440 Hz).&lt;/li&gt;
&lt;li&gt;For example, here’s an 88-key piano keyboard with A4 (and C4) labeled: 















&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/images/MIDI-keyboard.png&#34; alt=&#34;https://en.wikipedia.org/wiki/Piano_key_frequencies&#34; loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;Create and start the &lt;code&gt;MidiSource&lt;/code&gt; object.&lt;/li&gt;
&lt;li&gt;Similarly to &lt;code&gt;GuitarHero&lt;/code&gt;, write a loop that gets the next short Midi message. Interpret the message, and if it&amp;rsquo;s a &lt;code&gt;NOTE_ON&lt;/code&gt; with a velocity &lt;em&gt;greater than zero (0)&lt;/em&gt;, &lt;code&gt;pluck&lt;/code&gt; the appropriate &lt;code&gt;GuitarString&lt;/code&gt; object.  Then compute the sum  of the samples, &lt;code&gt;play&lt;/code&gt; the sum and &lt;code&gt;tic&lt;/code&gt; the &lt;code&gt;GuitarString&lt;/code&gt; objects.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;additional-challenges&#34;&gt;Additional Challenges!&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;When you execute the following command, try  pressing other buttons on your Midi keyboard controller. By understanding other MIDI codes (e.g., &lt;code&gt;CONTROL_CHANGE&lt;/code&gt;), you can use your Midi keyboard controller to change instruments. Of course, you need to create new music instruments by modifying the Karplus–Strong algorithm.
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs MidiSource -p
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;The MidiSource class can also generate MIDI messages from MIDI files. You can experiment by downloading chopstik.mid and executing the command:
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs MidiSource -p chopstik.mid
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;As you can see, different channels correspond to different instruments. If you have implemented multiple instruments, you can write an &lt;code&gt;MidiAutoGuitar.java&lt;/code&gt; that plays your instruments from an existing MIDI file.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;midi-controllers&#34;&gt;MIDI Controllers&lt;/h4&gt;
&lt;h4 id=&#34;midi-controller-keyboard-and-usb&#34;&gt;MIDI Controller Keyboard and USB&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Almost any MIDI keyboard controller with a USB interface will suffice (for example, a 25-key MIDI keyboard controller can be purchased on Amazon for about $40).&lt;/li&gt;
&lt;li&gt;Connect the MIDI keyboard to your laptop.&lt;/li&gt;
&lt;li&gt;In the terminal window, execute the command:
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs MidiSource
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Press the keys on the keyboard to see the MIDI messages (numbers) generated by each key.















&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/guitar/images/java-introcs_MidiSource.png&#34; alt=&#34;MIDI messages&#34; loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;iphone-with-ios-mac-os-and-usb&#34;&gt;iPhone with iOS, Mac OS and USB&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Download/install the &lt;a href=&#34;https://apps.apple.com/us/app/midi-wrench/id589243566&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;MIDI controller app&lt;/a&gt; from the Apple App Store.&lt;/li&gt;
&lt;li&gt;Connect your iPhone/iPad to your Mac laptop using the USB connector.&lt;/li&gt;
&lt;li&gt;On your Mac:
&lt;ul&gt;
&lt;li&gt;Start the Audio Midi Setup application (in the Applications/Utilities folder)&lt;/li&gt;
&lt;li&gt;Under Window/Show Audio Devices and enable your iPhone&lt;/li&gt;
&lt;li&gt;In the terminal window on your Mac laptop, execute the command:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs MidiSource
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Start the MIDI controller app.&lt;/li&gt;
&lt;li&gt;Press the keys on the MIDI Controller app to see the MIDI messages (numbers) generated by each key.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;android-and-usb&#34;&gt;Android and USB&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Download/install/start the &lt;a href=&#34;https://play.google.com/store/apps/details?id=com.mobileer.midikeyboard&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;MIDI controller app&lt;/a&gt; from the Google Play Store.&lt;/li&gt;
&lt;li&gt;Connect your Android device to your laptop using the USB connector.&lt;/li&gt;
&lt;li&gt;On your Android  device:
&lt;ul&gt;
&lt;li&gt;Show the notification screen by dragging down from the top of the display.&lt;/li&gt;
&lt;li&gt;Tap Use device MIDI. (Different versions of Android may require different settings.)&lt;/li&gt;
&lt;li&gt;In the terminal window on your laptop, execute the command:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs MidiSource
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;On the MIDI Controller app, tap Receivers for Keys and select Android USB Peripheral Port.&lt;/li&gt;
&lt;li&gt;Press the keys on the MIDI Controller app to see the MIDI messages (numbers) generated by each key.&lt;/li&gt;
&lt;/ol&gt;

&lt;/details&gt;

--&gt;
&lt;details&gt;
  &lt;summary&gt;&lt;strong&gt;Synthesizing Additional Instruments&lt;/strong&gt;&lt;/summary&gt;
  &lt;p&gt;Here are some approaches for synthesizing additional instruments. Some come from the &lt;a href=&#34;http://www.jstor.org/stable/10.2307/3680062&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;paper&lt;/a&gt; of Karplus and Strong.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Harp strings: Flipping the sign of the new value before enqueueing it in &lt;code&gt;tic()&lt;/code&gt; will change the sound from guitar-like to harp-like. You may want to play with the decay factors to improve the realism, and adjust the buffer sizes by a factor of two since the natural resonance frequency is cut in half by the &lt;code&gt;tic()&lt;/code&gt; change.&lt;/li&gt;
&lt;li&gt;Drums: Flipping the sign of a new value with probability 0.5 before enqueueing it in &lt;code&gt;tic()&lt;/code&gt; will produce a drum sound. A decay factor of 1.0 (no decay) will yield a better sound, and you will need to adjust the set of frequencies used.&lt;/li&gt;
&lt;li&gt;Guitars play each note on one of six physical strings. To simulate this you can divide your &lt;code&gt;GuitarString&lt;/code&gt; instances into six groups, and when a string is plucked, zero out all other strings in that group.&lt;/li&gt;
&lt;li&gt;Pianos come with a damper pedal which can be used to make the strings stationary. You can implement this by changing the decay factor on iterations where a certain key (such as Shift) is &lt;a href=&#34;http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdDraw.html#isKeyPressed%28int%29&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;held down&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;While we have used &lt;a href=&#34;http://en.wikipedia.org/wiki/Equal_temperament&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;equal temperament&lt;/a&gt;, the ear finds it more pleasing when musical intervals follow the small fractions in the &lt;a href=&#34;http://en.wikipedia.org/wiki/Just_intonation&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;just intonation&lt;/a&gt; system. For example, when a musician uses a brass instrument to play a &lt;a href=&#34;http://en.wikipedia.org/wiki/Perfect_fifth&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;perfect fifth&lt;/a&gt; harmonically, the ratio of frequencies is $ 3/2 = 1.5$ rather than $2^{7/12} ∼ 1.49$). Write a program where each successive pair of notes has just intonation.&lt;/li&gt;
&lt;/ul&gt;
&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;&lt;strong&gt;Related Work&lt;/strong&gt;&lt;/summary&gt;
  &lt;ul&gt;
&lt;li&gt;&lt;em&gt;ChucK&lt;/em&gt;. &lt;a href=&#34;http://chuck.cs.princeton.edu/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;ChucK&lt;/a&gt; is a specialized programming language for real-time synthesis, composition, and performance originated by &lt;a href=&#34;https://ccrma.stanford.edu/~ge&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Ge Wang&lt;/a&gt; and &lt;a href=&#34;http://www.cs.princeton.edu/~prc/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Perry Cook&lt;/a&gt; at Princeton University. Here&amp;rsquo;s the &lt;a href=&#34;http://chuck.cs.princeton.edu/doc/examples/deep/plu.ck&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Karplus–Strong algorithm in ChucK&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Slide flute&lt;/em&gt;. Here&amp;rsquo;s a description of a physically modeled &lt;a href=&#34;http://ccrma.stanford.edu/software/clm/compmus/clm-tutorials/pm.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;slide flute&lt;/a&gt; by Perry Cook.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Electric guitar synthesis&lt;/em&gt;. In COS 325/MUS 315 &lt;em&gt;Transforming Reality by Computer&lt;/em&gt;, Charlie Sullivan &amp;lsquo;87 extended the Karplus–Strong algorithm to synthesize electric guitar timbres with distortion and feedback. Here&amp;rsquo;s his Jimi Hendrix-ified version of &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/spr20/cos126/assignments/guitar/autoguitar/CharlieSullivanStar.mp3&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;The Star Spangled Banner&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;/details&gt;

&lt;p&gt;&lt;em&gt;This assignment was developed by Andrew Appel, Jeff Bernstein, Alan Kaplan, Maia Ginsburg, Ken Steiglitz, Ge Wang, and Kevin Wayne.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Copyright © 2005–2026&lt;/em&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>7. Chat126</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/chat126/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/chat126/</guid>
      <description>&lt;!-- &lt;p style=&#34;color:red;&#34;&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt;  This assignment has not been officially released yet and is subject to change!&lt;/p&gt;

 --&gt;
&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/chat126/chat126.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Chat126&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this assignment, you will build a Markov model from an English text,
then simulate it to generate stylized pseudorandom text.
You will use symbol tables to store and look up $k$-grams efficiently.&lt;/em&gt;&lt;/p&gt;
&lt;!--
### **Goals**

- To learn about symbol tables.
- To learn about natural language processing.
- To use a Markov chain to create a statistical model of a piece of English text.
- To simulate the Markov chain to generate stylized pseudo-random text.
--&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Review the textbook material on parameterized data type and generics (pages 566–570).&lt;/li&gt;
&lt;li&gt;Read the beginning of Section 4.4 (pages 582–586) on using symbol tables in client code.&lt;/li&gt;
&lt;li&gt;Consult the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#ST&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;ST API&lt;/a&gt; API as needed.&lt;/li&gt;
&lt;li&gt;Review the precept exercises, especially &lt;code&gt;FrequencyTable.java&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/chat126/chat126.zip&#34;&gt;chat126.zip&lt;/a&gt;
, then open the &lt;code&gt;chat126&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Review the partner collaboration policy.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;background&#34;&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Modern generative AI systems like &lt;em&gt;ChatGPT&lt;/em&gt; produce text by modeling language and predicting what comes next.&lt;/li&gt;
&lt;li&gt;In this assignment, you will build a much simpler model—&lt;em&gt;an order-k Markov model&lt;/em&gt;—that
can still generate stylized text.&lt;/li&gt;
&lt;li&gt;Markov models are lightweight and fast to train and simulate.&lt;/li&gt;
&lt;li&gt;Claude Shannon proposed using &lt;em&gt;Markov chains&lt;/em&gt; to model English text in 1948;
here you&amp;rsquo;ll implement a playful variant to generating stylized pseudorandom text.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;markov-model-of-natural-language&#34;&gt;Markov model of natural language&lt;/h3&gt;
&lt;p&gt;A &lt;em&gt;Markov model&lt;/em&gt; generates text one character at a time by sampling from
probability distributions estimated from an input text.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Order 0.&lt;/strong&gt;
An &lt;em&gt;order-0 Markov model&lt;/em&gt; chooses each character independently from a fixed distribution.
We fit an order-0 model by counting character frequencies in the input text.
For example, if the input text is&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;g a g g g a g a g g c g a g a a a
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;then the model predicts &lt;code&gt;a&lt;/code&gt; with probability 7/17, &lt;code&gt;c&lt;/code&gt; with probability 1/17, and &lt;code&gt;g&lt;/code&gt; with probability 9/17.
A typical generated sequence looks like:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;g a g g c g a g a a g a g a a g a a a g a g a g a g a a a g a g a a g ...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Order $k$.&lt;/strong&gt;
Independence is a poor approximation for English: characters are strongly correlated
(e.g., &lt;code&gt;q&lt;/code&gt; is usually followed by &lt;code&gt;u&lt;/code&gt;).
An &lt;em&gt;order-$k$ Markov model&lt;/em&gt; lets the next character depend on the previous $k$
characters, called a &lt;em&gt;$k$-gram&lt;/em&gt;.
For example, if &lt;code&gt;th&lt;/code&gt; is followed by &lt;code&gt;e&lt;/code&gt;, &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, and &lt;code&gt;o&lt;/code&gt; with frequencies 60, 25, 10, and 5 (out of 100),
then an order-2 model predicts that after &lt;code&gt;th&lt;/code&gt; the next letter is &lt;code&gt;e&lt;/code&gt; with probability 3/5, &lt;code&gt;i&lt;/code&gt; with
probability 1/4, &lt;code&gt;a&lt;/code&gt; with probability 1/10, and &lt;code&gt;o&lt;/code&gt; with probability 1/20.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Generating text.&lt;/strong&gt;
To generate text from an order-$k$ model, start with an initial $k$-gram from the input.
Repeatedly sample the next character according to the distribution for the current $k$-gram,
append it to the output, and update the $k$-gram by dropping its first character
and adding the sampled character.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Efficiency.&lt;/strong&gt; A brute-force implementation that repeatedly searches the input
text to find what follows the current $k$-gram is too slow for large inputs.
Instead, we will preprocess the text and store the necessary counts so that we
can sample the next character efficiently.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What did Shannon propose?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;in his landmark paper
&lt;a href=&#34;https://en.wikipedia.org/wiki/A_Mathematical_Theory_of_Communication&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;A Mathematical Theory of Communication&lt;/a&gt;.
That idea helped launch information theory and remains influential today.
Shannon described a manual method for generating text from a Markov model: repeatedly find an occurrence of the
current $k$-gram in a book and record the character that follows it. Your task is to automate this process in
an efficient manner. A direct brute-force implementation becomes too slow on large input texts.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;markov-language-model&#34;&gt;&lt;strong&gt;Markov Language Model&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Write a data type &lt;code&gt;MarkovLM&lt;/code&gt; to represent a Markov model of order \(k\) based
on a given input text. Implement the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates a Markov language  model of order k from the given text.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;k&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the order k of the model.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;order&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a string representation of the model (see below).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;toString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the number of times the k-gram occurs in the input text.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;kgram&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the number of times character c follows the k-gram&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// in the input text.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;kgram&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;char&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a character chosen at random, with probability proportional&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// to the number of times each character follows the k-gram in&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// the input text.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;char&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;predictNext&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;kgram&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Tests this class by directing calling all instance methods.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;API.&lt;/strong&gt; You must follow the prescribed API, with the given signatures.
Do not add &lt;code&gt;public&lt;/code&gt; methods.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Constructor.&lt;/strong&gt;
You may assume that the input text contains only ASCII characters (&lt;code&gt;char&lt;/code&gt; values between 0 and 127).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;String representation.&lt;/strong&gt;
Return a string representation of the model as illustrated below:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;aa: a 1 g 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ag: a 3 g 2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cg: a 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ga: a 1 g 4
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gc: g 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gg: a 1 c 1 g 1
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Include one line for each $k$-gram that appears in the text. Each line contains the \(k\)-gram, followed
by a colon; followed by each character that appears in the text immediately after that \(k\)-gram and the
number of times it appears, with a space between each component. The $k$-grams must appear in lexicographic
order, and the characters for each $k$-gram must appear in ASCII order.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Predict next character.&lt;/strong&gt;
The &lt;code&gt;predictNext()&lt;/code&gt; method must return a character that follows the given \(k\)-gram in the text,
chosen at random with probability proportional to the number of times that character follows the $k$-gram.
For  example if &lt;code&gt;&amp;quot;ga&amp;quot;&lt;/code&gt; appears 5 times—once followed by &lt;code&gt;a&lt;/code&gt; and four times followed by &lt;code&gt;g&lt;/code&gt;—then
&lt;code&gt;predictNext(&amp;quot;ga&amp;quot;)&lt;/code&gt; returns &lt;code&gt;a&lt;/code&gt; with probability 1/5 and &lt;code&gt;g&lt;/code&gt; with  probability 4/5, independently on each call.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Circular string.&lt;/strong&gt;
To avoid dead ends, treat the input text as a &lt;em&gt;circular string&lt;/em&gt;:
the first character succeeds the the last character.
For example, if $k = 2$ and the input text is &lt;code&gt;&amp;quot;gagggagaggcgagaaa&amp;quot;&lt;/code&gt;, then the model counts
wrap-around $k$-grams as well.
In particular, the frequency of &lt;code&gt;&amp;quot;ag&amp;quot;&lt;/code&gt; is 5 (not 4) because one occurrence crosses the end of the string.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/chat126/images/example-circular.jpg&#34; width=&#34;650&#34; alt=&#34;&#34;&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- As another example, consider the text 6-character string `&#34;banana&#34;`.  If \\(k = 2\\), then there are 6 2-grams: `&#34;ba&#34;`, `&#34;an&#34;`, `&#34;na&#34;`, `&#34;an&#34;`, `&#34;na&#34;`, `&#34;ab&#34;`:

&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/chat126/images/banana-circular.jpg&#34; width=&#34;400&#34; alt=&#34;&#34;&gt; --&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Corner cases.&lt;/strong&gt; Throw appropriate exceptions for invalid arguments.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;freq()&lt;/code&gt; and &lt;code&gt;predictNext()&lt;/code&gt;, throw an &lt;code&gt;IllegalArgumentException&lt;/code&gt; if &lt;code&gt;kgram&lt;/code&gt; is not of length $k$.&lt;/li&gt;
&lt;li&gt;In &lt;code&gt;predictNext()&lt;/code&gt;, throw an &lt;code&gt;IllegalArgumentException&lt;/code&gt; if &lt;code&gt;kgram&lt;/code&gt; does not appear in the input text.&lt;/li&gt;
&lt;li&gt;We will not test your data type with &lt;code&gt;null&lt;/code&gt; arguments.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performance requirements.&lt;/strong&gt;
Assume $k$ is a fixed constant. Let $n$ be the number of characters in the input text.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The constructor must run in time proportional to $n \log n$ (or better)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;order()&lt;/code&gt; must run in constant time&lt;/li&gt;
&lt;li&gt;&lt;code&gt;predictNext()&lt;/code&gt; and the two &lt;code&gt;freq()&lt;/code&gt; methods must run in time proportional to $\log n$  (or better)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To meet these requirements, use one or more symbol tables with $k$-grams as keys.
and values that support efficient implementation of the two freq() methods.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is the worst-case running time for common symbol-table operations?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;For the &lt;code&gt;ST&lt;/code&gt; and &lt;code&gt;java.util.TreeMap&lt;/code&gt; classes, the worst-case running time of
&lt;code&gt;put()&lt;/code&gt;, &lt;code&gt;get()&lt;/code&gt; and &lt;code&gt;contains()/containsKey()&lt;/code&gt; is $\Theta(log n)$.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I extract a substring of a given string?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use &lt;code&gt;substring()&lt;/code&gt;. For example, &lt;code&gt;s.substring(i, i + k)&lt;/code&gt; returns
the &lt;code&gt;k&lt;/code&gt;-character substring of the string &lt;code&gt;s&lt;/code&gt;, starting at &lt;code&gt;i&lt;/code&gt;. Note that it
includes the left endpoint but excludes the right endpoint.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I generate a random index with probability proportional to its weight?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Review &lt;code&gt;StdRandom.discrete()&lt;/code&gt;, which is overloaded:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One takes a floating-point array &lt;code&gt;probabilities[]&lt;/code&gt; and returns index &lt;code&gt;i&lt;/code&gt; with probability equal to
&lt;code&gt;probabilities[i]&lt;/code&gt;. The array entries must be nonnegative and sum to 1.&lt;/li&gt;
&lt;li&gt;The other takes an integer array &lt;code&gt;frequencies[]&lt;/code&gt; and returns index &lt;code&gt;i&lt;/code&gt; with probability proportional to
&lt;code&gt;frequencies[i]&lt;/code&gt;. The array entries must be nonnegative and not all zero.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;text-generator&#34;&gt;Text Generator&lt;/h3&gt;
&lt;p&gt;A Markov chain is a stochastic process in which the next state depends only on the current state.
For text generation, the state is a $k$-gram.
At each step, choose the next character at random using the probabilities from the Markov model,
then form the next state by appending that character and dropping the first character of
the $k$-gram.&lt;/p&gt;
&lt;p&gt;For example, if the current state is &lt;code&gt;&amp;quot;ga&amp;quot;&lt;/code&gt; in the order-2 model above,
then the next character is &lt;code&gt;a&lt;/code&gt; with probability $1/5$ and &lt;code&gt;g&lt;/code&gt; with probability $4/5$.
One possible trajectory (nine transitions) is:&lt;/p&gt;
&lt;p&gt;$$ ga \rightarrow
ag \rightarrow
gg \rightarrow
gc \rightarrow
cg \rightarrow
ga \rightarrow
ag \rightarrow
ga \rightarrow
aa \rightarrow
ag
$$&lt;/p&gt;
&lt;p&gt;Treating the input text as a circular string ensures that the Markov chain never gets stuck in a state with no
possible next character.&lt;/p&gt;
&lt;p&gt;To generate text from an order-$k$ model, start in the initial state
given by the first $k$ characters of the input text.
Then perform $T - k$ transitions, printing the sampled character at each step.
For example, if $k = 2$ and $T = 11$, the following trajectory could produce the output &lt;code&gt;gaggcgagaag&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;trajectory:  ga --&amp;gt; ag --&amp;gt; gg --&amp;gt; gc --&amp;gt; cg --&amp;gt; ga --&amp;gt; ag --&amp;gt; ga --&amp;gt; aa --&amp;gt; ag
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;output:      ga      g      g      c      g      a      g      a      a      g
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Write a client program &lt;code&gt;Chat126&lt;/code&gt; that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;takes two integer command-line arguments $k$ and $T$;&lt;/li&gt;
&lt;li&gt;reads the input text from standard input;&lt;/li&gt;
&lt;li&gt;builds an order-$k$ Markov model from the input text; and&lt;/li&gt;
&lt;li&gt;prints $T$ characters generated by simulating a trajectory through the corresponding Markov chain,
starting from the first $k$ characters of the input text..&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/chat126&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;more input17.txt&lt;/span&gt;
gagggagaggcgagaaa

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/chat126&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Chat126 2 11 &amp;lt; input17.txt&lt;/span&gt;
gaggcgagaag

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/chat126&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Chat126 2 11 &amp;lt; input17.txt&lt;/span&gt;
gaaaaaaagag

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/chat126&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Chat126 0 50 &amp;lt; input17.txt&lt;/span&gt;
gaaagaacagcagacgacggaagaaggaggaaaaggaggggaggggggag
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Corner cases.&lt;/strong&gt;
You may assume that the length of the text is at least $k$ and $T \geq k$.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performance requirement.&lt;/strong&gt;
If $k$ is a fixed constant, then the running time of Chat126 must be proportional to $n \log n + T \log n$
(or better), where $(n$ is the number of characters in the input text and $(T$ is the number of
characters in the output.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details&gt;
  &lt;summary&gt;&lt;em&gt;Click here to show possible progress steps for &lt;code&gt;MarkovLM&lt;/code&gt;.&lt;/em&gt;&lt;/summary&gt;
  &lt;h4 id=&#34;implementing-markovlmjava&#34;&gt;Implementing &lt;code&gt;MarkovLM.java&lt;/code&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Review precept exercises, especially &lt;code&gt;FrequencyTable&lt;/code&gt;,  as well as &lt;a href=&#34;https://introcs.cs.princeton.edu/42sort/IntegerSort.java.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;IntegerSort.java&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Create one or more instance variables to support the two &lt;code&gt;freq()&lt;/code&gt; methods. &lt;em&gt;One&lt;/em&gt; strategy is to maintain two symbol tables—one for the one-argument &lt;code&gt;freq()&lt;/code&gt; method and one for the two-argument &lt;code&gt;freq()&lt;/code&gt; method.&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;For each $k$-gram (a string), the first symbol table tells you how many times it appears in the text (an integer).&lt;/li&gt;
&lt;li&gt;For each $k$-gram (a string), the second symbol table tells you how many times each ASCII character succeeds the
$k$-gram in the text (an array of 128 integers).&lt;/li&gt;
&lt;li&gt;Character (i.e., &lt;code&gt;char&lt;/code&gt; values) can be used as an index into an array.  In Java, characters are 16-bit (unsigned) integers; they are promoted to &lt;code&gt;int&lt;/code&gt; values in any context that expects one. For example, &lt;code&gt;array[&#39;c&#39;]&lt;/code&gt; is equivalent to &lt;code&gt;array[99]&lt;/code&gt; because the ASCII code for &lt;code&gt;&#39;c&#39;&lt;/code&gt; is 99.&lt;/li&gt;
&lt;li&gt;You can avoid hardwiring the constant 128 by using a static instance variable: &lt;code&gt;private static final int ASCII = 128;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;This code should appear inside the class block, but before any instance variables or methods. By convention, constant variable names should be ALL_UPPERCASE. The &lt;code&gt;static&lt;/code&gt; modifier means that every instance method will refer to the same variable (as opposed to instance variables, for which there is one variable per object); the &lt;code&gt;final&lt;/code&gt; modifier means that you can&amp;rsquo;t change its value, once initialized.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;3&#34;&gt;
&lt;li&gt;Write the constructor to create the circular version of the input text. Then initialize and populate your symbol tables, using the symbol table methods &lt;code&gt;contains()&lt;/code&gt;, &lt;code&gt;get()&lt;/code&gt;, and &lt;code&gt;put()&lt;/code&gt;. This will be a substantial amount of code, relative to the other methods in this class.&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Do not save the original text (or the circular text) as an instance variable because no instance method will need this information after the symbol table is initialized.&lt;/li&gt;
&lt;li&gt;There are a number of approaches for emulating the circular text. One way is to append the first $k$ characters of the input text to the input text.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;4&#34;&gt;
&lt;li&gt;Test: In the &lt;code&gt;main()&lt;/code&gt;, try creating some &lt;code&gt;MarkovLM&lt;/code&gt; objects. For example:
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;banana&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;...&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;gagggagaggcgagaaa&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Write the &lt;code&gt;toString()&lt;/code&gt; method. Use an enhanced for loop to access each key–value pair in your symbol table and a &lt;code&gt;StringBuilder&lt;/code&gt; to generate the required &lt;code&gt;String&lt;/code&gt; value. See the &lt;code&gt;FrequencyTable.java&lt;/code&gt; from precept for an example.&lt;/li&gt;
&lt;li&gt;Test the constructor and &lt;code&gt;toString() method&lt;/code&gt;: This can help you debug small test cases. In the &lt;code&gt;main()&lt;/code&gt;, print some &lt;code&gt;MarkovLM&lt;/code&gt; objects. For example:
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;banana&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;...&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;gagggagaggcgagaaa&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Sample output from the code snippet above:
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ab: a 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;an: a 2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ba: n 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;na: b 1 n 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;aa: a 1 g 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ag: a 3 g 2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cg: a 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ga: a 1 g 4
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gc: g 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gg: a 1 c 1 g 1
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;You can insert a &lt;em&gt;line break&lt;/em&gt; in a &lt;code&gt;String&lt;/code&gt; by using the characters &lt;code&gt;\n&lt;/code&gt;. For example, if you print  &lt;code&gt;&amp;quot;ab\ncd&amp;quot;&lt;/code&gt;, &lt;code&gt;ab&lt;/code&gt; and &lt;code&gt;cd&lt;/code&gt; will appear on separate lines.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;7&#34;&gt;
&lt;li&gt;Write the &lt;code&gt;order()&lt;/code&gt; method. This should be a one-liner.&lt;/li&gt;
&lt;li&gt;Using the symbol table instance variables, write the two &lt;code&gt;freq()&lt;/code&gt; methods.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;main()&lt;/code&gt; provided above to test your code before continuing. In the &lt;code&gt;main&lt;/code&gt; method, you should add more tests of the constructor, &lt;code&gt;order()&lt;/code&gt;, and &lt;code&gt;freq()&lt;/code&gt; methods.&lt;/li&gt;
&lt;li&gt;Write the &lt;code&gt;predictNext()&lt;/code&gt; method. To generate a random character with probability proportional to its frequency you may call either of the two &lt;a href=&#34;https://introcs.cs.princeton.edu/java/stdlib/javadoc/StdRandom.html#discrete-double:A-&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;StdRandom.discrete()&lt;/code&gt;&lt;/a&gt; methods.&lt;/li&gt;
&lt;li&gt;It may not be obvious from your final results whether &lt;code&gt;predictNext()&lt;/code&gt; is working as intended, so be sure to test it thoroughly. Next, test your complete &lt;code&gt;MarkovLM&lt;/code&gt; data type before continuing. (See &lt;em&gt;Testing Your &lt;code&gt;MarkovLM.java&lt;/code&gt; Implementation&lt;/em&gt; below.)&lt;/li&gt;
&lt;/ol&gt;

&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;&lt;em&gt;Click here to show possible progress steps for Chat126.&lt;/em&gt;&lt;/summary&gt;
  &lt;h4 id=&#34;implementing-chat126java&#34;&gt;Implementing &lt;code&gt;Chat126.java&lt;/code&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Read in &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;T&lt;/code&gt; from the command line; read the input text from standard input.&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;MarkovLM&lt;/code&gt; object of order &lt;code&gt;k&lt;/code&gt; using the input text.&lt;/li&gt;
&lt;li&gt;To generate a trajectory of length &lt;code&gt;T&lt;/code&gt;, use the first &lt;code&gt;k&lt;/code&gt; characters in the input text as the initial \(k\)-gram and print the initial \(k\)-gram. Then, repeatedly generate and print a new random character according to the Markov model and update the \(k\)-gram to store the last &lt;code&gt;k&lt;/code&gt; characters printed.&lt;/li&gt;
&lt;li&gt;Make sure to test your program on large inputs (we provide several), large outputs, and different values of &lt;code&gt;k&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Some FAQs:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Should my program generate a different output each time I run it?&lt;/em&gt;  Yes.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;How can I read in the input text from standard input?&lt;/em&gt; Use &lt;code&gt;StdIn.readAll()&lt;/code&gt;. Do not remove whitespace.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;My random text ends in the middle of a sentence. Is that OK?&lt;/em&gt; Yes, that&amp;rsquo;s to be expected.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;After executing the program, the command prompt appears on the same line as the random text. Is that OK?&lt;/em&gt; Yes. It&amp;rsquo;s because the random text does not end with a newline character. If you want to add a call to &lt;code&gt;StdOut.println()&lt;/code&gt; at the end of your program, that&amp;rsquo;s fine—we promise not to deduct.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;What does this message mean: The local variable &amp;lsquo;T&amp;rsquo; must start with a lowercase letter and use camelCase?&lt;/em&gt; Since &lt;code&gt;T&lt;/code&gt; is a constant, you should declare it as &lt;code&gt;final&lt;/code&gt;, e.g., &lt;code&gt;final int T = ...&lt;/code&gt;.  Alternatively, you can rename the constant using a variable name that is more than one character.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;For which values of \(k\) should my program work?&lt;/em&gt; It should work for all well defined values of \(k\), from 0 up to, and including, the length of the input text. As \(k\) gets larger, your program will use more memory and take longer.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;My program is slow when \(T\) is large because I am concatenating the \(T\) characters, one at a time, to form string of length \(T\)). What else can I do?&lt;/em&gt; Do you need to form the entire string? Why not print the characters, one at a time, as you generate them?&lt;/li&gt;
&lt;li&gt;&lt;em&gt;I get an &lt;code&gt;OutOfMemoryException&lt;/code&gt;. How do I tell Java to use more of my computer&amp;rsquo;s memory?&lt;/em&gt; Depending on your operating system, you may have to ask the Java Virtual Machine for more main memory beyond the default.  The &lt;code&gt;500m&lt;/code&gt; means 500MB, and you should adjust this number depending on the size of the input text.
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs -Xmx500m Chat126 7 1000 &amp;lt; input.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;/details&gt;

&lt;h3 id=&#34;testing&#34;&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/h3&gt;
&lt;h4 id=&#34;testing-your-markovlmjava-implementation&#34;&gt;Testing Your &lt;code&gt;MarkovLM.java&lt;/code&gt; Implementation&lt;/h4&gt;
&lt;p&gt;We provide a &lt;code&gt;main()&lt;/code&gt; as a &lt;em&gt;start&lt;/em&gt; to your testing.  You will need to provide &lt;em&gt;more&lt;/em&gt; tests.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;banana&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;freq(\&amp;#34;an\&amp;#34;, &amp;#39;a&amp;#39;)    = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;an&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;sc&#34;&gt;&amp;#39;a&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;freq(\&amp;#34;na\&amp;#34;, &amp;#39;b&amp;#39;)    = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;na&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;sc&#34;&gt;&amp;#39;b&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;freq(\&amp;#34;na\&amp;#34;, &amp;#39;a&amp;#39;)    = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;na&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;sc&#34;&gt;&amp;#39;a&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;freq(\&amp;#34;na\&amp;#34;)         = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;na&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text3&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;one fish two fish red fish blue fish&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model3&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarkovLM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;freq(\&amp;#34;ish \&amp;#34;, &amp;#39;r&amp;#39;) = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;ish &amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;sc&#34;&gt;&amp;#39;r&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;freq(\&amp;#34;ish \&amp;#34;, &amp;#39;x&amp;#39;) = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;ish &amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;sc&#34;&gt;&amp;#39;x&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;freq(\&amp;#34;ish \&amp;#34;)      = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;ish &amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;freq(\&amp;#34;tuna\&amp;#34;)      = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;model3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;freq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;tuna&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If your method is working properly, you will get the following output:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs MarkovLM
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;freq(&amp;#34;an&amp;#34;, &amp;#39;a&amp;#39;)    = 2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;freq(&amp;#34;na&amp;#34;, &amp;#39;b&amp;#39;)    = 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;freq(&amp;#34;na&amp;#34;, &amp;#39;a&amp;#39;)    = 0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;freq(&amp;#34;na&amp;#34;)         = 2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;freq(&amp;#34;ish &amp;#34;, &amp;#39;r&amp;#39;) = 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;freq(&amp;#34;ish &amp;#34;, &amp;#39;x&amp;#39;) = 0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;freq(&amp;#34;ish &amp;#34;)      = 3
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;freq(&amp;#34;tuna&amp;#34;)      = 0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To test &lt;code&gt;predictNext()&lt;/code&gt;, write a loop that calls &lt;code&gt;predictNext()&lt;/code&gt; repeatedly, and count how many times a particular character is returned. For example, with &lt;code&gt;model1&lt;/code&gt; above, &lt;code&gt;predictNext(&amp;quot;na&amp;quot;)&lt;/code&gt; should return &lt;code&gt;b&lt;/code&gt; about one-half of the time; with &lt;code&gt;model3&lt;/code&gt; above, &lt;code&gt;predictNext(&amp;quot;fish&amp;quot;)&lt;/code&gt; should return &lt;code&gt;o&lt;/code&gt; about one-quarter of the time.&lt;/p&gt;
&lt;p&gt;Of course, you should try to define and test other models.&lt;/p&gt;
&lt;h3 id=&#34;generating-text-using-different-inputs-and-orders&#34;&gt;&lt;strong&gt;Generating Text Using Different Inputs and Orders&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Once you get the program working, test it on different inputs of different sizes and different orders. Does increasing the order have the effect you expect? Try your model on something that you have written or some other text you know well. Make sure to test both long inputs (we provide several) and long outputs.  Here are a couple of examples (click on the ►  icon to expand to expand/collapse):&lt;/p&gt;
&lt;details&gt;
  &lt;summary&gt;Example 1 Input: Speech to the Class of 2018&lt;/summary&gt;
  &lt;p&gt;Good afternoon and welcome to Opening Exercises. What a special pleasure it is to greet Princetons Great Class of 2018! I also offer a warm welcome to our new graduate students, faculty and staff members, and all of you who are returning to campus after the summer.&lt;/p&gt;
&lt;p&gt;Today we carry on a tradition that dates back at least to 1802, when Nassau Hall was the site of an opening exercise for Princeton students. The event switched to other sites before moving in 1929 to the University Chapel, where we gather today. Todays interfaith ceremony is far different from the Christian services that greeted students in 1929, but the chapels soaring architecture and inspirational spaces continue to invite all of us, whatever our religious or ethical traditions might be, to reflect on the larger purposes that should guide our community as we begin another year on this glorious campus.&lt;/p&gt;
&lt;p&gt;Today you join the ranks of students who have left their marks on the Princeton campus and the world for generations through their intellect, creativity and passion. You, the 1,312 members of the Class of 2018, are an extraordinarily accomplished, inspiring and diverse group. You hail from 46 states, as well as the District of Columbia. You come from 50 countries outside of the United States from Chile to the Czech Republic, from Iceland to India, from Nigeria to New Zealand. You grew to become upstanding, compassionate citizens in Happy Valley, Oregon, and Niceville, Florida. You weathered the ups and downs of life in Boiling Springs, Pennsylvania, and Frostburg, Maryland. And you learned to appreciate the lyrical majesty of language in Ho Ho Kus, New Jersey, and Oologah, Oklahoma.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Example 1 output: random Eisgruber, using order 7 model&lt;/em&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs Chat126 7 798 &amp;lt; opening-exercises.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Good afternoon and welcome to a universities around you here.&lt;/p&gt;
&lt;p&gt;I often ask Princeton is a truly global institution. As scholars who matter most to you. And you here.&lt;/p&gt;
&lt;p&gt;I often ask Princeton you have come to our social natures, and, more specifically, with drums and choirs and distinguished teachers, whose contributions will become upstanding.&lt;/p&gt;
&lt;p&gt;This Universitys GREAT CLASS OF 2018! Welcome new members play indispensable roles in helping our Universitys GREAT CLASS OF 2018! I also offer insignificant, or puzzling, or uninteresting, or unsympathetic may turn out to be discourse in all disciplines here as rich with meaningful, not just of any story, can make it easy to feel without knowing exactly what he was destined to appreciate the lyrical majesty of language in Ho Ho Kus, New Jersey, and&lt;/p&gt;

&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;Example 2 Input: As you Like It, Act 2&lt;/summary&gt;
  &lt;p&gt;[Enter DUKE SENIOR, AMIENS, and two or three Lords,
like foresters]&lt;/p&gt;
&lt;p&gt;DUKE SENIOR	Now, my co-mates and brothers in exile,
Hath not old custom made this life more sweet
Than that of painted pomp? Are not these woods
More free from peril than the envious court?
Here feel we but the penalty of Adam,
The seasons&amp;rsquo; difference, as the icy fang
And churlish chiding of the winter&amp;rsquo;s wind,
Which, when it bites and blows upon my body,
Even till I shrink with cold, I smile and say
&amp;lsquo;This is no flattery: these are counsellors
That feelingly persuade me what I am.&amp;rsquo;
Sweet are the uses of adversity,
Which, like the toad, ugly and venomous,
Wears yet a precious jewel in his head;
And this our life exempt from public haunt
Finds tongues in trees, books in the running brooks,
Sermons in stones and good in every thing.
I would not change it.&lt;/p&gt;
&lt;p&gt;AMIENS	Happy is your grace,
That can translate the stubbornness of fortune
Into so quiet and so sweet a style.&lt;/p&gt;
&lt;p&gt;DUKE SENIOR	Come, shall we go and kill us venison?
And yet it irks me the poor dappled fools,
Being native burghers of this desert city,
Should in their own confines with forked heads
Have their round haunches gored.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Example 2 output: random Shakespeare, using order 6 model&lt;/em&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs Chat126 7 1135 &amp;lt; as-you-like-it.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;DUKE SENIOR	Now, my co-mates and thus bolden&amp;rsquo;d, man, how now, monsieur Jaques,
Unclaim&amp;rsquo;d of his absence, as the holly!
Though in the slightest for the fashion of his absence, as the only wear.&lt;/p&gt;
&lt;p&gt;TOUCHSTONE	I care not for meed!
This I must woo yours: your request than your father: the time,
That ever love I broke
my sword upon some kind of men
Then, heigh-ho! sing, heigh-ho! sing, heigh-ho! sing, heigh-ho! unto the needless stream;
&amp;lsquo;Poor deer,&amp;rsquo; quoth he,
&amp;lsquo;Call me not so keen,
Because thou the creeping hours of the sun,
As man&amp;rsquo;s feasts and women merely players:
Thus we may rest ourselves and neglect the cottage, pasture?
Enter DUKE FREDERICK	Can in his time in my heartily,
And have me go with your fortune
In all this fruit
Till than bear
the arm&amp;rsquo;s end: I will through
Cleanse the uses of the way to look you.
Know you not, master,
Sighing like upon a stone another down his bravery is not so with his effigies with my food:
To speak my mind, and inquisition
And unregarded age in corners throat,
He will come hither:
He dies that hath engender&amp;rsquo;d:
And you to
the bed untreasured of the brutish sting it.&lt;/p&gt;

&lt;/details&gt;

&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all required files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Chat126&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;MarkovLM.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Chat126.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Include in your &lt;code&gt;readme.txt&lt;/code&gt; two of the most entertaining language-modeling fragments that you discover.&lt;/p&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Files&lt;/th&gt;
          &lt;th&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;MarkovLM.java&lt;/td&gt;
          &lt;td&gt;26&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Chat126.java&lt;/td&gt;
          &lt;td&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&#34;challenges&#34;&gt;&lt;strong&gt;Challenges&lt;/strong&gt;&lt;/h3&gt;
&lt;h4 id=&#34;challenge-for-the-bored-1&#34;&gt;Challenge for the bored 1.&lt;/h4&gt;
&lt;p&gt;The current assignment only handles ASCII characters.  However, many text collections use Unicode characters, such as those with  diacritic marks (e.g.:  ā ă ą ç é ē î ï ĩ í ĝ ġ ń ñ ö š ŝ ś û ů ŷ Á Ç) and other characters (e.g., 😀 ł đ ħ œ ⺆).&lt;/p&gt;
&lt;p&gt;Extend your solution so that it replaces and/or removes such Unicode characters in your text. Hint - use the API provided in the &lt;code&gt;ToASCII.java&lt;/code&gt; class.  Try your solution on a text that contains Unicode.&lt;/p&gt;
&lt;h4 id=&#34;challenge-for-the-bored-2&#34;&gt;Challenge for the bored 2.&lt;/h4&gt;
&lt;p&gt;Extend your solution to handle Unicode text, not just ASCII.&lt;/p&gt;
&lt;h4 id=&#34;challenge-for-the-bored-3&#34;&gt;Challenge for the bored 3.&lt;/h4&gt;
&lt;p&gt;Imagine you receive a message where some of the characters have been corrupted by noise. We represent unknown characters by the ~ symbol (and assume the character ~ does not appear in the original text). Devise a scheme based on the Markov model to determine the most likely value for each corrupted character. Assume unknown characters are at least \(k\) characters apart (and appear at least \(k\) characters away from the start and end of the message). Test your new method by writing a client program &lt;code&gt;FixCorrupted.java&lt;/code&gt; that takes as arguments the model order and the noisy string. The program prints the most likely original string:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Original:  it was the best of times, it was the worst of times.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Noisy:     it w~s th~ bes~ of tim~s, i~ was ~he wo~st of~times.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs FixCorrupted 4 &amp;#34;it w~s th~ bes~ of tim~s, i~ was ~he wo~st of~times.&amp;#34; &amp;lt; wiki_100k.txt 
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;it was the best of times, it was the worst of times.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;enrichment&#34;&gt;&lt;strong&gt;Enrichment&lt;/strong&gt;&lt;/h3&gt;
&lt;details&gt;
  &lt;summary&gt;Click each item  to expand.&lt;/summary&gt;
  Click again to collapse the answer.
&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;What is the relationship between Markov models and LLMs for generating text?&lt;/summary&gt;
  &lt;ul&gt;
&lt;li&gt;We actually asked ChatGPT this question, and here&amp;rsquo;s its response (slightly edited):&lt;/li&gt;
&lt;li&gt;Markov models and Large Language Models (LLMs) are both used for generating text but operate on different principles.
&lt;ul&gt;
&lt;li&gt;Markov Models: These are based on the Markov property, which states that the future state of a system depends only on its present state, not on the sequence of events that preceded it. In the context of text generation, a Markov model predicts the next word in a sequence based current k-gram.&lt;/li&gt;
&lt;li&gt;Large Language Models (LLMs): These are more sophisticated models based on neural networks, particularly variants like GPT (Generative Pre-trained Transformer) models. LLMs leverage deep learning techniques to capture complex patterns and dependencies in text data. They are trained on large corpora of text and can generate coherent and contextually relevant sequences of text. Unlike Markov models, LLMs do not rely solely on fixed-length context windows but instead learn contextual representations of words and phrases based on their entire input sequence.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;While both Markov models and LLMs can generate text, LLMs generally produce more fluent and contextually appropriate text due to their ability to capture long-range dependencies and contextual nuances. However, Markov models are simpler and more interpretable, making them suitable for certain text generation tasks, especially when computational resources are limited.&lt;/li&gt;
&lt;/ul&gt;

&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;What is the origin of the Markov text generator?&lt;/summary&gt;
  It was first described by Claude Shannon in 1948. The first computer version was apparently written by Don P. Mitchell, adapted by Bruce Ellis, and popularized by A. K. Dewdney in the Computing Recreations section of Scientific American. Brian Kernighan and Rob Pike revived the program in a University setting and described it as an example of design in The Practice of Programming. The program is also described in Jon Bentley&amp;rsquo;s Programming Pearls.
&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;What else can I do with a random text generator?&lt;/summary&gt;
  One former COS 126 student recited its output during the &lt;a href=&#34;https://www.cnn.com/2005/POLITICS/05/10/princeton.filibuster/index.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Frist filibuster&lt;/a&gt;.
&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;Some other interesting topics.&lt;/summary&gt;
  &lt;ul&gt;
&lt;li&gt;We are implementing the model Shannon described in his landmark paper. But the &lt;em&gt;one reads until this letter is encountered&lt;/em&gt; method in his quote on the assignment page is, ironically, not a statistically accurate example of his model. If we run your program with input &lt;code&gt;wawawaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaawy&lt;/code&gt; then &lt;code&gt;w&lt;/code&gt; should be followed by &lt;code&gt;a&lt;/code&gt; 75% of the time, while the &lt;em&gt;read until&lt;/em&gt; model will follow &lt;code&gt;w&lt;/code&gt; with &lt;code&gt;a&lt;/code&gt; only 15% of the time. What would be involved in simulating this other model? Which one do you think gives more realistic text?&lt;/li&gt;
&lt;li&gt;Here&amp;rsquo;s a website that generates &lt;a href=&#34;https://pdos.csail.mit.edu/archive/scigen/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;pseudo-random computer science papers&lt;/a&gt;. It uses something called a &lt;em&gt;context-free grammar&lt;/em&gt; instead of a Markov chain, but otherwise is similar in spirit to what you are doing on this assignment.&lt;/li&gt;
&lt;li&gt;Here are &lt;a href=&#34;http://joshmillard.com/garkov&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Garfield comics&lt;/a&gt; generated by a Markov chain.&lt;/li&gt;
&lt;/ul&gt;

&lt;/details&gt;

&lt;p&gt;&lt;em&gt;Copyright © 2005–2026 Robert Sedgewick and Kevin Wayne, All Rights Reserved&lt;/em&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>8. Image Classifier</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/classifier/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/classifier/</guid>
      <description>&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/classifier.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Classifier&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;!--
### **Goals**

- To learn about object-oriented programming concepts.
- To learn about machine learning (ML).
- To implement the *perceptron algorithm* -  a simple and beautiful example of ML in action.
- To write a client program that classifies images.
--&gt;
&lt;p&gt;&lt;em&gt;In this assignment, you will implement the perceptron algorithm and use it to classify images,
then evaluate its accuracy.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Review the &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/syllabus/#partners&#34;&gt;partnering rules&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Read/scan this entire project description before starting to code.
This will provide a &lt;em&gt;big picture&lt;/em&gt; before diving into the assignment!&lt;/li&gt;
&lt;li&gt;Review the ML lectures and precept exercises.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/classifier.zip&#34;&gt;classifier.zip&lt;/a&gt;
, then open the &lt;code&gt;classifier&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Consult the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#Picture&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Picture&lt;/a&gt; and
&lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#Color&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Color&lt;/a&gt; APIs as needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;context&#34;&gt;&lt;strong&gt;Context&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Classification is a core task in machine learning (ML): given an input (such as an image),
predict which category it belongs to.
For a familiar example of digit classification, try this web app: 
&lt;script src=&#34;https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&#34;&gt;&lt;/script&gt;
        &lt;script type=&#34;text/javascript&#34; src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126//assignments/classifier/demo/mathutils.js&#34;&gt;&lt;/script&gt;
        &lt;script type=&#34;text/javascript&#34; src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126//assignments/classifier/demo/mnist_digit_labels.js&#34;&gt;&lt;/script&gt;
        &lt;script type=&#34;text/javascript&#34; src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126//assignments/classifier/demo/webcnn.js&#34;&gt;&lt;/script&gt;
        &lt;script type=&#34;text/javascript&#34; src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126//assignments/classifier/demo/digitdemo.js&#34;&gt;&lt;/script&gt;
        &lt;link href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126//assignments/classifier/demo/digit.css&#34; rel=&#34;stylesheet&#34;/&gt;

	
&lt;div id=&#34;recognizer&#34;&gt;
    &lt;div class=&#34;inlineDiv&#34;&gt;
        &lt;div id=&#34;drawingCanvasDiv&#34;&gt;&lt;canvas id=&#34;drawCanvas&#34; width=&#34;150&#34; height=&#34;150&#34;&gt;&lt;/canvas&gt;&lt;/div&gt;
        &lt;button class=&#34;silverButton&#34; onclick=&#34;buttonClick(2)&#34; id=&#34;clearButton&#34;&gt;Reset&lt;/button&gt;
    &lt;/div&gt;
&amp;nbsp;
    &lt;div class=&#34;inlineDiv&#34;&gt;
        &lt;div id=&#34;guessNumberDiv&#34;&gt;&lt;/div&gt;
        &lt;div&gt;&lt;span id=&#34;confidence&#34;&gt;&lt;/span&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;





&lt;br&gt;
&lt;br&gt;
&lt;div&gt;
&lt;small&gt;
Derived from https://github.com/DenseInL2/webcnn&lt;/small&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Training and testing.&lt;/strong&gt;
In this assignment, you will implement the &lt;em&gt;perceptron algorithm&lt;/em&gt; for
handwritten digit classification using &lt;em&gt;supervised learning&lt;/em&gt;. Supervised
learning as two phases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Training:&lt;/strong&gt; learn a function that maps inputs to labels from labeled examples.
For digit recognition, the training set contains 60,000 grayscale images (inputs) and
their corresponding digits (labels). Here is a small subset:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/training-subset.png&#34; width=&#34;550&#34; alt=&#34;small training subset&#34;&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Testing:&lt;/strong&gt;  evaluate the learned function by predicting labels for unseen inputs (not used for training).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Binary vs. multiclass classification.&lt;/strong&gt;
In &lt;em&gt;binary classification&lt;/em&gt;, we assign each image to one of two classes
(e.g., &amp;ldquo;6&amp;rdquo; vs. &amp;ldquo;not 6&amp;rdquo;).
By convention, we use labels $+1$ (&lt;em&gt;positive&lt;/em&gt;) and $-1$ (&lt;em&gt;negative&lt;/em&gt;).
In &lt;em&gt;multiclass classification&lt;/em&gt;, we assign each image to one of
$m$ classes, labeled $0, 1, &amp;hellip;, m-1$.
For handwritten digits, $m = 10$ and class $i$ corresponding to digit $i$.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Test error rate.&lt;/strong&gt;
Typically, the algorithm makes some prediction errors (e.g., predicting 9 when the handwritten digit is 6).
An important quality metric is the &lt;em&gt;test error rate&lt;/em&gt;: the fraction of test inputs that are misclassified.
It measures how well the learned classifier generalizes from the training data to new inputs.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/testing-subset.png&#34; width=&#34;450&#34; alt=&#34;small testing subset&#34;&gt;
&lt;p&gt;&lt;strong&gt;Perceptrons&lt;/strong&gt;. A &lt;em&gt;perceptron&lt;/em&gt; is a simplified model of a biological neuron.
It takes an input vector vector $x = x_0, x_1, \ldots, x_{n-1}$ of $n$ real numbers
and outputs a binary label $+1$ or $-1$.
A perceptron is defined by a &lt;em&gt;weight vector&lt;/em&gt; $w = w_0, w_1, \ldots, w_{n-1}$.
It computes the weighted sum&lt;/p&gt;
&lt;p&gt;$$ S = (w_0 \cdot x_0)  + (w_1 \cdot x_1) + \cdots + (w_{n-1} \cdot x_{n-1}) $$&lt;/p&gt;
&lt;p&gt;and outputs $+1$ if the sum is positive, and $-1$ otherwise.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/weighted-sum.png&#34; width=&#34;500&#34; alt=&#34;perceptron computes sign of a weighted sum&#34;&gt;
&lt;p&gt;For the handwritten-digit task, we train a perceptron to output $+1$ for images of a chosen target digit
and $-1$ for all other digits.
The input vector $x$ contains the grayscale values of each pixel in the image,
and the weight vector $w$ is computed during training, as described in the next paragraph.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Perceptron algorithm.&lt;/strong&gt; How do we choose the weight vector $w$ so that the perceptron makes accurate predictions?
The key idea is to use labeled training data to refine the weights incrementally.
Initialize all weights to 0, then process the training examples one at a time.
For each labeled input vector $x$, there are three cases:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Correct prediction&lt;/em&gt;: The perceptron predicts the correct label $+1$ or $-1$.
Leave $w$ unchanged.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;False positive&lt;/em&gt;: The true label is $-1$ but the perceptron predicts $+1$.
Update $w$ by subtracting $x$:
$$ \text{for each } j,  \text{ } w^\prime_j=w_j - x_j $$&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;False negative&lt;/em&gt;: The true label is $+1$ but the perceptron predicts $-1$.
Update $w$ by adding $x$:
$$ \text{for each } j, \text{ } w^\prime_j=w_j + x_j $$&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Intuitively, we push $w$ away from false positives and toward false negatives.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example.&lt;/strong&gt;
Here is an example trace of the perceptron algorithm using four labeled inputs, each of length $n = 3$.
In this example, an input $x$ has a label $+1$ if and only if  $x_0 \le x_1 \le x_2$;
otherwise it has a label $-1$.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/example-labeled-inputs.png&#34; width=&#34;550&#34; alt=&#34;[example trace of the perceptron algorithm using 4 labeled inputs&#34;&gt;
&lt;h3 id=&#34;perceptron-data-type&#34;&gt;&lt;strong&gt;Perceptron Data Type&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Create a data type that represents a perceptron by implementing the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Perceptron&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates a perceptron with n input and all weights initialized to 0.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;Perceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the number of inputs n.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;numberOfInputs&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the weighted sum (dot product) of the weight vector and x. &lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;weightedSum&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Predicts the binary label for the input vector x.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns +1 if the weighted sum is positive; otherwise returns -1.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;predict&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Trains this perceptron on the input vector x with the given&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// binary label (+1 or -1). Updates the weight vector according&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// to the perceptron training rule.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;     &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;train&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;binaryLabel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a string representation of the weight vector, with the&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// individual weights separated by commas and enclosed in parentheses.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Example: (2.0, 1.0, -1.0, 5.0, 3.0)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;toString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Tests this class by directly calling all instance methods.   &lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;    
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;Corner cases.&lt;/em&gt; You may assume that all arguments to the constructor and instance methods are valid.
For example, you may assume that every binary label is either $+1$  or $-1$,
every input vector $x$ has length $n$, and $n \ge 1$.&lt;/p&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;&lt;strong&gt;I&amp;rsquo;m stuck on &lt;code&gt;Perceptron.java&lt;/code&gt;. Can you suggest some steps for making steady, incremental progress?&lt;/strong&gt;&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;These steps are optional. Use them as needed.&lt;/p&gt;
&lt;h4 id=&#34;implementing-perceptronjava&#34;&gt;Implementing &lt;code&gt;Perceptron.java&lt;/code&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;Perceptron()&lt;/code&gt; constructor and the method &lt;code&gt;numberOfInputs()&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Define two instance variables: an integer &lt;code&gt;n&lt;/code&gt; and real-valued array &lt;code&gt;weights[]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Initialize the instance variables.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test:&lt;/strong&gt; In &lt;code&gt;main()&lt;/code&gt;, create a few &lt;code&gt;Perceptron&lt;/code&gt; objects and print the number of inputs for each one.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;toString()&lt;/code&gt; method.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use a loop to concatenate the individual weights.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test:&lt;/strong&gt; In &lt;code&gt;main()&lt;/code&gt;, print the &lt;code&gt;Perceptron&lt;/code&gt; objects you created in Step 1.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;weightedSum()&lt;/code&gt; method.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use a loop to compute the weighted sum.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test:&lt;/strong&gt; In &lt;code&gt;main()&lt;/code&gt;, call &lt;code&gt;weightedSum()&lt;/code&gt; with different arguments and print the results.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;predict()&lt;/code&gt; method by calling &lt;code&gt;weightedSum()&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;train()&lt;/code&gt; method.  The &lt;code&gt;train()&lt;/code&gt; method should call &lt;code&gt;predict()&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test:&lt;/strong&gt; Use the code in the &lt;strong&gt;Testing&lt;/strong&gt; section below to test &lt;code&gt;predict()&lt;/code&gt; and &lt;code&gt;train()&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Submit to &lt;em&gt;TigerFile&lt;/em&gt; for additional testing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;testing-perceptronjava&#34;&gt;Testing &lt;code&gt;Perceptron.java&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The Java code below trains a &lt;code&gt;Perceptron&lt;/code&gt; on four input vectors (each of length three),
following the example in the assignment specification.
After Tests 1–3 pass, implement Tests 4–6.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Create a Perceptron with n inputs.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Perceptron&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;perceptron&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Perceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test 1: Perceptron(%d)\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;(0.0, 0.0, 0.0)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;perceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test 2: numberOfInputs()&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;perceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;numberOfInputs&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// +1 (yes)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// -1 (no)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training3&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// +1 (yes)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training4&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// -1 (no)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test 3a: weightedSum(3.0, 4.0, 5.0)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;perceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;weightedSum&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test 3b: predict(3.0, 4.0, 5.0)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;perceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;predict&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Test 3c: train(3.0, 4.0, 5.0, +1)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;perceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;train&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;(3.0, 4.0, 5.0)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;perceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// TODO: Implement Tests 4–6, following the pattern in Test 3.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Test 4: weightedSum(training2), predict(training2), train(training2, -1)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Test 5: weightedSum(training3), predict(training3), train(training3, +1)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Test 6: weightedSum(training4), predict(training4), train(training4, -1)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Do not&lt;/strong&gt; move onto &lt;code&gt;MultiPerceptron&lt;/code&gt; until &lt;code&gt;Perceptron&lt;/code&gt; is working properly.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;multiclass-classification&#34;&gt;&lt;strong&gt;Multiclass Classification&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;In the previous section, we used a single perceptron for a binary classification task.
For a multiclass problem with $m$ classes, we use an array of $m$ perceptrons,
one per class.
Perceptron $i$ is trained to answer the binary question: &lt;em&gt;is this image the digit $i$&lt;/em&gt;?&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/multiclass-classification.png&#34; width=&#34;550&#34; alt=&#34;[multiclass classification problem&#34;&gt;
&lt;p&gt;We train each perceptron independently and combine their outputs to make a multiclass prediction.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multiclass training.&lt;/strong&gt; Initialize all $m$ perceptrons with weight vectors of $0$.
Then process the labeled training inputs one at a time.
For an input vector $x$ with class label $i$&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Train perceptron $i$ on $x$ with binary label $+1$&lt;/li&gt;
&lt;li&gt;Train each of the other $m-1$ perceptrons on $x$ with binary label $-1$&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In other words, for perceptron $k$, examples of class $k$ are &lt;em&gt;positive&lt;/em&gt;
and all other examples are &lt;em&gt;negative&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multiclass prediction.&lt;/strong&gt;
To classify an input vector $x$, compute the weighted sum for each of the $m$ perceptrons.
Predict the class label of the perceptron with the &lt;em&gt;largest weighted sum&lt;/em&gt;.
We choose exactly one class, even if all weighted sums are negative.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This &lt;em&gt;one-vs-all&lt;/em&gt; strategy decomposes a multiclass classification task into $m$ binary classification
tasks. In computer science, this kind of decomposition is called a &lt;em&gt;reduction&lt;/em&gt;;
reductions like this are used throughout machine learning.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;. Here is an example of a multi-perceptron with $m = 2$ classes and $n = 3$ inputs.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/multiperceptron-m2-n3.png&#34; width=&#34;550&#34; alt=&#34;multi-perceptron with m = 2 classes and n = 3 inputs&#34;&gt;
&lt;h3 id=&#34;multiperceptron-data-type&#34;&gt;&lt;strong&gt;MultiPerceptron Data Type&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Create a data type that represents a multi-perceptron by implementing the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;MultiPerceptron&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates a multi-perceptron with m classes and n inputs.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;MultiPerceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the number of classes m.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;numberOfClasses&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the number of inputs n (length of the feature vector).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;numberOfInputs&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Predicts the class label for input vector x.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;predictMulti&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Trains this multi-perceptron on input vector x&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// with the given class label (between 0 and m-1).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;trainMulti&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;classLabel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns a string representation of this multi-perceptron, with&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// the string representations of the perceptrons separated by commas&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// and enclosed in parentheses.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Example with m = 2 and n = 3: ((2.0, 0.0, -2.0), (3.0, 4.0, 5.0))&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;toString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Tests this class by directly calling all instance methods.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;    
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here are some additional details about the API:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Ties&lt;/em&gt;. If two (or more) perceptrons tie for the largest weighted sum in &lt;code&gt;predictMulti()&lt;/code&gt;,
return the index of one of them.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Corner cases&lt;/em&gt;. You may assume that the arguments to the constructor and instance methods are valid.
For example, you may assume that every class label is an integer between $0$ and $m-1$,
every input vector $x$ has length $n$, and $m \ge 1$ and $n \ge 1$.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;&lt;strong&gt;I&amp;rsquo;m stuck on &lt;code&gt;MultiPerceptron&lt;/code&gt;. Can you suggest some steps for making steady, incremental progress?&lt;/strong&gt;&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;h4 id=&#34;implementing-multiperceptronjava&#34;&gt;Implementing &lt;code&gt;MultiPerceptron.java&lt;/code&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;MultiPerceptron()&lt;/code&gt; constructor and the methods &lt;code&gt;numberOfClasses()&lt;/code&gt; and &lt;code&gt;numberOfInputs()&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Define three instance variables:
&lt;ul&gt;
&lt;li&gt;an integer &lt;code&gt;m&lt;/code&gt; (number of classes)&lt;/li&gt;
&lt;li&gt;an integer &lt;code&gt;n&lt;/code&gt; (length of the input feature vector)&lt;/li&gt;
&lt;li&gt;an array of &lt;code&gt;Perceptron&lt;/code&gt; objects &lt;code&gt;perceptrons[]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Initialize the instance variables.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test:&lt;/strong&gt; In &lt;code&gt;main()&lt;/code&gt;, create a few &lt;code&gt;MultiPerceptron&lt;/code&gt; objects and
print the number of classes and inputs for each object.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;toString()&lt;/code&gt; method.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use a loop to concatenate the &lt;code&gt;Perceptron&lt;/code&gt; objects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test:&lt;/strong&gt; In &lt;code&gt;main()&lt;/code&gt;, print the &lt;code&gt;MultiPerceptron&lt;/code&gt; objects from Step 1.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;predictMulti()&lt;/code&gt; method.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;trainMulti()&lt;/code&gt; method.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test:&lt;/strong&gt; Test &lt;code&gt;predictMulti()&lt;/code&gt; and &lt;code&gt;trainMulti()&lt;/code&gt; with the code in the &lt;em&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/em&gt; section (below).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Submit to &lt;em&gt;TigerFile&lt;/em&gt; for additional testing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;testing-multiperceptronjava&#34;&gt;Testing &lt;code&gt;MultiPerceptron.java&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The Java code below creates a &lt;code&gt;MultiPerceptron&lt;/code&gt; object,
trains the &lt;code&gt;MultiPerceptron&lt;/code&gt; on four input vectors (each of length three)
and then tests the &lt;code&gt;MultiPerceptron&lt;/code&gt; on two input vectors (of length three)
following the examples in the assignment specification.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Create a MultiPerceptron with m classes and n inputs.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MultiPerceptron&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MultiPerceptron&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Constructor Test 1: create a MultiPerceptron and print it.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Constructor Test 1: MultiPerceptron(%d, %d)%n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: ((0.0, 0.0, 0.0), (0.0, 0.0, 0.0))&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Constructor Test 2: check the number of classes.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Constructor Test 2: numberOfClasses()&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;numberOfClasses&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Constructor Test 3: check the number of inputs.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Constructor Test 3: numberOfInputs()&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;numberOfInputs&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Training data.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// class 1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// class 0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training3&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// class 1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training4&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// class 0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Training Test 1 (class 1).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Training Test 1: trainMulti((3, 4, 5), 1)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;trainMulti&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: ((0.0, 0.0, 0.0), (3.0, 4.0, 5.0))&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Training Test 2 (class 0).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Training Test 2: trainMulti((2, 0, -2), 0)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;trainMulti&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: ((2.0, 0.0, -2.0), (3.0, 4.0, 5.0))&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Training Test 3 (class 1).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Training Test 3: trainMulti((-2, 0, 2), 1)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;trainMulti&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: ((2.0, 0.0, -2.0), (3.0, 4.0, 5.0))&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Training Test 4 (class 0).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Training Test 4: trainMulti((5, 4, 3), 0)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;trainMulti&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;training4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: ((2.0, 0.0, -2.0), (-2.0, 0.0, 2.0))&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Testing data.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;testing1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;testing2&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Testing Test 1 (expect class 1).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Testing Test 1: predictMulti((-1, -2, 3))&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: 1&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;predictMulti&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;testing1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Testing Test 2 (expect class 0).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Testing Test 2: predictMulti((2, -5, 1))&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  expect: 0&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;StdOut&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;  result: &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mp1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;predictMulti&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;testing2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;image-classifier-data-type&#34;&gt;&lt;strong&gt;Image Classifier Data Type&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Your final task is to implement &lt;code&gt;ImageClassifier.java&lt;/code&gt;, which uses &lt;code&gt;MultiPerceptron&lt;/code&gt;
to classify images. It must:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Train on the labeled examples in a &lt;em&gt;training data file.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Test on the labeled examples in a &lt;em&gt;testing data file&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Print the misclassified images and the test error rate.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Organize your client according to the following API:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;ImageClassifier&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Creates an ImageClassifier from the given configuration file.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;ImageClassifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;configFile&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the name of the class corresponding to the given class label.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;classNameOf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;classLabel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the feature vector (1D array) extracted from the given picture.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;extractFeatures&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Picture&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;picture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Trains the classifier using the given training data file.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;trainClassifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;trainFile&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Predicts the class label for the given picture.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;classifyImage&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Picture&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;picture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Returns the test error rate on the given testing data file.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Also prints the misclassified examples (see the specification).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;testClassifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;testFile&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Tests this class using a configuration file, training file,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// and testing file.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ImageClassifier&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;classifier&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ImageClassifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;classifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;trainClassifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;testErrorRate&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;classifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;testClassifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;System&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;out&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;test error rate = &amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;testErrorRate&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here are some details about the API:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Configuration file format.&lt;/strong&gt; The configuration file consists of the following lines:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The image &lt;em&gt;width&lt;/em&gt; and &lt;em&gt;height&lt;/em&gt; (in pixels), used by the training and testing data files.&lt;/li&gt;
&lt;li&gt;The number of classes $m$.&lt;/li&gt;
&lt;li&gt;The names of the $m$ classes, one per line.&lt;/li&gt;
&lt;/ol&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/configuration-file.png&#34; width=&#34;250&#34; alt=&#34;configuration file format&#34;&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Training and testing file format.&lt;/strong&gt;
Training and testing data files consists of a sequence of lines. Each line contains:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the name of an image file, and&lt;/li&gt;
&lt;li&gt;an integer class label (between $0$ and $m-1$), separated by whitespace.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/input-file-format.png&#34; width=&#34;500&#34; alt=&#34;input file format&#34;&gt;
&lt;p&gt;For testing data files, you will use the integer labels only to evaluate the accuracy of your predictions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Input files.&lt;/strong&gt;
We provide a variety of datasets in the specified format, including handwritten digits, fashion articles from
Zalando, Hiragana characters, and doodles of fruit, animals, and musical instruments. The handwritten digits and
fashion articles are included in your project folder. You can download the other datasets
&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/datasets.zip&#34;&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;div class=&#34;center-table&#34;&gt;
&lt;div class=&#34;md-table md-table-clean&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Data files&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Description&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Examples&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Source&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;digits.jar&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;em&gt;handwritten digits&lt;/em&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/handwritten-digits.png&#34; width=&#34;150&#34; alt=&#34;handwritten digits&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;a href=&#34;https://www.kaggle.com/datasets/hojjatk/mnist-dataset&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;MNIST&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;fashion.jar&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;em&gt;fashion articles&lt;/em&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/fashion-articles.png&#34; width=&#34;150&#34; alt=&#34;fashion articles&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;a href=&#34;https://github.com/zalandoresearch/fashion-mnist&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Fashion MNIST&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Kuzushiji.jar&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;em&gt;Hirigana characters&lt;/em&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/hirigana-characters.png&#34; width=&#34;150&#34; alt=&#34;Hirigana characters&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;a href=&#34;https://github.com/rois-codh/kmnist&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Kuzushiji MNIST&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;fruit.jar&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;em&gt;fruit doodles&lt;/em&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/fruit-doodles.png&#34; width=&#34;150&#34; alt=&#34;fruit doodles&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;a href=&#34;https://quickdraw.withgoogle.com/data&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Quick, Draw!&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;animals.jar&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;em&gt;animal doodles&lt;/em&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/animal-doodles.png&#34; width=&#34;150&#34; alt=&#34;animal doodles&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;a href=&#34;https://quickdraw.withgoogle.com/data&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Quick, Draw!&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;music.jar&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;em&gt;musical instrument doodles&lt;/em&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/musical-doodles.png&#34; width=&#34;150&#34; alt=&#34;musical instrument doodles&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;a href=&#34;https://quickdraw.withgoogle.com/data&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Quick, Draw!&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Constructor&lt;/strong&gt;.  The &lt;code&gt;ImageClassifier&lt;/code&gt; constructor takes one argument: the name
of a configuration file.
It reads the configuration data and creates a &lt;code&gt;MultiPerceptron&lt;/code&gt; with $m$
classes and $n = width \times height$ inputs.
It also stores the class names from the configuration file.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Feature extraction.&lt;/strong&gt; The &lt;code&gt;extractFeatures()&lt;/code&gt; method converts a grayscale image into
a one-dimensional feature vector for use with &lt;code&gt;MultiPerceptron&lt;/code&gt;. It must:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;iterate over the pixels in &lt;em&gt;row-major order&lt;/em&gt;;&lt;/li&gt;
&lt;li&gt;extract the grayscale value of each pixel (for a shade of gray, the red, green, and
blue components are equal); and&lt;/li&gt;
&lt;li&gt;store the values in a 1D array of length $width$-by-$height$.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It must throw an &lt;code&gt;IllegalArgumentException&lt;/code&gt;
if the image dimensions are not equal to the dimensions specified in the configuration file.&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/grayscale-values-matrix.png&#34; width=&#34;650&#34; alt=&#34;grayscale value matrix&#34;&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Training&lt;/strong&gt;. The &lt;code&gt;trainClassifier()&lt;/code&gt; method takes the name of a training data file and
trains the classifier using the images and labels in that file.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Class name&lt;/strong&gt;.  The &lt;code&gt;classNameOf()&lt;/code&gt; method must throw an &lt;code&gt;IllegalArgumentException&lt;/code&gt;
if its argument is not between $0$ and $m-1$, where $m$ is the number of classes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Classification&lt;/strong&gt;.  The &lt;code&gt;classifyImage()&lt;/code&gt; predicts and returns a class label $i$, where
$$0 \leq i \leq m - 1$.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Testing&lt;/strong&gt;. The &lt;code&gt;testClassifier()&lt;/code&gt; method takes the name of a testing data file
and tests the classifier using the images and labels in that file.
For each misclassified image, it must print:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the image filename,&lt;/li&gt;
&lt;li&gt;the correct class name, and&lt;/li&gt;
&lt;li&gt;the predicted class name.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;in the format shown below:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jar:file:digits.jar!/testing/6/4814.png, label = seven, predict = nine
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jar:file:digits.jar!/testing/6/66.png, label = seven, predict = eight
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jar:file:digits.jar!/testing/5/9982.png, label = six, predict = seven
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jar:file:digits.jar!/testing/7/6561.png, label = eight, predict = ten
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;testClassifier()&lt;/code&gt; method also returns the test error rate (the fraction of test images that are misclassified).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Main.&lt;/strong&gt; The &lt;code&gt;main()&lt;/code&gt; method takes three command-line arguments:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;the name of a configuration data file;.&lt;/li&gt;
&lt;li&gt;the name of training data file;&lt;/li&gt;
&lt;li&gt;The name of testing data file.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It then creates an &lt;code&gt;ImageClassifier&lt;/code&gt;, trains it on the training data, tests it on the testing data,
and prints the test error rate.&lt;/p&gt;
&lt;p&gt;Here is a sample execution:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/classifier&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs ImageClassifier digits.txt digits-training20.txt digits-testing10.txt&lt;/span&gt;
digits/testing/1/46.png, label = one, predict = three
digits/testing/7/36.png, label = seven, predict = two
digits/testing/7/80.png, label = seven, predict = two
digits/testing/1/40.png, label = one, predict = two
digits/testing/1/39.png, label = one, predict = three
digits/testing/7/79.png, label = seven, predict = two
digits/testing/9/20.png, label = nine, predict = two
digits/testing/9/58.png, label = nine, predict = four
test error rate = 0.8
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;&lt;strong&gt;I&amp;rsquo;m stuck on &lt;code&gt;ImageClassifier&lt;/code&gt;. Can you suggest some steps for making steady, incremental progress?&lt;/strong&gt;&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;These steps are optional. Use them as needed.&lt;/p&gt;
&lt;h4 id=&#34;constructor-and-instance-variables&#34;&gt;Constructor and Instance Variables&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;ImageClassifier()&lt;/code&gt; constructor.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Read the configuration file data, and store the configuration data in your instance variables.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Review the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#In&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;In&lt;/code&gt;&lt;/a&gt; data type from Section 3.1,
which is an object-oriented version of &lt;code&gt;StdIn&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Define these instance variables:
&lt;ul&gt;
&lt;li&gt;an integer&lt;code&gt;width&lt;/code&gt; (picture width)&lt;/li&gt;
&lt;li&gt;an integer &lt;code&gt;height&lt;/code&gt;(picture height)&lt;/li&gt;
&lt;li&gt;an array of strings &lt;code&gt;classNames[]&lt;/code&gt; (the $m$ class names)&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;MultiPerceptron&lt;/code&gt; with $m$ classes and $n = width \times height$ inputs&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Print the instances variables to standard output.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test:&lt;/strong&gt; In &lt;code&gt;main()&lt;/code&gt;, create various &lt;code&gt;ImageClassifier&lt;/code&gt; objects using different configuration files
(&lt;code&gt;image3x3.txt&lt;/code&gt;, &lt;code&gt;digits.txt&lt;/code&gt;, &lt;code&gt;fashion.txt&lt;/code&gt;, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement &lt;code&gt;classNameOf()&lt;/code&gt;. For the given class label, return the class name associated with it.
&lt;strong&gt;Test:&lt;/strong&gt;  call ``classNameOf()` with different arguments and print the results.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Printing is solely for checking progress;
remove the print statements once you have confidence your constructor is working properly.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;feature-extraction&#34;&gt;Feature Extraction&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Review Section 3.1 of the textbook,
especially Program 3.1.4 (&lt;a href=&#34;https://introcs.cs.princeton.edu/31datatype/Grayscale.java.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;code&gt;Grayscale.java&lt;/code&gt;&lt;/a&gt;)
for using the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#Picture&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Picture&lt;/a&gt; and
&lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/#Color&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Color&lt;/a&gt; data types.
Note that the images are already grayscale, so you &lt;em&gt;don’t&lt;/em&gt; need to use &lt;code&gt;Luminance.java&lt;/code&gt;.
In particular, the red, green, and blue components are equal, so you can use any of
&lt;code&gt;getRed()&lt;/code&gt;, &lt;code&gt;getGreen()&lt;/code&gt;, or &lt;code&gt;getBlue()&lt;/code&gt; to get the grayscale value.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Comment out the test client code provided in &lt;code&gt;ImageClassifier.main()&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a &lt;code&gt;Picture&lt;/code&gt; object for the image &lt;code&gt;49785.png&lt;/code&gt; (in the project folder) and display it in a window.
(Remove this code after you have successfully displayed the image.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a &lt;code&gt;Picture&lt;/code&gt; object for the image &lt;code&gt;image3x3.png&lt;/code&gt; (in the project folder)
corresponding to the 3-by-3 example given below.
















&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/grayscale-values-matrix.png&#34; alt=&#34;Grayscale Values Matrix&#34; loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Extract its width and height and print the values to standard output.&lt;/li&gt;
&lt;li&gt;Extract the grayscale values of the pixels and print.
If it’s not already in row-major order, adjust your code so that it prints the values in the specified order.&lt;/li&gt;
&lt;li&gt;If you are using IntelliJ, do not type the &lt;code&gt;import java.awt.Color;&lt;/code&gt; statement that
is normally needed to access Java’s &lt;code&gt;Color&lt;/code&gt; data type.
IntelliJ is pre-configured to automatically add &lt;code&gt;import&lt;/code&gt; statements when needed (and remove them when not needed).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a one-dimensional array of length &lt;em&gt;width x height&lt;/em&gt; and copy the grayscale values to the array.
Print the values of this array to confirm you can create a vector (row-major order) of values from a &lt;code&gt;Picture&lt;/code&gt; object.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Using the code from steps (4) and (5) as a guide, implement the method &lt;code&gt;extractFeatures()&lt;/code&gt; that takes a &lt;code&gt;Picture&lt;/code&gt; as
an argument and returns the grayscale values as a &lt;code&gt;double[]&lt;/code&gt; in &lt;em&gt;row-major order&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write a &lt;code&gt;main()&lt;/code&gt; method that tests &lt;code&gt;extractFeatures()&lt;/code&gt;. Using &lt;code&gt;image3-by-3.png&lt;/code&gt;, your &lt;code&gt;main()&lt;/code&gt; method should print the
values returned by &lt;code&gt;extractFeatures()&lt;/code&gt; as shown in the above figure:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ImageClassifier test = new ImageClassifier(&amp;#34;image3x3.txt&amp;#34;); // create a small test
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Picture image3x3 = new Picture(&amp;#34;image3x3.png&amp;#34;);             
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;double[] values = test.extractFeatures(image3x3);
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;// print the array values
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you are confident that &lt;code&gt;extractFeatures()&lt;/code&gt; works, remove your testing code before submitting the assignment to
&lt;em&gt;TigerFile&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;classifying-images&#34;&gt;Classifying Images&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;classifyImage()&lt;/code&gt; method. For the given image, extract its features
and use the multi-perceptron to predict its class label.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;trainClassifier()&lt;/code&gt; method. Read the training file data just as you read the configuration file. For
each training image, extract its corresponding features and train the classifier using the corresponding label.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement the &lt;code&gt;testClassifier()&lt;/code&gt; method. Read the testing file data just as you read the configuration file. For each
testing image, predict its class. Print each misclassified image to standard output and compute the error rate on these
images.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;training-and-testing-using-large-datasets&#34;&gt;&lt;strong&gt;Training and Testing using Large Datasets&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Now for the fun part. Try the large training and testing files.
Processing 60,000 images may take noticeable time.&lt;/p&gt;
&lt;p&gt;Now, the fun part. Use large training and testing input files. Be prepared to wait for one (1) minute (or more) while your program
processes 60,000 images.&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/classifier&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs ImageClassifier digits.txt digits-training60K.txt digits-testing10K.txt&lt;/span&gt;
jar:file:digits.jar!/testing/6/4814.png, label = six, predict = zero
jar:file:digits.jar!/testing/5/4915.png, label = five, predict = eight
jar:file:digits.jar!/testing/6/2754.png, label = six, predict = zero
...
jar:file:digits.jar!/testing/4/1751.png, label = four, predict = three
jar:file:digits.jar!/testing/3/9614.png, label = three, predict = five
jar:file:digits.jar!/testing/5/6043.png, label = five, predict = three
test error rate = 0.1318
&lt;/pre&gt;

&lt;p&gt;Don’t worry about the odd-looking filenames. They specify the location of an image stored inside a JAR file (Java Archive).
Storing the images in a JAR is more efficient than working with hundreds of thousands of separate files.&lt;/p&gt;
&lt;p&gt;For example, in &lt;code&gt;jar:file:digits.jar!/training/7/4545.png&lt;/code&gt;, &lt;code&gt;digits.jar&lt;/code&gt; is the JAR file,
and &lt;code&gt;/training/7/4545.png&lt;/code&gt; is the path to the image within that JAR.&lt;/p&gt;
&lt;p&gt;Try experimenting with the other datasets:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/classifier&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs ImageClassifier fashion.txt fashion-training60K.txt fashion-testing10K.txt&lt;/span&gt;
...

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/classifier&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs ImageClassifier Kuzushiji.txt Kuzushiji-training60K.txt Kuzushiji-testing10K.txt&lt;/span&gt;
...

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/classifier&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs ImageClassifier music.txt  music-training50K.txt music-testing10K.txt&lt;/span&gt;
...

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/classifier&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs ImageClassifier fruit.txt fruit-training30K.txt fruit-testing6K.txt&lt;/span&gt;
...

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/classifier&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs ImageClassifier animals.txt animals-training60K.txt animals-testing12K.txt&lt;/span&gt;
...
&lt;/pre&gt;

&lt;h3 id=&#34;analysis&#34;&gt;Analysis&lt;/h3&gt;
&lt;p&gt;Answer Parts 1, 2 and 3 in &lt;code&gt;readme.txt&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Part 1&lt;/strong&gt;:  Run the following experiment (you may want to redirect standard output to a file):&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/classifier&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs ImageClassifier digits.txt digits-training60K.txt digits-testing1K.txt&lt;/span&gt;
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Which digit is misclassified the most frequently?&lt;/li&gt;
&lt;li&gt;For that digit, what are the two most common incorrect predictions
(i.e., which two digits does your classifier confuse it with most often)?&lt;/li&gt;
&lt;li&gt;Inspect several of these misclassified images. Explain what visual features might be causing the misclassifications.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Part 2.&lt;/strong&gt; Use experiments to answer the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;What is the error rate on &lt;code&gt;digits-testing1K.txt&lt;/code&gt; &lt;strong&gt;before training&lt;/strong&gt;?
To measure this, run your program without training (e.g., temporarily comment out the call to &lt;code&gt;trainClassifier()&lt;/code&gt; in &lt;code&gt;main()&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;What is the error rate on &lt;code&gt;digits-testing1K.txt&lt;/code&gt; &lt;strong&gt;after training&lt;/strong&gt;?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Based on these results, can you conclude that the classifier is learning? Explain briefly.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Part 3.&lt;/strong&gt;
People write the digit 7 in different ways.
For example, some writers (common in parts of Europe and Latin America)
draw a 7 with a horizontal bar through the middle,
while others (common in Japan and Korea) draw a 7 with a slanted or &amp;ldquo;crooked&amp;rdquo; top stroke.&lt;/p&gt;
   &lt;div class=&#34;center-table&#34;&gt;
   &lt;div class=&#34;md-table md-table-clean&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Our data set&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;7 with a middle bar&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;7 with a crooked top&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/7.png&#34; width=&#34;50&#34; alt=&#34;American 7&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/7withdash.png&#34; width=&#34;50&#34; alt=&#34;Europe and Latin America 7&#34;&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/7withhang.png&#34; width=&#34;50&#34; alt=&#34;Asian 7&#34;&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

   &lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Suppose the training data contains no examples of either convention.
How do you expect the classifier to perform on test data from populations that commonly use these styles?
What are possible consequences?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now consider a supervised learning system for diagnosing cancer.
Suppose the training data contains examples only from population X,
but you deploy the system on population Y. What are possible consequences?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Submit all files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Classifier&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Perceptron.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;MultiPerceptron.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ImageClassifier.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Files&lt;/th&gt;
          &lt;th&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;Perceptron.java&lt;/td&gt;
          &lt;td&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;MultiPerceptron.java&lt;/td&gt;
          &lt;td&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Classifier.java&lt;/td&gt;
          &lt;td&gt;12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&#34;enrichment-faq&#34;&gt;&lt;strong&gt;Enrichment FAQ&lt;/strong&gt;&lt;/h3&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;When was the perceptron algorithm first discovered?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It was proposed in 1958 by Frank Rosenblatt, an
American psychologist. It is one of the earliest machine-learning algorithms. At the time, researchers were overly
optimistic about its short-term potential and grossly underestimated the formidable challenge of building intelligent
machines.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is the significance of the perceptron algorithm?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;It is a really simple, beautiful algorithm that, nevertheless, can do something interesting.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The perceptron algorithm is one of the most fundamental algorithms in an area of ML called online learning (learning from samples one at a time).&lt;/li&gt;
&lt;li&gt;The perceptron algorithm is closely related to the support-vector machine algorithm, another fundamental ML algorithm.&lt;/li&gt;
&lt;li&gt;The perceptron algorithm has some beautiful theoretical properties. For example, if the training data set is linearly separable (i.e., there exists some weight vector that correctly classifies all of the training examples), and if we cycle through the training data repeatedly, the perceptron algorithm will eventually (and provably) find such a weight vector.&lt;/li&gt;
&lt;li&gt;Perceptrons are a building block in neural networks. In neural networks, many perceptrons (or other artificial neurons) are connected in a network architecture, in which the outputs of some neurons are used as the inputs to other neurons. Training multi-layer neural networks requires a more sophisticated algorithm to adjust the weights, such as gradient descent and backpropagation.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Does the perceptron algorithm produce a different weight vector depending on the order in which it processes the training examples?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. We&amp;rsquo;ve randomized the training data. It would be a bad idea, for example, to process all of the handwritten 0s
before all of the handwritten 6s.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Any intuition for why the perceptron algorithm works?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Geometrically, you can view each input vector $x$ as a &lt;em&gt;point&lt;/em&gt; in $R^n$
and the weight vector $w$ as a &lt;em&gt;hyperplane&lt;/em&gt; through the origin.
The goal of the perceptron algorithm is to find a hyperplane that separates the positive examples from the negative
examples. Using vector terminology, the weighted sum is known as the &lt;em&gt;dot product&lt;/em&gt;; its sign determines on which side
of the hyperplane the point lies.&lt;/p&gt;
&lt;p&gt;















&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/dot-product.png&#34; alt=&#34;Dot product&#34; loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;During training, when we encounter a point $x$ that is on the wrong side of the hyperplane (i.e., a false positive or
negative), we update the weight vector, thereby rotating the hyperplane slightly. After the rotation, x is either on
the correct side of the hyperplane or, if not, at least a bit closer to the hyperplane (in terms of Euclidean
distance).&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How can I improve accuracy of the perceptron algorithm?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Here are three simple ideas:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Multiclass perceptron&lt;/em&gt;. Instead of training all &lt;code&gt;m&lt;/code&gt; perceptrons on each input vector, when there is a prediction error (multiclass perceptron predicts $i$ but correct label is $k$, train only two perceptrons: train perceptron $i$ (with label $-1$) and perceptron $k$ (with label $+1$).&lt;/li&gt;
&lt;li&gt;Adjust the weights with a fraction of $+1$ or $-1$ for correct or incorrect predictions (this helps with a smoother convergence) and iterate over the training step multiple times, each time training the perceptron with the same set of training data (randomized in order).&lt;/li&gt;
&lt;li&gt;Normalize the features array data to have values between 0 and 1 (divide the values with 255) and initialize the perceptron weights to random values (with uniform random or Gaussian random to be less than 1 and on average 0).&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Averaged perceptron&lt;/em&gt;. Instead of using the last weight vector, take the average of the weight vectors that are computed along the way.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Incorporate more features&lt;/em&gt;. Instead of using the feature vector $x_0, x_1,\ldots, x_{n-1}$, create additional features. In particular, for each pair of features $x_i$ and $x_k$, create a new feature  $x_{ik} = x_i * x_k$. You could also keep going, adding not just pairs of features, but also triples, etc. This can significantly improve accuracy, but it becomes prohibitively expensive in terms of computation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See this &lt;a href=&#34;http://rob.schapire.net/papers/FreundSc98.pdf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;paper&lt;/a&gt; for additional ideas, including the kernel trick and the voted-perceptron algorithm.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I noticed that the weights are always integral throughout the perceptron algorithm. Why is this?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Adding or subtracting an integer to an integer yields an integer. The weights are always adjusted by either adding or subtracting the input vector; for the image classification problems we consider in this assignment, the input vector elements are integers between 0 and 255 (grayscale values).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;As a perceptron is trained with more and more data, the weights increase in absolute value. Is this to be expected?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. This implies that the algorithm makes smaller and smaller relative changes to the weights as it learns from more and more input–output pairs.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Why not use the testing data for training?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;We seek a model that can make good predictions for unseen input–output pairs. If we use the testing data when training, the algorithm could “memorize” the input–output pairs. While this might achieve higher accuracy on those inputs, the results may not generalize to unseen inputs.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is the difference between supervised and unsupervised learning?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;In supervised learning, the algorithm has access to training data for which we know the correct labels. These labels act as a teacher supervising the learning process. In unsupervised learning, the training data is unlabeled, so there are no correct answers; instead, the goal may be to cluster similar inputs together.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How can I make it recognize my own handwritten digits?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use the same technique, but you must be careful to size-normalize and center the images, as is done in the &lt;a href=&#34;https://en.wikipedia.org/wiki/MNIST_database&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;MNIST training data&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can ML algorithms be trained to classify alphabetic and mathematical symbols?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Here are web apps that let you draw and find the most similar &lt;a href=&#34;https://shapecatcher.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Unicode characters&lt;/a&gt; or &lt;a href=&#34;https://detexify.kirelabs.org/classify.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;LaTeX symbols&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Any games based on classifying hand-drawn images?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Try &lt;a href=&#34;https://quickdraw.withgoogle.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Quick, Draw!&lt;/a&gt;, which uses neural networks and the world’s largest doodling data set.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is the best performing algorithm for classifying handwritten digits using the MNIST dataset?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;The current champion uses convolution neural networks and achieves a 99.79% accuracy rate on the MNIST testing database consisting of 10,000 images. Here are the 21 incorrect predictions:&lt;/p&gt;
&lt;p&gt;















&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/classifier/images/incorrect.png&#34; alt=&#34;Incorrect Predictions&#34; loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;There is not much room for improvement; indeed, some of the errors appear to be due to incorrectly labeled (or ambiguous) inputs.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;This assignment was developed by Sebastian Caldas, Robert DeLuca, Ruth Fong, Maia Ginsburg,
Alan Kaplan, Kevin Jeon, and Kevin Wayne.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Copyright © 2005–2026&lt;/em&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>9. Hamming Codes in TOY</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hamming/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hamming/</guid>
      <description>&lt;!--&lt;p style=&#34;color:red;&#34;&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt;  This assignment has not been officially released yet and is subject to change!&lt;/p&gt;

 --&gt;
&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hamming/hamming.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Hamming&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this assignment, you will write TOY programs to encode and decode messages using Hamming codes.
You will learn about machine-language programming and error-correcting codes.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Read Chapter 6 of the textbook and review the corresponding lectures and precepts.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hamming/hamming.zip&#34;&gt;hamming.zip&lt;/a&gt;
, then open the &lt;code&gt;hamming&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Review &lt;code&gt;HammingEncoder.java&lt;/code&gt; and &lt;code&gt;HammingDecoder.java&lt;/code&gt; in the project folder;
they illustrate the encoding and decoding procedures in Java.&lt;/li&gt;
&lt;li&gt;Refer to the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/62toy/cheatsheet.txt&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;TOY reference card&lt;/a&gt;, as needed.&lt;/li&gt;
&lt;li&gt;Follow these &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/syllabus/#partners&#34;&gt;partnering rules&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;background&#34;&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Error-correcting codes&lt;/em&gt; enable reliable communication over noisy channels.
The sender appends redundant information so the receiver can recover the original message
even if some bits are corrupted during transmission.
Errors can arise from static on a cell phone or atmospheric interference.
In noisy settings, error-correcting codes can increase throughput by reducing (or eliminating) retransmissions.
They are used in many systems, including memory storage systems (e.g., DRAM and SSDs),
mobile and wireless communications, and digital television.&lt;/p&gt;
&lt;p&gt;A &lt;em&gt;Hamming code&lt;/em&gt; is an error-correcting code that detects and corrects single-bit errors.
It is used in settings where such errors are common, including DRAM chips and satellite communications.
A Hamming code takes four message bits and adds three parity bits to form a 7-bit codeword.
If at most one of these seven bits is corrupted, the receiver can detect the error and recover the original four
message bits.
This single-bit error correction increases bandwidth by 75% (three extra parity bits for every four message bits).
By comparison, sending three copies of each bit and taking the majority value increases bandwidth by 200%.&lt;/p&gt;
&lt;h3 id=&#34;approach&#34;&gt;&lt;strong&gt;Approach&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Before describing the algebra of Hamming codes, we first visualize how the parity bits
are computed using Venn diagrams.
As an example, suppose we want to send the 4-bit message &lt;code&gt;1101&lt;/code&gt;.
Label the message bits $m_1, m_2, m_3, m_4$, as in the diagram below:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hamming/images/venn.png&#34; width=&#34;450&#34; alt=&#34;Venn diagram&#34;&gt;
&lt;p&gt;Then add three parity bits $p_1, p_2, p_3$ so that each circle has &lt;em&gt;even parity&lt;/em&gt;:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hamming/images/even.png&#34; width=&#34;450&#34; alt=&#34;Venn diagram: even parity&#34;&gt;
&lt;p&gt;That is, the sum of the four bits inside each circle is even:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hamming/images/sum4-even.png&#34; width=&#34;650&#34; alt=&#34;Venn diagram: even parity sum 4&#34;&gt;
&lt;p&gt;In this example, the parity bits are &lt;code&gt;1&lt;/code&gt; (top), &lt;code&gt;0&lt;/code&gt; (left), and &lt;code&gt;0&lt;/code&gt; (right).
So, instead of sending &lt;code&gt;1101&lt;/code&gt;, we send the 7-bit codeword &lt;code&gt;1101100&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now suppose one bit is corrupted during transmission, so the receiver gets the codeword &lt;code&gt;1001100&lt;/code&gt;:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hamming/images/noisy.png&#34; width=&#34;350&#34; alt=&#34;Venn diagram: noisy&#34;&gt;
&lt;p&gt;The receiver detects an error by checking the parity of the three circles.
Moreover, the pattern of failed parity checks pinpoints which bit flipped,
so the receiver can correct the error and recover the original four message bits:&lt;/p&gt;
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hamming/images/recover.png&#34; width=&#34;650&#34; alt=&#34;Venn diagram: recovery&#34;&gt;
&lt;p&gt;Here, the parity checks for the &lt;em&gt;top&lt;/em&gt; and &lt;em&gt;right&lt;/em&gt; circles fail, while the &lt;em&gt;left&lt;/em&gt; circle passes.
The only bit that lies in exactly those two circles is $m_2$,
so the receiver flips $m_2$ to obtain &lt;code&gt;1101100&lt;/code&gt;.
This corresponds to message bits &lt;code&gt;1101&lt;/code&gt; plus parity bits &lt;code&gt;100&lt;/code&gt;, as intended.&lt;/p&gt;
&lt;p&gt;The pattern of failed parity checks identifies which bit (if any) was flipped:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If no bit is corrupted, then all three parity checks pass.&lt;/li&gt;
&lt;li&gt;If one of $m_1$, $m_2$, or $m_3$ is corrupted, then exactly two checks fail.&lt;/li&gt;
&lt;li&gt;If $m_4$ is corrupted, then all three checks fail.&lt;/li&gt;
&lt;li&gt;If one of $p_1$, $p_2$, $p_3$, or $p_4$ is corrupted, then exactly one check fails (the check for that circle).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This scheme corrects only single-bit errors;
more sophisticated error-correcting codes handle multiple-bit errors.&lt;/p&gt;
&lt;h3 id=&#34;hamming-encoder&#34;&gt;Hamming Encoder&lt;/h3&gt;
&lt;p&gt;Write a TOY program &lt;code&gt;encode.toy&lt;/code&gt; that encodes a binary message using the scheme described above.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Repeatedly read four bits $m_1, m_2, m_3, m_4$ from TOY standard input.&lt;/li&gt;
&lt;li&gt;Compute the parity bits:
&lt;ul&gt;
&lt;li&gt;$p_1 = m_1 \oplus m_2 \oplus m_4$&lt;/li&gt;
&lt;li&gt;$p_2 = m_1 \oplus m_3 \oplus m_4$&lt;/li&gt;
&lt;li&gt;$p_3 = m_2 \oplus m_3 \oplus m_4$&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Write the seven bits $m_1, m_2, m_3, m_4, p_1, p_2, p_3$ to TOY standard output.&lt;/li&gt;
&lt;li&gt;Stop when you read &lt;code&gt;FFFF&lt;/code&gt;, then output &lt;code&gt;FFFF&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is the meaning of the $\oplus$ operator?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It is the standard symbol in math and CS for &lt;em&gt;exclusive or&lt;/em&gt; (xor),
which is useful for comptuting parity.
Xor takes two input bits and outputs 1 they are different and 0 if they are the same.
Equivalently, it outputs 1 if the sum of the bits is odd,
and 0 if is even.
In Java and TOY, it corresponds to the &lt;code&gt;^&lt;/code&gt; operator.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;hamming-decoder&#34;&gt;Hamming Decoder&lt;/h3&gt;
&lt;p&gt;Write a TOY program &lt;code&gt;decode.toy&lt;/code&gt; that decodes (and corrects) a Hamming-encoded message.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Repeatedly read seven bits $m_1, m_2, m_3, m_4, p_1, p_2, p_3$ from standard input.&lt;/li&gt;
&lt;li&gt;Recomptue the parity bits from the message bits:
&lt;ul&gt;
&lt;li&gt;$q_1 = m_1 \oplus m_2 \oplus m_4$&lt;/li&gt;
&lt;li&gt;$q_2 = m_1 \oplus m_3 \oplus m_4$&lt;/li&gt;
&lt;li&gt;$q_3 = m_2 \oplus m_3 \oplus m_4$&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Compare  $q_1, q_2, q_3$ with the received parity bits $p_1, p_2, p_3$.&lt;/li&gt;
&lt;li&gt;If necessary, flip the corrupted message bit, then write  $m_1, m_2, m_3, m_4$ to standard output.&lt;/li&gt;
&lt;li&gt;Stop when you read &lt;code&gt;FFFF&lt;/code&gt;, then output &lt;code&gt;FFFF&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To determine which message bit (if any) is corrupted, use the result of the three parity checks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If zero or one check fails, then all four message bits are correct.&lt;/li&gt;
&lt;li&gt;If checks 1 and 2 fail (but not check 3), then $m_1$ is incorrect.&lt;/li&gt;
&lt;li&gt;If checks 1 and 3 fail (but not check 2), then $m_2$ is incorrect.&lt;/li&gt;
&lt;li&gt;If checks 2 and 3 fail (but not check 1), then $m_3$ is incorrect.&lt;/li&gt;
&lt;li&gt;If all three checks fail, then $m_4$ is incorrect.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;input-format&#34;&gt;Input Format&lt;/h3&gt;
&lt;p&gt;The input to &lt;code&gt;encode.toy&lt;/code&gt; is a text file containing the bits to transmit.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Each line contains four bits, $m_1, m_2, m_3, m_4$.&lt;/li&gt;
&lt;li&gt;Each bit is written as a 4-digit hexadecimal integer: &lt;code&gt;0000&lt;/code&gt; (0) or &lt;code&gt;0001&lt;/code&gt; (1), separated by whitespace.&lt;/li&gt;
&lt;li&gt;The final line is the single integer &lt;code&gt;FFFF&lt;/code&gt;, which marks the end of the file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The file &lt;code&gt;encode3.txt&lt;/code&gt; contains three 4-bit messages:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hamming&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;more encode3.txt&lt;/span&gt;
0001 0001 0000 0001
0001 0001 0001 0000
0001 0001 0001 0001
FFFF
&lt;/pre&gt;

&lt;p&gt;The corresponding 4-bit messages are &lt;code&gt;1101&lt;/code&gt;, &lt;code&gt;1110&lt;/code&gt;, and &lt;code&gt;1111&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The input format for &lt;code&gt;decode.toy&lt;/code&gt; is similar,
except that each line contains seven bits (a 7-bit codeword), again written as
&lt;code&gt;0000&lt;/code&gt; or &lt;code&gt;0001&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hamming&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;more decode4.txt&lt;/span&gt;
0001 0001 0000 0001 0001 0000 0000
0001 0000 0000 0001 0001 0000 0000
0001 0001 0000 0000 0001 0000 0000
0001 0001 0000 0001 0001 0000 0001
FFFF
&lt;/pre&gt;

&lt;p&gt;The corresponding 7-bit codewords are &lt;code&gt;1101100&lt;/code&gt;, &lt;code&gt;1001100&lt;/code&gt;, &lt;code&gt;1100100&lt;/code&gt;, and &lt;code&gt;1101101&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;formatting-and-commenting-requirements&#34;&gt;Formatting and Commenting Requirements&lt;/h3&gt;
&lt;p&gt;To make your TOY code readable and easy to debug, follow these formatting and commenting guidelines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Each TOY instruction must have corresponding pseudocode.
(If you use &lt;em&gt;Visual X-Toy&lt;/em&gt;, the pseudocode is generated automatically.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add blank lines between logically related sections of TOY code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write a comment above each section explaining what that code does.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the third column for your own comments.
&lt;em&gt;Hint:&lt;/em&gt; use the Java code from &lt;code&gt;HammingEncoder.java&lt;/code&gt; and &lt;code&gt;HammingDecoder.java&lt;/code&gt; as a starting point for your comments.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;faq&#34;&gt;FAQ&lt;/h3&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I assume the input files are in the prescribed format?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. The input files will contain &lt;strong&gt;only&lt;/strong&gt; a sequence of &lt;code&gt;0000&lt;/code&gt;&amp;rsquo;s and &lt;code&gt;0001&lt;/code&gt;&amp;rsquo;s,
followed by &lt;code&gt;FFFF&lt;/code&gt;. If there are no bits to be decoded, the file contains only the single
integer &lt;code&gt;FFFF&lt;/code&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How to use the Visual X-TOY Simulator?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Use the &lt;a href=&#34;https://lift.cs.princeton.edu/xtoy/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Visual X-TOY simulator&lt;/a&gt;
by executing the following command in the IntelliJ terminal:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hamming&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java -jar toy.jar&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;The Visual X-TOY simulator provides lots of useful development features. There are two major modes: &lt;em&gt;edit&lt;/em&gt; and &lt;em&gt;debug&lt;/em&gt;.
Use &lt;em&gt;Mode &amp;gt; Edit Mode&lt;/em&gt; to edit &lt;code&gt;.toy&lt;/code&gt; programs and &lt;em&gt;Mode &amp;gt; Debug Mode&lt;/em&gt; to debug or run &lt;code&gt;.toy&lt;/code&gt; programs. In Debug Mode,
use the &lt;em&gt;Reference&lt;/em&gt;, &lt;em&gt;Stdin&lt;/em&gt;, &lt;em&gt;Stdout&lt;/em&gt; and &lt;em&gt;Core&lt;/em&gt; tabs on the right to help debug your program.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To &lt;strong&gt;open&lt;/strong&gt; a TOY program from a file, use &lt;em&gt;Select File &amp;gt; Open&lt;/em&gt;, then browse to find the program, e.g.,
&lt;code&gt;multiply.toy&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To &lt;strong&gt;edit&lt;/strong&gt; a TOY program, use &lt;em&gt;Select Mode &amp;gt; Edit Mode&lt;/em&gt;. You can type your program directly in the edit window. Use &lt;code&gt;multiply.toy&lt;/code&gt; as a reference for formatting and commenting.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To &lt;strong&gt;redirect&lt;/strong&gt; standard input from a file, in Edit Mode, select &lt;em&gt;Mode &amp;gt; Load File to Stdin&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To &lt;strong&gt;execute&lt;/strong&gt; a TOY program, use &lt;em&gt;Select Mode &amp;gt; Debug Mode&lt;/em&gt;. Then click the &lt;em&gt;Run&lt;/em&gt; button at the bottom. You can enter data on standard input by typing the value in the &lt;em&gt;Stdin&lt;/em&gt; tab and clicking the &lt;em&gt;Add&lt;/em&gt; button. You will have to click the &lt;em&gt;Run&lt;/em&gt; button to resume execution. You can see the results on standard output in the &lt;em&gt;Stdout&lt;/em&gt; tab.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What are common TOY programming issues?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;ul&gt;
&lt;li&gt;The program counter starts at &lt;code&gt;10&lt;/code&gt; so make sure that you place your code starting at memory address &lt;code&gt;10&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Be sure that each line follows the required format &lt;code&gt;XX: XXXX&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Check for duplicated line numbers or out-of-order line numbers.&lt;/li&gt;
&lt;li&gt;Check for using a letter like &lt;code&gt;O&lt;/code&gt; or &lt;code&gt;I&lt;/code&gt; instead of the number &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Remember that all values, memory addresses, and arithmetic are in hex. For example, memory address &lt;code&gt;1A&lt;/code&gt; follows &lt;code&gt;19&lt;/code&gt;. If you don&amp;rsquo;t specify the value for a memory address, that memory address will have the default value of &lt;code&gt;0000&lt;/code&gt;, which is a &lt;code&gt;HALT&lt;/code&gt; instruction.&lt;/li&gt;
&lt;li&gt;Watch out for jump statements — if you insert a new line of code between existing lines, you will have to renumber all the following lines. Also, be sure to update any jump statements that have hardwired line numbers.&lt;/li&gt;
&lt;li&gt;Be very careful to update both your comments and your actual code at the same time! It is very common to update only the pseudocode and not the machine instruction.&lt;/li&gt;
&lt;li&gt;All registers are global variables. One way to be sure that a register is not used for two different purposes is to fill in the question in the &lt;code&gt;readme.txt&lt;/code&gt; about registers before or during debugging.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I&amp;rsquo;m stuck. How do I make progress?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;These are purely suggestions for how you might make progress.
You do not have to follow these steps. If you get stumped
or frustrated on some portion of the assignment, you should not hesitate to consult a preceptor.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the Visual X-Toy Simulator and experiment with some of the example programs.
&lt;ol&gt;
&lt;li&gt;Try the sample programs &lt;em&gt;Add&lt;/em&gt;, &lt;em&gt;Echo&lt;/em&gt;, and &lt;em&gt;Sum&lt;/em&gt; by going to &lt;em&gt;File &amp;gt; Open Example Programs&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Open and experiment with &lt;code&gt;multiply.toy&lt;/code&gt;, which is included in the project folder.&lt;/li&gt;
&lt;li&gt;Try executing some of the programs from precept.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Read, compile, and run the reference solutions &lt;code&gt;HammingEncoder.java&lt;/code&gt; and &lt;code&gt;HammingDecoder.java&lt;/code&gt;. Use these reference solutions as a &lt;em&gt;design&lt;/em&gt; for your TOY programs.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;readme.txt&lt;/code&gt; provides tables to help your design/implementation/debugging of &lt;code&gt;encode.toy&lt;/code&gt; and &lt;code&gt;decode.toy.&lt;/code&gt;  This will help you think about how you plan to use and/or re-use the Toy registers as you implement these Toy programs.  Before you start coding, complete these tables, and update as needed.  They  will be very helpful for you as well as those helping you during office hours and/or Lab TA debugging sessions.&lt;/li&gt;
&lt;li&gt;As you write your TOY programs, remember:
&lt;ul&gt;
&lt;li&gt;The first column contains the TOY instruction &lt;em&gt;&lt;strong&gt;in hex&lt;/strong&gt;&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;The second column contains the TOY pseudo-code.&lt;/li&gt;
&lt;li&gt;The third column is used for your own comments. &lt;em&gt;Write comments as you write your code. This will help you understand your design as well as help during office hours, grading, etc.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;In X-Toy, create a new file (&lt;em&gt;File &amp;gt; New&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;Save the file (&lt;em&gt;File &amp;gt; Save&lt;/em&gt;) as &lt;code&gt;encode.toy&lt;/code&gt; in your Hamming assignment project folder.&lt;/li&gt;
&lt;li&gt;Incrementally implement and test &lt;code&gt;encode.toy&lt;/code&gt;, using &lt;code&gt;HammingEncoder.java&lt;/code&gt; as a guide. Remember that as you revise your program, you will need to edit your TOY statement numbers accordingly.
&lt;ul&gt;
&lt;li&gt;Write TOY code that reads a number from standard input. If the number is negative, the program shall halt. (Note, the only valid negative input is &lt;code&gt;FFFF&lt;/code&gt;.) Otherwise, it prints the number and inputs the next number.&lt;/li&gt;
&lt;li&gt;Edit your TOY program from step (a) so that it now reads in sequences of four numbers, halting if the first number is negative. Otherwise, it writes the four numbers and inputs the next sequence of numbers.&lt;/li&gt;
&lt;li&gt;Edit your TOY program from step (b) so that it now computes the parity bits, and writes the parity bits.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Incrementally implement and test &lt;code&gt;decode.toy&lt;/code&gt;, using &lt;code&gt;HammingDecoder.java&lt;/code&gt; as a guide.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I test my TOY programs?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;We provide several input files for both &lt;code&gt;encode.toy&lt;/code&gt; and &lt;code&gt;decode.toy&lt;/code&gt;,
along with the corresopnding answer files.
For convenience, each answer file shows the input and an abbreviated version of the output.
corresponding outputs.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Encoding&lt;/em&gt;&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;input file&lt;/th&gt;
          &lt;th&gt;output file&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;encode0.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;encode0-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;encode1.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;encode1-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;encode3.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;encode3-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;encode16.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;encode16-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;em&gt;Decoding&lt;/em&gt;&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;input file&lt;/th&gt;
          &lt;th&gt;output file&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;decode0.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;decode0-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;decode1.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;decode1-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;decode3.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;decode3-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;decode4.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;decode4-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;decode6.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;decode6-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;decode16.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;decode16-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;decode128.txt&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;&lt;code&gt;decode128-answer.txt&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;To test your TOY program with the command-line &lt;code&gt;TOY.java&lt;/code&gt; simulator,
type the commands below in the IntelliJ  terrminal.
You should see one &lt;em&gt;bit&lt;/em&gt; (a TOY hex word) per line:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hamming&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs TOY encode.toy &amp;lt; encode3.txt&lt;/span&gt;
0001
0001
0000
0001
0001
0000
0000
0001
0001
0001
0000
0000
0000
0000
0001
0001
0001
0001
0001
0001
0001
FFFF

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/hamming&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs TOY decode.toy &amp;lt; decode4.txt&lt;/span&gt;
0001
0001
0000
0001
0001
0001
0000
0001
0001
0001
0000
0001
0001
0001
0000
0001
FFFF
&lt;/pre&gt;
&lt;p&gt;You can then compare your output with the corresponding answer file.&lt;/p&gt;
&lt;p&gt;The most thorough test is to encode and decode &lt;em&gt;all&lt;/em&gt; possible inputs.
The input files &lt;code&gt;encode16.txt&lt;/code&gt; and &lt;code&gt;decode128.txt&lt;/code&gt; do exactly that.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all required files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Hamming&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;encode.toy&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;decode.toy&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Be sure to answer all questions in &lt;code&gt;readme.txt&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Files&lt;/th&gt;
          &lt;th&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;encode.toy&lt;/td&gt;
          &lt;td&gt;16&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;decode.toy&lt;/td&gt;
          &lt;td&gt;22&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;readme.txt&lt;/td&gt;
          &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td&gt;40&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&#34;leaderboard-optional&#34;&gt;&lt;strong&gt;Leaderboard (optional)&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Submit an &lt;em&gt;optimized&lt;/em&gt; &lt;code&gt;decode.toy&lt;/code&gt; to the Hamming Leaderboard for class fame and glory.
You may work alone or with your partner.
Your goal is to use the fewest &lt;em&gt;nonzero&lt;/em&gt; words of TOY main memory.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Under 40 (decimal) is very good.&lt;/li&gt;
&lt;li&gt;Under 35 is great.&lt;/li&gt;
&lt;li&gt;The all-time record is 27.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To submit to the leaderboard and see results:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Upload &lt;code&gt;nickname.txt&lt;/code&gt; containing your group name. Please keep it respectful.&lt;/li&gt;
&lt;li&gt;Upload &lt;code&gt;leaderboard.txt&lt;/code&gt;, describing your approach.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Hamming_Leaderboard&#34;&gt;Submit to Leaderboard&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/leaderboard/hamming.html&#34;&gt;View Current Leaderboard&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Copyright © 1999–2026, &lt;a href=&#34;https://www.cs.princeton.edu/~rs&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Robert Sedgewick&lt;/a&gt; and &lt;a href=&#34;https://www.cs.princeton.edu/~wayne&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Kevin Wayne&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>People</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/people/</link>
      <pubDate>Mon, 19 Jan 2026 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/people/</guid>
      <description></description>
    </item>
    
    <item>
      <title>Contact</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/contact/</link>
      <pubDate>Mon, 24 Oct 2022 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/contact/</guid>
      <description></description>
    </item>
    
    <item>
      <title>COS 126 Programming Assignments FAQ</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/guidelines/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/guidelines/</guid>
      <description>&lt;p&gt;&lt;em&gt;This page answers common questions about coding, testing, and submitting COS 126 assignments. If you do not find an answer here, ask on Ed or attend office hours.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Click a question to reveal the answer.&lt;/p&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;Getting started&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Which Java programming environment (IDE) should I use for COS 126?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;We strongly recommend our custom version of &lt;em&gt;IntelliJ&lt;/em&gt;. It is the only IDE we support.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I already have &lt;em&gt;IntelliJ&lt;/em&gt;. Do I still need to install the COS 126 version?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Install (or update to) the COS 126 version, which we refresh every summer.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I unzip the assignment ZIP file?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;ul&gt;
&lt;li&gt;macOS: Double-click the &lt;code&gt;.zip&lt;/code&gt; file in &lt;em&gt;Finder&lt;/em&gt; to extract it (if it wasn&amp;rsquo;t automatically extracted when you downloaded it).&lt;/li&gt;
&lt;li&gt;Windows: Right-click the ZIP file and choose &lt;em&gt;Extract All…&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I open an assignment project in IntelliJ?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Download the assignment ZIP file, unzip it, then  open the &lt;strong&gt;project folder&lt;/strong&gt; in &lt;em&gt;IntelliJ&lt;/em&gt;.
Do not open a file or subfolder inside the project folder.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Where should I store assignment projects?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Create one folder for all COS 126 assignments, and keep each assignment in its own subfolder.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Store projects on a local disk (not a network drive, cloud-synced folder, or SMB share).&lt;/li&gt;
&lt;li&gt;On macOS, if you store projects in &lt;em&gt;Desktop&lt;/em&gt;, &lt;em&gt;Documents&lt;/em&gt;, or &lt;em&gt;Downloads&lt;/em&gt;,
you may need to grant &lt;em&gt;IntelliJ&lt;/em&gt; and &lt;em&gt;Terminal&lt;/em&gt; file access
via &lt;em&gt;System Settings → Privacy &amp;amp; Security → Files and Folders&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is in the assignment project folder?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It typically includes data files and course configuration files.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I create a new Java class in IntelliJ?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Select &lt;em&gt;LIFT → New Java Class&lt;/em&gt; from the menu.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I create a new IntelliJ project?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;IntelliJ projects can be tricky to configure.
We recommend using only the provided project folders (one for each assignment and precept).
To create a new project, download any provided folder, rename it, and delete
any unneeded files.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;course-policies&#34;&gt;Course policies&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What Java features are allowed on assignments?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use only Java features that have been covered in lecture, precept, or the assigned readings for this point in the course. If you are unsure whether something is in scope, ask on &lt;em&gt;Ed&lt;/em&gt; before using it.
For reference, the &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Java Programming Cheatsheet&lt;/a&gt;
lists the Java features we use during the semester.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I copy or adapt code from the course materials?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. You may copy or adapt code from course materials, including the textbook, lecture slides, precepts, and assignment specifications.
If you copy substantial code, include a brief comment citing the source.
Do not copy solutions or code from outside course materials.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I use generative AI tools in programming assignments?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. You may not use generative AI for any part of a programming assignment,
including writing code, debugging, explaining errors, generating comments,
summarizing, or reformatting).
These assignments are designed to help you build your own ability to reason about code.
Submitting AI-generated work defeats that purpose and violates the course collaboration policy.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Should I include my name and NetID in every file I submit?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. We grade anonymously. Do not put any personally identifiable
information in &lt;code&gt;.java&lt;/code&gt; files or &lt;code&gt;readme.txt&lt;/code&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;style-and-readability&#34;&gt;Style and readability&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How should I format my code?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;ul&gt;
&lt;li&gt;Use 4 spaces per indentation level.&lt;/li&gt;
&lt;li&gt;Keep lines to 87 characters or fewer in &lt;code&gt;.java&lt;/code&gt;, &lt;code&gt;readme.txt&lt;/code&gt;, and &lt;code&gt;acknowledgments.txt&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Use whitespace for readability: blank lines between logical sections and spaces around operators.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How should I write clear code?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;ul&gt;
&lt;li&gt;Use meaningful variable names (for example, &lt;code&gt;isOrdered&lt;/code&gt;, not &lt;code&gt;o&lt;/code&gt; or &lt;code&gt;ordered&lt;/code&gt;). Loop indices like &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt; are fine.&lt;/li&gt;
&lt;li&gt;Prefer simple conditionals: write &lt;code&gt;if (isBlue) { ... }&lt;/code&gt;, not &lt;code&gt;if (isBlue == true) {...}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Match the require types: if an input is specified as an integer, store it in an &lt;code&gt;int&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Match the required control flow: if the specification requires a &lt;code&gt;while&lt;/code&gt; loop, use a &lt;code&gt;while&lt;/code&gt; loop.&lt;/li&gt;
&lt;li&gt;Match the output format exactly, including punctuation, spacing, and number of lines. Remove debugging prints before submitting.&lt;/li&gt;
&lt;li&gt;Avoid &lt;em&gt;magic numbers&lt;/em&gt;. Give important constants a named variable (e.g., &lt;code&gt;int DAYS_PER_WEEK = 7&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Minimize scope: declare variables in the smallest block where they are used.&lt;/li&gt;
&lt;li&gt;In OOP assignments, use instance variables only when they represent per-object state. Make all instance variables &lt;code&gt;private&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How should I comment my code?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;ul&gt;
&lt;li&gt;Add a brief comment above each logical section of code.&lt;/li&gt;
&lt;li&gt;Comment every method, documenting its purpose, inputs, and outputs.&lt;/li&gt;
&lt;li&gt;Comment any local variable whose purpose is not obvious from its name.&lt;/li&gt;
&lt;li&gt;In OOP assignments, comment every instance variable.&lt;/li&gt;
&lt;li&gt;Write comments as you code so your intent stays clear.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Is there another useful resource on writing clear programs?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Our &lt;a href=&#34;https://introcs.cs.princeton.edu/java/11style&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;style guide&lt;/a&gt; is a useful additional resource. Some guidelines may not make sense yet, but they will as the semester unfolds.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;required-text-files&#34;&gt;Required text files&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How should I edit &lt;code&gt;readme.txt&lt;/code&gt; and &lt;code&gt;acknowledgments.txt&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use &lt;em&gt;IntelliJ&lt;/em&gt; (recommended). Save them as plain text files.
Do not change their names or file extensions.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is a &lt;code&gt;readme.txt&lt;/code&gt; file?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It is a short narrative description of your work.
Use the provided template and answer every question.
Do not include your name, NetID, or email address in &lt;code&gt;readme.txt&lt;/code&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is an &lt;code&gt;acknowledgments.txt&lt;/code&gt; file?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It lists who helped you (with dates) and includes the required academic integrity
statement with your digital signature.
We grade an assignment only after &lt;code&gt;acknowledgments.txt&lt;/code&gt; has been submitted.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;assignment-submissions&#34;&gt;Assignment submissions&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I submit an assignment?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Submit assignments on &lt;em&gt;TigerFile&lt;/em&gt;. Each assignment has its own submission link.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I log in to &lt;em&gt;TigerFile&lt;/em&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Log in with your OIT NetID and password.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I cannot log in to &lt;em&gt;TigerFile&lt;/em&gt;. What should I do?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;To access &lt;em&gt;TigerFile&lt;/em&gt;, you must be officially enrolled in the course.
Make sure you are using the submission link for the current semester.
If you still cannot log in, post on Ed.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I submit via &lt;em&gt;Canvas&lt;/em&gt; or email instead of &lt;em&gt;TigerFile&lt;/em&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. All programming assignments must be submitted via &lt;em&gt;TigerFile&lt;/em&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I correctly submit an assignment?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;ul&gt;
&lt;li&gt;Remove debugging output.&lt;/li&gt;
&lt;li&gt;Upload all required files (your latest versions).&lt;/li&gt;
&lt;li&gt;Match the required output format exactly (spelling, spacing, punctuation, and number of lines).&lt;/li&gt;
&lt;li&gt;After testing locally, click &lt;code&gt;Check Submitted Files&lt;/code&gt; and fix any reported issues.&lt;/li&gt;
&lt;li&gt;When you are ready for grading, upload &lt;code&gt;acknowledgments.txt&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I resubmit after uploading?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Absolutely. You may resubmit as often as you like before the deadline.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I fix &lt;em&gt;Filename is not in list&lt;/em&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Your filename must match the required name exactly, including capitalization and the &lt;code&gt;.java&lt;/code&gt; extension. For example, &lt;code&gt;HelloWorld.java&lt;/code&gt; is not the same as &lt;code&gt;helloworld.java&lt;/code&gt;. We recommend enabling “show file extensions” in your operating system settings (&lt;a href=&#34;https://support.apple.com/guide/mac-help/show-or-hide-filename-extensions-on-mac-mchlp2304/mac&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Mac&lt;/a&gt; and &lt;a href=&#34;https://www.thewindowsclub.com/show-file-extensions-in-windows&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Windows&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;late-submissions&#34;&gt;Late submissions&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I submit an assignment after the deadline?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Submit as usual in &lt;em&gt;TigerFile&lt;/em&gt;. Upload &lt;code&gt;acknowledgments.txt&lt;/code&gt; only when you are ready for your work to be graded.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I use late days for an assignment?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;They are applied automatically.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;partnered-submissions&#34;&gt;Partnered submissions&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;On assignments that allow partners, how do we upload files?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Create a &lt;em&gt;TigerFile&lt;/em&gt; group for the assignment and add your partner. Either partner may upload files.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I am working alone, but &lt;em&gt;TigerFile&lt;/em&gt; requires a group to submit. What should I do?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Create a group with one member (just you).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can either partner upload files?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;check-submitted-files&#34;&gt;Check Submitted Files&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What does &lt;em&gt;Check Submitted Files&lt;/em&gt; do?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It compiles your code and runs automated checks against the assignment specification. These include correctness tests and, on some assignments, performance and memory checks. It also runs static analysis (&lt;em&gt;SpotBugs&lt;/em&gt; and &lt;em&gt;Checkstyle&lt;/em&gt;) to flag likely bugs and style issues.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Where is the &lt;em&gt;Check Submitted Files&lt;/em&gt; button?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;In &lt;em&gt;TigerFile&lt;/em&gt;, open the assignment submission page. The &lt;em&gt;Check Submitted Files&lt;/em&gt; button appears below your uploaded files.
&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/hello/images/tigerfile-check-submitted-files.png&#34; width=&#34;300&#34; alt=&#34;Check Submitted Files button in TigerFile&#34;&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How many checks do I get per assignment?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;You may run &lt;em&gt;Check Submitted Files&lt;/em&gt; up to &lt;strong&gt;20 times&lt;/strong&gt; per assignment. For partnered assignments, this limit applies to the group.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Do I need to upload all required files to get feedback?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. The autograder checks whichever files you submit, as long as they compile.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What do compiler errors or warnings mean?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Your code did not compile cleanly. Fix all compiler errors and resolve all warnings before your final submission. If you are stuck, ask on Ed or bring the error message to office hours or Lab TA hours.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What do &lt;em&gt;SpotBugs&lt;/em&gt; and &lt;em&gt;Checkstyle&lt;/em&gt; warnings mean?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://spotbugs.github.io&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;SpotBugs&lt;/a&gt;: likely bug patterns (occasionally false positives)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://checkstyle.sourceforge.net&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Checkstyle&lt;/a&gt;: formatting and style rules, including course-specific checks.
Treat warnings seriously and fix them when possible.
If you do not understand a message, ask on Ed or bring it to office hours or Lab TA hours.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What does a &lt;em&gt;FAILED&lt;/em&gt; message mean in the autograder output?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Your program does not meet the specification on the tested inputs. A &lt;em&gt;FAILED&lt;/em&gt; result will likely reduce your score. Passing all tests is a good sign, but it does not guarantee full credit because we run additional tests when grading.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What causes &lt;em&gt;Process took too long and was killed&lt;/em&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;The autograder did not finish within the time limit. Common causes are an infinite loop or printing far more output than the specification requires (often due to leftover debugging output).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I fix &lt;em&gt;failed to fetch NetworkError&lt;/em&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;This typically indicates a network problem. Confirm you are online and reload the page.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;testing-input-and-debugging&#34;&gt;Testing, input, and debugging&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Does my program need to handle every possible input?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. Your program must handle all inputs in the domain specified by the assignment. For example, when grading &lt;code&gt;RGBtoCMYK.java&lt;/code&gt;, we will always provide three integers between 0 and 255.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Do I have to test my code?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. Some assignments provide a test client; others require you to write one. At minimum, your test client should exercise every public method at least once with meaningful inputs and print the results. For thorough testing, try additional edge cases beyond the minimum.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Should my program use command-line arguments, standard input, or file input?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Follow the assignment specification.
If it requires command-line arguments, read &lt;code&gt;args[]&lt;/code&gt;.
If it requires standard input, read from standard input.
If it requires file input, read from a file.
Using the wrong input method will not match our tests.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;!--
### Java Programming


&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How can I download a program from the textbook?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;The &lt;a href=&#34;https://introcs.cs.princeton.edu&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;booksite&lt;/a&gt; links to each program.
You can download the &lt;code&gt;.java&lt;/code&gt; file by opening the program page and saving the source link
(for example, right-click &lt;code&gt;UseArgument.java&lt;/code&gt;).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

--&gt;
&lt;h3 id=&#34;grading-and-feedback&#34;&gt;Grading and feedback&lt;/h3&gt;
&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Does &lt;em&gt;Check Submitted Files&lt;/em&gt; determine my grade?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. &lt;em&gt;Check Submitted Files&lt;/em&gt; provides automated feedback.
Course staff assign the final grade, and we may run additional tests when grading.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Where can I view grading feedback?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;View grading feedback in &lt;a href=&#34;https://www.gradescope.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Gradescope&lt;/a&gt;.
We will email sign-up instructions after Assignment 0 is graded.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How are deductions computed?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;There are three components (1) The total number of tests passed / total number of tests. (2) .4 points deducted for each warning message. (3)
3.0 points deducted for each error message.   However, we sometimes deduct points manually for certain violations.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How do I know if my files have been successfully submitted?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;You know your file has been successfully uploaded to TigerFile when the gray bar beneath the file name turns green and shows the label &amp;ldquo;Uploaded&amp;rdquo; in the middle. There will also be a file size shown immediately to the right of the file name and a timestamp at the far right of the row.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Is coding style important?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Adhering to coding style conventions is important because it makes code easier to read, understand, and maintain. You should fix all Checkstyle errors and warnings, such as line length, comments, and variable names, and ask for help (office hours, Lab TAs, Ed) if you’re unsure how to resolve them.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;May I use coding patterns or Java features that have not yet been taught in COS 126?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. You are expected to use only the programming concepts, coding patterns, and Java language features that have been covered in  COS 126 up to that point of the assignment. Assignments are designed to assess your understanding of the material that has been taught. You should use only the programming techniques and language features covered in the course or introduced specifically for the assignment. Using more advanced techniques or features, even if they produce the correct output, is not permitted and may result in a deduction of points.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;If my program passes all the test cases and has no warnings or error messages, does that guarantee a score of 100%, or are there additional grading criteria that could affect my grade?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It does not guarantee a score of 100%.  On some assignments, we may not provide all the test cases to the autograder due to resource constraints. Examples of such test cases involve memory and timing tests.  In addition, we reserve the right to grade manually when we believe our automated test cases are not robust enough.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;I believe my assignment was graded incorrectly. How do I request a regrade?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;If you think there is an error in your feedback, please submit a regrade request via GradeScope within three days of release of your graded work.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can the same bug produce multiple warning/error messages?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes, absolutely.  You should fix all reported errors and warnings. Ask for help (office hours, Lab TAs, Ed) if you’re unsure how to resolve them.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa faq&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Will all the test cases always be provided?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Most of the time, yes. However, due to the load on our server, we often will not provide memory and timing tests.  We also retain the right to add additional tests if needed.   That said, passing all the published test cases without any errors/warnings generally means you understood how to develop a solution to the assignment specification.  Read all feedback carefully and ask questions if you need clarifications.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

</description>
    </item>
    
    <item>
      <title>Exam Archive</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/exams/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/exams/</guid>
      <description>&lt;!--A good way to prepare for an exam is to solve old exam questions. Here are some old COS 126 midterms and final exams. (We have included only exams that were administered in-class, as the format and policies for online exams was somewhat different.) --&gt;
&lt;!--
**Fall 2025 Programming Exam: Do not access the programming exam download/submit links (below) until instructed to do so.&lt;br&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/Programming_Exam/Programming_Exam.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Programming_Exam&#34;&gt;Submit to TigerFile&lt;/a&gt;
**  
--&gt;
&lt;h4 id=&#34;programming-exams-on-tigerfile&#34;&gt;Programming Exams on TigerFile.&lt;/h4&gt;
&lt;p&gt;Here are a few programming exams that are  hosted on TigerFile.  This will give you practice with downloading the exam/project folder from TigerFile in the same manner that you will do on real programming exam.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_S2026/DNA&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Fall 2025 Programming Exam&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_S2026/Lap_Timer&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Fall 2024 Programming Exam&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_S2026/Tiger_Wallet&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Spring 2024 Programming Exam&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;style&gt;
.exam-table-spacious td,
.exam-table-spacious th { padding-top: 1.1rem; padding-bottom: 1.1rem; }

/* light separators between body rows (not the header) */
.exam-table-spacious tbody tr + tr td {
  border-top: 0.75px solid rgba(0,0,0,0.1);
}
/* bold first column (body only) */
.exam-table-spacious tbody td:first-child {
  font-weight: 600;
}
&lt;/style&gt;
&lt;h4 id=&#34;some-past-exams-and-solutions&#34;&gt;Some Past Exams and Solutions&lt;/h4&gt;
&lt;p&gt;Note - some older exams include topics we no longer cover. You are responsible only for this semester’s lectures, precepts, and programming assignments.&lt;/p&gt;
&lt;div class=&#34;exam-table-spacious&#34;&gt;
&lt;div class=&#34;md-table md-table-clean&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Semester&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Written Exam 1&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Programming Exam&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Written Exam 2/Final Exam&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;Spring&lt;br&gt;2026&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s26-we1/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s26-we1/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s26-pe/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s26-pe/s26-pe.zip&#34;&gt;Project&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s26-pe/solution.zip&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s26-we2/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s26-we2/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;Fall&lt;br&gt;2025&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f25-we1/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f25-we1/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f25-pe/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f25-pe/f25-pe.zip&#34;&gt;Project&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f25-pe/solution.zip&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f25-we2/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f25-we2/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;Spring&lt;br&gt;2025&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s25-we1/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s25-we1/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s25-pe/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s25-pe/s25-pe.zip&#34;&gt;Project&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s25-pe/solution.zip&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s25-we2/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s25-we2/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;Fall&lt;br&gt;2024&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f24-we1/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f24-we1/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f24-pe/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f24-pe/f24-pe.zip&#34;&gt;Project&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f24-pe/solution.zip&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f24-we2/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f24-we2/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;Spring&lt;br&gt;2024&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s24-we1/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s24-we1/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s24-pe/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s24-pe/s24-pe.zip&#34;&gt;Project&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s24-pe/solution.zip&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s24-we2/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/s24-we2/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;Fall&lt;br&gt;2023&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f23-we1/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f23-we1/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f23-pe2/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f23-pe2/f23-pe2.zip&#34;&gt;Project&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f23-pe2/solution.zip&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f23-we2/exam.pdf&#34;&gt;Exam&lt;/a&gt; &lt;br&gt; &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/exams/f23-we2/solution.pdf&#34;&gt;Solution&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;
 
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Help</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/help/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/help/</guid>
      <description>&lt;!-- 
*COS 126 is a challenging course.* Below you will find some of the various ways you can get help in COS 126. If you are falling behind, be proactive. Contact your preceptor as soon as possible and schedule a meeting with them. In the meeting, review the material and make a plan for success in this course. If you don&#39;t feel comfortable talking to your preceptor, contact the course instructors as soon as possible to arrange to get some help. We will be happy to meet with you.   
--&gt;
&lt;p&gt;&lt;em&gt;COS 126 is a challenging course,&lt;/em&gt; and getting help early makes a big difference. If you’re falling behind, be proactive: start by contacting your preceptor. If you’d rather not start there, contact the course instructors. We will be happy to meet with you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Course Discussion Forum.&lt;/strong&gt; Use &lt;a href=&#34;https://edstem.org/us/courses/99455/discussion&#34;&gt;&lt;em&gt;Ed Discussion&lt;/em&gt;&lt;/a&gt; for quick questions. Staff monitor Ed regularly. Please do not post your assignment code on Ed, even in private posts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Office Hours.&lt;/strong&gt; For more substantial questions, come to office hours. You may attend any staff member&amp;rsquo;s office hours; see the calendar below. Office hours are appropriate for help with assignments, course concepts, or broader CS questions. Please review the relevant lecture and attempt the corresponding precept exercises &lt;em&gt;before&lt;/em&gt; coming to office hours.&lt;/p&gt;


&lt;div class=&#34;responsive-wrap&#34;&gt;
  &lt;iframe src=&#34;https://calendar.google.com/calendar/embed?src=c_lnskd7q3lhjqm6d5jd0c60p13k%40group.calendar.google.com&amp;amp;ctz=America%2FNew_York&amp;amp;mode=WEEK&#34; frameborder=&#34;0&#34; width=&#34;960&#34; height=&#34;569&#34; allowfullscreen=&#34;true&#34; mozallowfullscreen=&#34;true&#34; webkitallowfullscreen=&#34;true&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;
&lt;p&gt;&lt;strong&gt;Intro COS Lab.&lt;/strong&gt; The &lt;a href=&#34;https://introlab.cs.princeton.edu&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Intro COS Lab&lt;/a&gt;, located in &lt;a href=&#34;https://maps.app.goo.gl/ZgTskwsUMfyP9aQr6&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Computer Science Building 105&lt;/a&gt;
is staffed by undergraduate TAs and can help you debug your code. Before coming, make a reasonable effort to identify the bug and isolate the problem. Please also attend the relevant lecture and attempt the corresponding precept exercises first.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tutoring and additional academic support.&lt;/strong&gt;
The &lt;a href=&#34;https://mcgraw.princeton.edu/undergraduates&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;McGraw Center for Teaching &amp;amp; Learning&lt;/a&gt; offers additional academic support, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://mcgraw.princeton.edu/undergraduates/programs/tutoring&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Peer Tutoring&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://mcgraw.princeton.edu/undergraduates/programs/allc&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Learning Consultations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://mcgraw.princeton.edu/undergraduates/group-and-individual-tutoring/study-groups-and-jumpstarts&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Student-Led Study Groups&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Not Available</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/notavailable/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/notavailable/</guid>
      <description>&lt;p&gt;The content you want to access is not available yet.  If you believe this is an error, please post on Ed.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Resources</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/resources/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/resources/</guid>
      <description>&lt;p&gt;&lt;strong&gt;Course communications.&lt;/strong&gt; We use &lt;a href=&#34;https://edstem.org/us/courses/99455/discussion&#34;&gt;&lt;em&gt;Ed Discussion&lt;/em&gt;&lt;/a&gt; for course communications,
including announcements and questions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Programming environment.&lt;/strong&gt; We use a customized version of &lt;em&gt;IntelliJ&lt;/em&gt;, which provides a complete Java programming environment. Install it on your computer by following the instructions for your operating system: &lt;a href=&#34;https://lift.cs.princeton.edu/java/mac&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Mac OS X&lt;/a&gt;, &lt;a href=&#34;https://lift.cs.princeton.edu/java/windows/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Windows&lt;/a&gt;, or &lt;a href=&#34;https://lift.cs.princeton.edu/java/linux/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Linux&lt;/a&gt;. For troubleshooting, go to the &lt;a href=&#34;https://introlab.cs.princeton.edu&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Intro COS Lab&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Textbook.&lt;/strong&gt;
The course textbook is &lt;em&gt;Computer Science: An Interdisciplinary Approach&lt;/em&gt;, by Robert Sedgewick and Kevin Wayne. Addison–Wesley Professional, 2016.
ISBN 978-0134076423.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can purchase it through Princeton&amp;rsquo;s &lt;a href=&#34;https://princeton.ecampus.com/shop-by-course&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;eCampus bookstore&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The textbook is on reserve at the &lt;a href=&#34;https://catalog.princeton.edu/catalog/9999429913506421&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Engineering Library&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The companion &lt;em&gt;&lt;a href=&#34;https://introcs.cs.princeton.edu/java/home&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;booksite&lt;/a&gt;&lt;/em&gt; includes the book’s code and solutions to selected exercises.&lt;/li&gt;
&lt;li&gt;Use the textbook to learn new material and to review for exams. Use the booksite while you are online.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Lecture participation.&lt;/strong&gt;
We use &lt;em&gt;&lt;a href=&#34;https://www.iclicker.com/students/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;iClicker&lt;/a&gt;&lt;/em&gt; to make lectures more interactive.
To earn participation credit, you must attend lecture and respond to iClicker polls.
You must also register your mobile/web app:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If needed, create an &lt;a href=&#34;https://student.iclicker.com/#/account/create&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;iClicker account&lt;/a&gt;.
&lt;ul&gt;
&lt;li&gt;Select &lt;em&gt;Princeton University&lt;/em&gt; as the institution.&lt;/li&gt;
&lt;li&gt;Use your name, Princeton email address (as listed on &lt;a href=&#34;https://princeton.instructure.com/courses/22541&#34;&gt;Canvas&lt;/a&gt;), and &lt;em&gt;NetID&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Select &lt;em&gt;COS 126, Fall 2026&lt;/em&gt; for the course.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Lecture recordings.&lt;/strong&gt; We post lecture recordings in &lt;em&gt;&lt;a href=&#34;https://princeton.instructure.com/courses/22541&#34;&gt;Canvas&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Precept exercises.&lt;/strong&gt; Posted on &lt;em&gt;&lt;a href=&#34;https://edstem.org/us/courses/99455/lessons&#34;&gt;Ed Lessons&lt;/a&gt;&lt;/em&gt;, along with solutions and additional practice exercises.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Java documentation.&lt;/strong&gt; The following references summarize the Java constructs and APIs you will use throughout the course:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;a href=&#34;https://introcs.cs.princeton.edu/java/11cheatsheet/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Java cheatsheet&lt;/a&gt;&lt;/em&gt;. Summarizes Java constructs and selected APIs used in this course.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;a href=&#34;https://introcs.cs.princeton.edu/java/stdlib/javadoc&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Textbook libraries Javadoc&lt;/a&gt;&lt;/em&gt;. Provides detailed documentation for the textbook libraries.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Java visualizer.&lt;/strong&gt; Visualize your code with the &lt;em&gt;&lt;a href=&#34;https://cscircles.cemc.uwaterloo.ca/java_visualize&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Java Visualizer&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Computers.&lt;/strong&gt;
If your laptop fails during the semester, there are a few options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;a href=&#34;https://oit.princeton.edu&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;OIT&lt;/a&gt;&lt;/em&gt; can troubleshoot laptop issues.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://mcgrawdll.princeton.edu/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;McGraw Digital Learning Lab&lt;/a&gt; has computers setup with our programming environment.&lt;/li&gt;
&lt;li&gt;Your residential college may offer loaner laptops.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Submitting assignments.&lt;/strong&gt; We use the platform &lt;em&gt;TigerFile&lt;/em&gt; for submitting programming assignments and programming exams. Each assignment will have its own TigerFile submission link.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Feedback and grading.&lt;/strong&gt; Grades and feedback are distributed across several systems:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We post grades on &lt;em&gt;&lt;a href=&#34;https://princeton.instructure.com/courses/22541&#34;&gt;Canvas&lt;/a&gt;&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;We use &lt;em&gt;Gradescope&lt;/em&gt; for feedback on programming assignments and written exams.&lt;/li&gt;
&lt;li&gt;You will receive an invitation to join &lt;em&gt;Gradescope&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Zoom.&lt;/strong&gt; We may use &lt;a href=&#34;https://princeton.zoom.us/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;em&gt;Zoom&lt;/em&gt;&lt;/a&gt; for certain office hours.&lt;/p&gt;
&lt;!-- , etc. Instructions for configuring your Princeton Zoom account can be found [here](https://princeton.service-now.com/service?id=kb_article&amp;sys_id=0e002cfc1bba00948f8243f4bd4bcb59).  --&gt;
</description>
    </item>
    
    <item>
      <title>Schedule</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/schedule-fall/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/schedule-fall/</guid>
      <description>&lt;details&gt;
  &lt;summary&gt;Click here for the precept schedule, including rooms and instructor&lt;/summary&gt;
  &lt;p&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt; Note - this is subject to change.&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Section&lt;/th&gt;
          &lt;th&gt;Days/Time&lt;/th&gt;
          &lt;th&gt;Room&lt;/th&gt;
          &lt;th&gt;Instructor&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;Lecture&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 1:20pm–2:40pm&lt;/td&gt;
          &lt;td&gt;McCosh 50&lt;/td&gt;
          &lt;td&gt;Yuri  Pritykin&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P10&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 2:55pm-4:15pm&lt;/td&gt;
          &lt;td&gt;McDonnell 105&lt;/td&gt;
          &lt;td&gt;Max Gonzalez Saez-Diez&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P10A&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 2:55pm-4:15pm&lt;/td&gt;
          &lt;td&gt;McDonnell 103A&lt;/td&gt;
          &lt;td&gt;Daniel Williams&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P10B&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 2:55pm-4:15pm&lt;/td&gt;
          &lt;td&gt;Friend 009&lt;/td&gt;
          &lt;td&gt;Donna Gabai&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P01&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 3:30pm-4:20pm&lt;/td&gt;
          &lt;td&gt;Friend 112&lt;/td&gt;
          &lt;td&gt;Sowmya Thanvantri&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P01A&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 3:30pm-4:20pm&lt;/td&gt;
          &lt;td&gt;Friend 111&lt;/td&gt;
          &lt;td&gt;Kylie Zhang&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P02&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 8:30am–9:20am&lt;/td&gt;
          &lt;td&gt;Andlinger 017&lt;/td&gt;
          &lt;td&gt;Abhishek Joshi&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P11 RPi&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 9:00am-10:20am&lt;/td&gt;
          &lt;td&gt;Friend  007&lt;/td&gt;
          &lt;td&gt;Alan Kaplan&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P11A&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 9:00am-10:20am&lt;/td&gt;
          &lt;td&gt;Friend 112&lt;/td&gt;
          &lt;td&gt;Nobline Yoo&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P03&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 9:35am-10:25am&lt;/td&gt;
          &lt;td&gt;Andlinger 017&lt;/td&gt;
          &lt;td&gt;Ryan Oet&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P03A&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 9:35am-10:25am&lt;/td&gt;
          &lt;td&gt;Bendheim House 103&lt;/td&gt;
          &lt;td&gt;Tim Kosfeld&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P04&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 10:40am-11:30am&lt;/td&gt;
          &lt;td&gt;Andlinger 017&lt;/td&gt;
          &lt;td&gt;Kara Schechtman&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P04A&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 10:40am-11:30am&lt;/td&gt;
          &lt;td&gt;Friend 007&lt;/td&gt;
          &lt;td&gt;Matthew Munoz&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P12&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 10:40am-12:00pm&lt;/td&gt;
          &lt;td&gt;Friend 111&lt;/td&gt;
          &lt;td&gt;Reva Hirave&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P05&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 12:15pm-1:05pm&lt;/td&gt;
          &lt;td&gt;Friend 112&lt;/td&gt;
          &lt;td&gt;Alan Zhang&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P05A&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 12:15pm-1:05pm&lt;/td&gt;
          &lt;td&gt;Friend 111&lt;/td&gt;
          &lt;td&gt;David Shustin&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P06&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 1:20pm-2:10pm&lt;/td&gt;
          &lt;td&gt;Friend 112&lt;/td&gt;
          &lt;td&gt;Donna Gabai&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/details&gt;

&lt;!--&lt;details&gt;
  &lt;summary&gt;Click here for instructor office hours&lt;/summary&gt;
  &lt;div class=&#34;responsive-wrap&#34;&gt;
  &lt;iframe src=&#34;https://calendar.google.com/calendar/embed?src=c_lnskd7q3lhjqm6d5jd0c60p13k%40group.calendar.google.com&amp;amp;ctz=America%2FNew_York&#34; frameborder=&#34;0&#34; width=&#34;960&#34; height=&#34;569&#34; allowfullscreen=&#34;true&#34; mozallowfullscreen=&#34;true&#34; webkitallowfullscreen=&#34;true&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;/details&gt;
--&gt;
&lt;h4 id=&#34;course-schedule&#34;&gt;&lt;strong&gt;Course Schedule&lt;/strong&gt;&lt;/h4&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Week&lt;/th&gt;
          &lt;th&gt;Date&lt;/th&gt;
          &lt;th&gt;Topic&lt;/th&gt;
          &lt;th&gt;Handouts | Demos | Assignments&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;0&lt;/td&gt;
          &lt;td&gt;Mon, Sep 1&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;Labor Day: No lecture&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Sep 1 &lt;br&gt;Tue, Sep 2&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;No precepts&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 3&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/00IntroCOS126.pdf&#34;&gt;Introduction to COS 126&lt;/a&gt;

&lt;br&gt; 


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/11IntroJava.pdf&#34;&gt;Introduction to Java&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.1-1.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 3 &lt;br&gt;Thu, Sep 4&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p00-hello-world/p00-hello-world.zip&#34;&gt;Hello World&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Sep 7&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hello/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Hello due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;1&lt;/td&gt;
          &lt;td&gt;Mon, Sep 8&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/13Conditionals.pdf&#34;&gt;Conditionals&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.2-1.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Sep 8 &lt;br&gt;Tue, Sep 9&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p02-data-types-conditionals/p02-data-types-conditionals.zip&#34;&gt;Conditionals&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 10&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/13Loops.pdf&#34;&gt;Loops&lt;/a&gt;

 &lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 10 &lt;br&gt;Thu, Sep 11&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p03-loops/p03-loops.zip&#34;&gt;Loops&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Sep 14&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/loops/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Conditionals &amp;amp; Loops due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;2&lt;/td&gt;
          &lt;td&gt;Mon, Sep 15&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/14Arrays.pdf&#34;&gt;Arrays&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.4&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/14DemoShuffle&#34; target=&#34;_blank&#34;&gt;Shuffle Demo&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Sep 15 &lt;br&gt;Tue, Sep 16&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p04-arrays/p04-arrays.zip&#34;&gt;Arrays&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 17&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/15InputOutput.pdf&#34;&gt;Input &amp;amp; Output&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.5&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 17 &lt;br&gt;Thu, Sep 18&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p05-io/p05-io.zip&#34;&gt;Input &amp;amp; Output&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Sep 21&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/arrays/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Arrays &amp;amp; IO due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;3&lt;/td&gt;
          &lt;td&gt;Mon, Sep 22&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/21Functions.pdf&#34;&gt;Functions&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 2.1&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/21DemoFunctionCall&#34; target=&#34;_blank&#34;&gt;Function-Call Demo&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Sep 22 &lt;br&gt;Tue, Sep 23&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p06-functions/p06-functions.zip&#34;&gt;Functions&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 24&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/22Libraries.pdf&#34;&gt;Libraries &amp;amp; Clients&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 2.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 24 &lt;br&gt;Thu, Sep 25&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p07-libraries/p07-libraries.zip&#34;&gt;Libraries &amp;amp; Clients&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Sep 28&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/functions/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Functions due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;4&lt;/td&gt;
          &lt;td&gt;Mon, Sep 29&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/23Recursion.pdf&#34;&gt;Recursion&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 2.3&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/23DemoFactorial&#34; target=&#34;_blank&#34;&gt;Factorial Demo&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Sep 29 &lt;br&gt;Tue, Sep 30&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p08-recursion/p08-recursion.zip&#34;&gt;Recursion&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 1&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/41Performance.pdf&#34;&gt;Performance&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 4.1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 1&lt;br&gt;Thu, Oct 2&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p09-performance/p09-performance.zip&#34;&gt;Performance&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Oct 5&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/recursion/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Recursive Graphics due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;5&lt;/td&gt;
          &lt;td&gt;Mon, Oct 6&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/Networking.pdf&#34;&gt;Introduction to Networking&lt;/a&gt;

&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Oct 6 &lt;br&gt;Tue, Oct 7&lt;/td&gt;
          &lt;td&gt;Precept: Written Exam 1 Review&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 8&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Written Exam 1&lt;/em&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 8 &lt;br&gt;Thu, Oct 9&lt;/td&gt;
          &lt;td&gt;Precept: None&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Oct 13 -&lt;br&gt; Fri, Oct 17&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;BREAK&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;6&lt;/td&gt;
          &lt;td&gt;Mon, Oct 20&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/31UsingDataTypes.pdf&#34;&gt;Using Data Types&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 3.1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Oct 20 &lt;br&gt;Tue, Oct 21&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p12-using-data-types/p12-using-data-types.zip&#34;&gt;Using Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 22&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/32CreatingDataTypes.pdf&#34;&gt;Creating Data Types&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 3.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 22 &lt;br&gt;Thu, Oct 23&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p13-creating-data-types/p13-creating-data-types.zip&#34;&gt;Creating Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Oct 26&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/oop/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Object-Oriented Programming due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;7&lt;/td&gt;
          &lt;td&gt;Mon, Oct 27&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/33DesigningDataTypes.pdf&#34;&gt;Designing Data Types&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 3.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Oct 27 &lt;br&gt;Tue, Oct 28&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p14-designing-data-types/p14-designing-data-types.zip&#34;&gt;Designing Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 29&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/IntroML.pdf&#34;&gt;Intro to Machine Learning&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; &lt;a href=&#34;https://www.wolfram.com/language/introduction-machine-learning/machine-learning-paradigms&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;2 | Machine Learning Paradigms&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 29 &lt;br&gt;Thu, Oct 30&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p15-aiml/p15-aiml.zip&#34;&gt;Intro to Machine Learning&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Nov 2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/classifier/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Image Classifier due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;8&lt;/td&gt;
          &lt;td&gt;Mon, Nov 3&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/42Algorithms.pdf&#34;&gt;Algorithms&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 4.2&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoBinarySearch&#34; target=&#34;_blank&#34;&gt;Binary Search Demo&lt;/a&gt;

  &lt;br&gt; Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoInsertionSort&#34; target=&#34;_blank&#34;&gt;Insertion Sort Demo&lt;/a&gt;

 &lt;br&gt; Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoMerge&#34; target=&#34;_blank&#34;&gt;Mergesort Demo&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 3 &lt;br&gt;Tue, Nov 4&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p16-algorithms/p16-algorithms.zip&#34;&gt;Algorithms&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 5&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/43DataStructures.pdf&#34;&gt;Data Structures&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 4.3&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/43DemoDijkstraTwoStack&#34; target=&#34;_blank&#34;&gt;Dijkstra Two Stack&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 5 &lt;br&gt;Thu, Nov 6&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p17-data-structures/p17-data-structures.zip&#34;&gt;Data Structures&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Nov 9&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/guitar/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Guitar Hero due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;9&lt;/td&gt;
          &lt;td&gt;Mon, Nov 10&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/50TheoryOfComputing.pdf&#34;&gt;Theory of Computing&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 5.3-5.4&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 10&lt;br&gt;Tue, Nov 11&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p18-theory/p18-theory.zip&#34;&gt;Theory of Computing&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 12&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/60ToyI.pdf&#34;&gt;Toy I&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 6.1-6.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 12 &lt;br&gt;Thu, Nov 13&lt;/td&gt;
          &lt;td&gt;Precept Toy I&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Nov 16&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/chat126/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Chat126 due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;10&lt;/td&gt;
          &lt;td&gt;Mon, Nov 17&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/60ToyII.pdf&#34;&gt;Toy II&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 6.3-6.4&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 17 &lt;br&gt;Tue, Nov 18&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p20-toy2/p20-toy2.zip&#34;&gt;Toy II&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 19&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/70Circuits.pdf&#34;&gt;Circuits&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 7.1, 7.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 19 &lt;br&gt;Thu, Nov 20&lt;/td&gt;
          &lt;td&gt;Precept Circuits&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Nov 23&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hamming/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Hamming due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;11&lt;/td&gt;
          &lt;td&gt;Mon, Nov 24&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Programming Exam&lt;/em&gt; &lt;br&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 24 &lt;br&gt;Tue, Nov 25&lt;/td&gt;
          &lt;td&gt;No precept&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 26 &lt;br&gt;Thu, Nov 27&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;THANKSGIVING BREAK&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;12&lt;/td&gt;
          &lt;td&gt;Mon, Dec 1&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/2025-12-01-COS126-IntroCompBio.pdf&#34;&gt;Introduction to Computational Biology&lt;/a&gt;

&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Dec 1&lt;br&gt;Tue, Dec 2&lt;/td&gt;
          &lt;td&gt;Precept Java Jeopardy&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Dec 3&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Written Exam 2&lt;/em&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Dec 3&lt;br&gt;Thu, Dec 4&lt;/td&gt;
          &lt;td&gt;No precept&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;13+&lt;/td&gt;
          &lt;td&gt;Mon, Dec 8&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/Atomic_Nature_of_Matter.pdf&#34;&gt;Optional class session for Final Project&lt;/a&gt;

&lt;/td&gt;
          &lt;td&gt;2:00-4:00pm in CS 105&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Dec 14&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Final Project:&lt;/em&gt; Atomic due, 11:30am&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;!--


&lt;p style=&#34;color:red;&#34;&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt;  The lectures below have not yet been updated for Fall 2025!&lt;/p&gt;




|      |             |    |   |
| ---- | -------     | ---|---|

--&gt;
</description>
    </item>
    
    <item>
      <title>Schedule</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/schedule-spring/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/schedule-spring/</guid>
      <description>&lt;details&gt;
  &lt;summary&gt;Click here for the precept schedule, including rooms and instructor&lt;/summary&gt;
  &lt;!-- &lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt; Note - this is subject to change. --&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Section&lt;/th&gt;
          &lt;th&gt;Days/Time&lt;/th&gt;
          &lt;th&gt;Room&lt;/th&gt;
          &lt;th&gt;Instructor&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;Lecture&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 1:20pm–2:40pm&lt;/td&gt;
          &lt;td&gt;McCosh 50&lt;/td&gt;
          &lt;td&gt;Kevin Wayne&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P01&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 3:30pm-4:20pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P01A&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 3:30pm-4:20pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P02&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 8:30am–9:20am&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P03&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 9:35am-10:25am&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P04&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 10:40am-11:30am&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P04A&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 10:40am-11:30am&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P05&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 12:15pm-1:05pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P05A&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 12:15pm-1:05pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P06&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 1:20pm-2:10pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P10&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 2:55pm-4:15pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P10A&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 2:55pm-4:15pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P10B&lt;/td&gt;
          &lt;td&gt;Mon/Wed, 2:55pm-4:15pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P11&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 9:00am-10:20am&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Precept P12&lt;/td&gt;
          &lt;td&gt;Tue/Thu, 10:40am-12:00pm&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/details&gt;

&lt;!--&lt;details&gt;
  &lt;summary&gt;Click here for instructor office hours&lt;/summary&gt;
  &lt;div class=&#34;responsive-wrap&#34;&gt;
  &lt;iframe src=&#34;https://calendar.google.com/calendar/embed?src=c_lnskd7q3lhjqm6d5jd0c60p13k%40group.calendar.google.com&amp;amp;ctz=America%2FNew_York&#34; frameborder=&#34;0&#34; width=&#34;960&#34; height=&#34;569&#34; allowfullscreen=&#34;true&#34; mozallowfullscreen=&#34;true&#34; webkitallowfullscreen=&#34;true&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;/details&gt;
--&gt;
&lt;h4 id=&#34;course-schedule&#34;&gt;&lt;strong&gt;Course Schedule&lt;/strong&gt;&lt;/h4&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Week&lt;/th&gt;
          &lt;th&gt;Date&lt;/th&gt;
          &lt;th&gt;Topic&lt;/th&gt;
          &lt;th&gt;Handouts | Demos | Assignments&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;0&lt;/td&gt;
          &lt;td&gt;Mon, Jan 26&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/00IntroCOS126.pdf&#34;&gt;Introduction to COS 126&lt;/a&gt;

&lt;br&gt; 


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/11HelloWorld.pdf&#34;&gt;Hello, World&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Jan 26 &lt;br&gt;Tue, Jan 27&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p00-hello-world/p00-hello-world.zip&#34;&gt;Hello World&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Jan 28&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/12DataTypes.pdf&#34;&gt;Data Types&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Jan 28 &lt;br&gt;Thu, Jan 28&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p01-data-types/p01-data-types.zip&#34;&gt;Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Feb 1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hello/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Hello due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;1&lt;/td&gt;
          &lt;td&gt;Mon, Feb 2&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/13Conditionals.pdf&#34;&gt;Conditionals&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Feb 2 &lt;br&gt;Tue, Feb 3&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p02-conditionals/p02-conditionals.zip&#34;&gt;Conditionals&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Feb 4&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/13Loops.pdf&#34;&gt;Loops&lt;/a&gt;

 &lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Feb 4 &lt;br&gt;Thu, Feb 5&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p03-loops/p03-loops.zip&#34;&gt;Loops&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Feb 8&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/loops/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Conditionals &amp;amp; Loops due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;2&lt;/td&gt;
          &lt;td&gt;Mon, Feb 9&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/14Arrays.pdf&#34;&gt;Arrays&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.4&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/14DemoShuffle&#34; target=&#34;_blank&#34;&gt;Shuffle Demo&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Feb 9 &lt;br&gt;Tue, Feb 10&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p04-arrays/p04-arrays.zip&#34;&gt;Arrays&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Feb 11&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/15InputOutput.pdf&#34;&gt;Input &amp;amp; Output&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 1.5&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Feb 11 &lt;br&gt;Thu, Feb 12&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p05-io/p05-io.zip&#34;&gt;Input &amp;amp; Output&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Feb 15&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/arrays/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Arrays &amp;amp; IO due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;3&lt;/td&gt;
          &lt;td&gt;Mon, Feb 16&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/21Functions.pdf&#34;&gt;Functions&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 2.1&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/21DemoFunctionCall&#34; target=&#34;_blank&#34;&gt;Function-Call Demo&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Feb 16 &lt;br&gt;Tue, Feb 17&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p06-functions/p06-functions.zip&#34;&gt;Functions&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Feb 18&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/22Libraries.pdf&#34;&gt;Libraries &amp;amp; Clients&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 2.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Feb 18 &lt;br&gt;Thu, Feb 19&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p07-libraries/p07-libraries.zip&#34;&gt;Libraries &amp;amp; Clients&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Feb 22&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/functions/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Functions due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;4&lt;/td&gt;
          &lt;td&gt;Mon, Feb 23&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/23Recursion.pdf&#34;&gt;Recursion&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 2.3&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/23DemoFactorial&#34; target=&#34;_blank&#34;&gt;Factorial Demo&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Feb 23 &lt;br&gt;Tue, Feb 24&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p08-recursion/p08-recursion.zip&#34;&gt;Recursion&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Feb 25&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/41Performance.pdf&#34;&gt;Performance&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 4.1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Feb 25&lt;br&gt;Thu, Feb 26&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p09-performance/p09-performance.zip&#34;&gt;Performance&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Mar 1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/recursion/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Recursive Graphics due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;5&lt;/td&gt;
          &lt;td&gt;Mon, Mar 2&lt;/td&gt;
          &lt;td&gt;Lecture: Midterm Review&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Mar 2 &lt;br&gt;Tue, Mar 3&lt;/td&gt;
          &lt;td&gt;Precept: Midterm Review&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Mar 4&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Midterm&lt;/em&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Mar 5 &lt;br&gt;Thu, Mar 6&lt;/td&gt;
          &lt;td&gt;Precept: None&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Mar 9 -&lt;br&gt; Fri, Mar 13&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;BREAK&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;6&lt;/td&gt;
          &lt;td&gt;Mon, Mar 16&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/31UsingDataTypes.pdf&#34;&gt;Using Data Types&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 3.1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Mar 16 &lt;br&gt;Tue, Mar 17&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p12-using-data-types/p12-using-data-types.zip&#34;&gt;Using Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Mar 18&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/32CreatingDataTypes.pdf&#34;&gt;Creating Data Types&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 3.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Mar 18 &lt;br&gt;Thu, Mar 19&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p13-creating-data-types/p13-creating-data-types.zip&#34;&gt;Creating Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Mar 22&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/oop/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Object-Oriented Programming due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;7&lt;/td&gt;
          &lt;td&gt;Mon, Mar 23&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/33DesigningDataTypes.pdf&#34;&gt;Designing Data Types&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 3.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Mar 23 &lt;br&gt;Tue, Mar 24&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p14-designing-data-types/p14-designing-data-types.zip&#34;&gt;Designing Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Mar 25&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/AIML.pdf&#34;&gt;Intro to Machine Learning&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; &lt;a href=&#34;https://www.wolfram.com/language/introduction-machine-learning/machine-learning-paradigms&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;2 | Machine Learning Paradigms&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Mar 25 &lt;br&gt;Thu, Mar 26&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p15-aiml/p15-aiml.zip&#34;&gt;Intro to Machine Learning&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Mar 29&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/classifier/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Image Classifier due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;8&lt;/td&gt;
          &lt;td&gt;Mon, Mar 30&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/42Algorithms.pdf&#34;&gt;Algorithms&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 4.2&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoBinarySearch&#34; target=&#34;_blank&#34;&gt;Binary Search Demo&lt;/a&gt;

  &lt;br&gt; Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoInsertionSort&#34; target=&#34;_blank&#34;&gt;Insertion Sort Demo&lt;/a&gt;

 &lt;br&gt; Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoMerge&#34; target=&#34;_blank&#34;&gt;Mergesort Demo&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Mar 30 &lt;br&gt;Tue, Mar 31&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p16-algorithms/p16-algorithms.zip&#34;&gt;Algorithms&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Apr 1&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/43DataStructures.pdf&#34;&gt;Data Structures&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 4.3&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/43DemoDijkstraTwoStack&#34; target=&#34;_blank&#34;&gt;Dijkstra Two Stack&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Apr 1 &lt;br&gt;Thu, Apr 2&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p17-data-structures/p17-data-structures.zip&#34;&gt;Data Structures&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Apr 5&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/guitar/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Guitar Hero due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;9&lt;/td&gt;
          &lt;td&gt;Mon, Apr 6&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/50TheoryOfComputing.pdf&#34;&gt;Theory of Computing&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 5.3-5.4&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Apr 6&lt;br&gt;Tue, Apr 7&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p18-theory/p18-theory.zip&#34;&gt;Theory of Computing&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Apr 8&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/60ToyI.pdf&#34;&gt;Toy I&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 6.1-6.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Apr 8 &lt;br&gt;Thu, Apr 9&lt;/td&gt;
          &lt;td&gt;Precept Toy I&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Apr 12&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/chat126/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Chat126 due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;10&lt;/td&gt;
          &lt;td&gt;Mon, Apr 13&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/60ToyII.pdf&#34;&gt;Toy II&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 6.3-6.4&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Apr 13 &lt;br&gt;Tue, Apr 14&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p20-toy2/p20-toy2.zip&#34;&gt;Toy II&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Apr 15&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Programming Exam&lt;/em&gt; &lt;br&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Apr 15 &lt;br&gt;Thu, Apr 16&lt;/td&gt;
          &lt;td&gt;Precept Java Jeopardy&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Apr 19&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hamming/&#34;&gt;&lt;em&gt;Assignment:&lt;/em&gt; Hamming due&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;11&lt;/td&gt;
          &lt;td&gt;Mon, Apr 20&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/70Circuits.pdf&#34;&gt;Circuits&lt;/a&gt;

&lt;br&gt; &lt;em&gt;Reading:&lt;/em&gt; 7.1, 7.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Apr 20  &lt;br&gt;Tue, Apr 21&lt;/td&gt;
          &lt;td&gt;Precept Circuits&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Apr 22&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Written Exam 2&lt;/em&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Apr 22 &lt;br&gt;Thu, Apr 23&lt;/td&gt;
          &lt;td&gt;No precept&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;12&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;READING WEEK&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;13&lt;/td&gt;
          &lt;td&gt;Wed, May 5&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Project:&lt;/em&gt; Atomic due 5:00pm&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;14&lt;/td&gt;
          &lt;td&gt;Wed, May&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;em&gt;Final Exam:&lt;/em&gt; TBD&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</description>
    </item>
    
    <item>
      <title>Schedule</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/schedule/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/schedule/</guid>
      <description>&lt;details&gt;
  &lt;summary&gt;&lt;em&gt;Click here for the precept schedule, including rooms and instructor.&lt;/em&gt;&lt;/summary&gt;
  &lt;p&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt; Note - this is subject to change.&lt;/p&gt;
&lt;div class=&#34;md-table md-table-clean&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Section&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Meetings&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Room&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Instructor&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Lecture L01&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Mon/Wed, 1:20–2:40pm&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;McCosh 50&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Adam Finkelstein/Maryam Hedayati&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P01&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Mon/Wed, 3:30–4:20pm&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 112&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Matthew Munoz&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P01A&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Mon/Wed, 3:30–4:20pm&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 007&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Reva Hirave&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P02&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 8:30–9:20am&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 007&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;James Zhang&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P03&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 9:35–10:25am&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 007&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Alan Kaplan&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P03A&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 9:35–10:25am&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 112&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Donna Gabai&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P04&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 10:40–11:30am&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 007&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;John Luo&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P04A&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 10:40–11:30am&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 112&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Michelle Le&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P05&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 12:15–1:05pm&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 110&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Slater Fisch&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P05A&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 12:15–1:05pm&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 007&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Liz Austell&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P06&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 1:20–2:10pm&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Bend House 103&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Donna Gabai&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P10&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Mon/Wed, 2:55–4:15pm&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 111&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Maryam Hedayati&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P11&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 9:00–10:20am&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 111&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Arnold Caleb Asiimwe&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Precept P13 (RPi)&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Tue/Thu, 1:20-2:40pm&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Friend 005&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Brian Phillips&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br&gt;
&lt;h4 id=&#34;course-schedule&#34;&gt;&lt;strong&gt;Course Schedule&lt;/strong&gt;&lt;/h4&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Week&lt;/th&gt;
          &lt;th&gt;Date&lt;/th&gt;
          &lt;th&gt;Topic&lt;/th&gt;
          &lt;th&gt;Handouts | Demos | Assignments&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;0&lt;/td&gt;
          &lt;td&gt;Wed, Sep 2&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/00IntroCOS126.pdf&#34;&gt;Introduction to COS 126&lt;/a&gt;

&lt;br&gt; 


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/11HelloWorld.pdf&#34;&gt;Hello, World&lt;/a&gt;

&lt;br&gt; Reading: 1.1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 2 &lt;br&gt;Thu, Sep 3&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p00-hello-world/p00-hello-world.zip&#34;&gt;Hello World&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 9&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/12DataTypes.pdf&#34;&gt;Data Types&lt;/a&gt;

&lt;br&gt; Reading: 1.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 9 &lt;br&gt;Thu, Sep 10&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p01-data-types/p01-data-types.zip&#34;&gt;Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Sep 13&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hello/&#34;&gt;Hello&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;1&lt;/td&gt;
          &lt;td&gt;Mon, Sep 14&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/13Conditionals.pdf&#34;&gt;Conditionals&lt;/a&gt;

&lt;br&gt; Reading: 1.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Sep 14 &lt;br&gt;Tue, Sep 15&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p02-conditionals/p02-conditionals.zip&#34;&gt;Conditionals&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 16&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/13Loops.pdf&#34;&gt;Loops&lt;/a&gt;

 &lt;br&gt; Reading: 1.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 16 &lt;br&gt;Thu, Sep 17&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p03-loops/p03-loops.zip&#34;&gt;Loops&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Sep 20&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/loops/&#34;&gt;Conditionals and Loops&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;2&lt;/td&gt;
          &lt;td&gt;Mon, Sep 21&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/14Arrays.pdf&#34;&gt;Arrays&lt;/a&gt;

&lt;br&gt; Reading: 1.4&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/14DemoShuffle&#34; target=&#34;_blank&#34;&gt;Shuffle&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Sep 21 &lt;br&gt;Tue, Sep 22&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p04-arrays/p04-arrays.zip&#34;&gt;Arrays&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 23&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/15InputOutput.pdf&#34;&gt;Input and Output&lt;/a&gt;

&lt;br&gt; Reading: 1.5&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 23 &lt;br&gt;Thu, Sep 24&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p05-io/p05-io.zip&#34;&gt;Input and Output&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Sep 27&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/arrays/&#34;&gt;Arrays and IO&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;3&lt;/td&gt;
          &lt;td&gt;Mon, Sep 28&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/21Functions.pdf&#34;&gt;Functions&lt;/a&gt;

&lt;br&gt; Reading: 2.1&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/21DemoFunctionCall&#34; target=&#34;_blank&#34;&gt;Function Call&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Sep 28 &lt;br&gt;Tue, Sep 29&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p06-functions/p06-functions.zip&#34;&gt;Functions&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 30&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/22Libraries.pdf&#34;&gt;Libraries and Clients&lt;/a&gt;

&lt;br&gt; Reading: 2.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Sep 30 &lt;br&gt;Thu, Oct 1&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p07-libraries/p07-libraries.zip&#34;&gt;Libraries and Clients&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Oct 4&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/functions/&#34;&gt;Functions&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;4&lt;/td&gt;
          &lt;td&gt;Mon, Oct 5&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/23Recursion.pdf&#34;&gt;Recursion&lt;/a&gt;

&lt;br&gt; Reading: 2.3&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/23DemoFactorial&#34; target=&#34;_blank&#34;&gt;Factorial&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Oct 5 &lt;br&gt;Tue, Oct 6&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p08-recursion/p08-recursion.zip&#34;&gt;Recursion&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 7&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/41Performance.pdf&#34;&gt;Performance&lt;/a&gt;

&lt;br&gt; Reading: 4.1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 7&lt;br&gt;Thu, Oct 8&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p09-performance/p09-performance.zip&#34;&gt;Performance&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Oct 11&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/recursion/&#34;&gt;Recursive Graphics&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;5&lt;/td&gt;
          &lt;td&gt;Mon, Oct 12&lt;/td&gt;
          &lt;td&gt;Lecture: Midterm Review&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Oct 12 &lt;br&gt;Tue, Oct 13&lt;/td&gt;
          &lt;td&gt;Precept: Midterm Review&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 14&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;Midterm&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 14 &lt;br&gt;Thu, Oct 15&lt;/td&gt;
          &lt;td&gt;Precept: None&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Oct 19 -&lt;br&gt; Fri, Oct 23&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;FALL BREAK&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;6&lt;/td&gt;
          &lt;td&gt;Mon, Oct 26&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/31UsingDataTypes.pdf&#34;&gt;Using Data Types&lt;/a&gt;

&lt;br&gt; Reading: 3.1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Oct 26 &lt;br&gt;Tue, Oct 27&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p12-using-data-types/p12-using-data-types.zip&#34;&gt;Using Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 28&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/32CreatingDataTypes.pdf&#34;&gt;Creating Data Types&lt;/a&gt;

&lt;br&gt; Reading: 3.2&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Oct 28 &lt;br&gt;Thu, Oct 29&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p13-creating-data-types/p13-creating-data-types.zip&#34;&gt;Creating Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Nov 1&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/oop/&#34;&gt;OOP&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;7&lt;/td&gt;
          &lt;td&gt;Mon, Nov 2&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/33DesigningDataTypes.pdf&#34;&gt;Designing Data Types&lt;/a&gt;

&lt;br&gt; Reading: 3.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 2 &lt;br&gt;Tue, Nov 3&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p14-designing-data-types/p14-designing-data-types.zip&#34;&gt;Designing Data Types&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 4&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/42Algorithms.pdf&#34;&gt;Algorithms&lt;/a&gt;

&lt;br&gt; Reading: 4.2&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoBinarySearch&#34; target=&#34;_blank&#34;&gt;Binary Search&lt;/a&gt;

  &lt;br&gt; Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoInsertionSort&#34; target=&#34;_blank&#34;&gt;Insertion Sort&lt;/a&gt;

 &lt;br&gt; Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/42DemoMerge&#34; target=&#34;_blank&#34;&gt;Mergesort&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 4 &lt;br&gt;Tue, Nov 5&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p15-algorithms/p15-algorithms.zip&#34;&gt;Algorithms&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Nov 8&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/guitar/&#34;&gt;Guitar Hero&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;8&lt;/td&gt;
          &lt;td&gt;Mon, Nov 9&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/43DataStructures.pdf&#34;&gt;Data Structures&lt;/a&gt;

&lt;br&gt; Reading: 4.3&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/43DemoDijkstraTwoStack&#34; target=&#34;_blank&#34;&gt;Dijkstra Two Stack&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 9 &lt;br&gt;Tue, Nov 10&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p16-data-structures/p16-data-structures.zip&#34;&gt;Data Structures&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 11&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/50TheoryOfComputing.pdf&#34;&gt;Theory of Computing&lt;/a&gt;

&lt;br&gt; Reading: 5.3-5.4&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 11&lt;br&gt;Thurs, Nov 12&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p17-theory/p17-theory.zip&#34;&gt;Theory of Computing&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Nov 15&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/chat126/&#34;&gt;Chat126&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;9&lt;/td&gt;
          &lt;td&gt;Mon, Nov 16&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/IntroML.pdf&#34;&gt;Intro to Machine Learning&lt;/a&gt;

&lt;br&gt; Reading: &lt;a href=&#34;https://www.wolfram.com/language/introduction-machine-learning/machine-learning-paradigms&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Machine Learning Paradigms&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 16&lt;br&gt;Tue, Nov 17&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p18-aiml/p18-aiml.zip&#34;&gt;Intro to Machine Learning&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 18&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/IntroDL.pdf&#34;&gt;Intro to Deep Learning&lt;/a&gt;

&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 18 &lt;br&gt;Thu, Nov 19&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/ML-2/ML-2.zip&#34;&gt;ML-2&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Nov 22&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/classifier/&#34;&gt;Image Classifier&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 23&lt;/td&gt;
          &lt;td&gt;Lecture: Networking&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 18 &lt;br&gt;Thu, Nov 19&lt;/td&gt;
          &lt;td&gt;Precept: Networking&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Nov 25 -&lt;br&gt; Fri, Nov 27&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;THANKSGIVING BREAK&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;10&lt;/td&gt;
          &lt;td&gt;Mon, Nov 30&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/60ToyI.pdf&#34;&gt;Toy I&lt;/a&gt;

&lt;br&gt; Reading: 6.1-6.2&lt;/td&gt;
          &lt;td&gt;Demo: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/demos/60DemoToyMachine&#34; target=&#34;_blank&#34;&gt;TOY Machine&lt;/a&gt;

&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Nov 30 &lt;br&gt;Tues, Dec 1&lt;/td&gt;
          &lt;td&gt;Precept: Toy I&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Dec 2&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/60ToyII.pdf&#34;&gt;Toy II&lt;/a&gt;

&lt;br&gt; Reading: 6.3-6.4&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Wed, Dec 2 &lt;br&gt;Thu, Dec 3&lt;/td&gt;
          &lt;td&gt;&lt;br&gt;Precept: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/precepts/p21-toy2/p21-toy2.zip&#34;&gt;Toy II&lt;/a&gt;
&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Sun, Dec 6&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Assignment due: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/assignments/hamming/&#34;&gt;Hamming&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;11&lt;/td&gt;
          &lt;td&gt;Mon, Dec 7&lt;/td&gt;
          &lt;td&gt;


   Lecture: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/lectures/70Circuits.pdf&#34;&gt;Circuits&lt;/a&gt;

&lt;br&gt; Reading: 7.1, 7.3&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Mon, Dec 7 &lt;br&gt;Tue, Dec 8&lt;/td&gt;
          &lt;td&gt;Precept: Circuits&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;12&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;READING PERIOD&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;13&lt;/td&gt;
          &lt;td&gt;Tue, Dec 15&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;Dean&amp;rsquo;s Date&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;Project due 5pm: &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/project/&#34;&gt;Atomic&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;14&lt;/td&gt;
          &lt;td&gt;Sun, Dec 20&lt;/td&gt;
          &lt;td&gt;&lt;strong&gt;Final Exam&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;4:00pm - 07:00 pm&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</description>
    </item>
    
    <item>
      <title>Syllabus</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/syllabus/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/syllabus/</guid>
      <description>&lt;h3 id=&#34;course-description&#34;&gt;Course Description&lt;/h3&gt;
&lt;p&gt;COS 126 introduces computer science through scientific, engineering, and commercial applications.
You will learn fundamental principles and practical programming skills that prepare you to use computers effectively in fields such as computer science, physics, biology, chemistry, and engineering.
The course uses Java to introduce fundamental programming concepts, including conditionals, loops, arrays, functions, and object-oriented programming. Additional topics include algorithms and data structures; principles of computation; hardware and software systems; and machine learning.&lt;/p&gt;
&lt;h3 id=&#34;course-communications&#34;&gt;Course Communications&lt;/h3&gt;
&lt;p&gt;We use &lt;a href=&#34;https://edstem.org/us/courses/99455/discussion&#34;&gt;&lt;em&gt;Ed Discussion&lt;/em&gt;&lt;/a&gt; for course announcements and the course discussion forum.
Start there if you have a question; post publicly when possible and privately for personal matters.
For office hours, Lab TAs, and other support options, see the &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/help/&#34;&gt;Help&lt;/a&gt; page.&lt;/p&gt;
&lt;h3 id=&#34;textbook&#34;&gt;Textbook&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Computer Science: An Interdisciplinary Approach&lt;/em&gt;, by Robert Sedgewick and Kevin Wayne. Addison–Wesley Professional, 2016. ISBN 978-0134076423.&lt;/p&gt;
&lt;p&gt;We use this text throughout the semester; lectures and precepts follow it closely.&lt;/p&gt;
&lt;h3 id=&#34;course-organization&#34;&gt;Course Organization&lt;/h3&gt;
&lt;p&gt;This course includes lectures, precepts, programming assignments, code reviews,
a programming project, a midterm exam, and a final exam.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Lectures.&lt;/strong&gt;
Class meets twice per week. Lectures introduce new content and motivate the week’s topics.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;iClickers.&lt;/strong&gt;&lt;/em&gt;
We use &lt;em&gt;&lt;a href=&#34;https://www.iclicker.com/students/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;iClicker&lt;/a&gt;&lt;/em&gt; to make lectures more interactive.
To earn participation credit, you must attend lecture and submit responses to at least 50% of the iClicker poll questions.
You may not use a classmate’s iClicker or allow someone else to use yours.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Lecture recordings.&lt;/strong&gt;&lt;/em&gt; We record lectures and post in &lt;em&gt;&lt;a href=&#34;https://princeton.instructure.com/courses/22541&#34;&gt;Canvas&lt;/a&gt;&lt;/em&gt;.
The system is set up not to capture student voices, but if you speak loudly it might be audible.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Lecture absences.&lt;/strong&gt;&lt;/em&gt;
The first four lecture absences are automatically waived.
This accounts for illnesses, religious observances, varsity athletic competitions, late course
enrollment, and technical issues with the iClicker app.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Waivers beyond the four waived absences.&lt;/strong&gt;&lt;/em&gt;
To request a participation waiver beyond the four waived absences, post privately on Ed with a brief explanation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Precepts.&lt;/strong&gt;
Precepts meet twice per week.
In a small group, your preceptor will review key learning objectives from the week’s lectures and
lead interactive exercises and discussion, often in pairs.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Precept absences.&lt;/strong&gt;&lt;/em&gt;
The first four absences are automatically waived. This accounts for illnesses, religious observances, varsity athletic competitions, and late course
enrollment.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Waivers beyond the four waived absences.&lt;/strong&gt;&lt;/em&gt;
To request a participation waiver beyond the four waived absences, post privately on Ed with a brief explanation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Attending another precept.&lt;/strong&gt;&lt;/em&gt;
If you cannot attend your assigned precept, you may occasionally attend another precept. Notify both your regular preceptor and the preceptor you plan to visit.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Reviewing precept.&lt;/strong&gt;&lt;/em&gt; If you miss a precept, see the materials on &lt;em&gt;&lt;a href=&#34;https://edstem.org/us/courses/99455/lessons&#34;&gt;Ed Lessons&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Programming Assignments.&lt;/strong&gt;
There are ten programming assignments, equally weighted.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Late work.&lt;/strong&gt;&lt;/em&gt;
Assignments are due Sundays at 11:59pm ET. If any part of an assignment is submitted late, the entire assignment is late.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Late penalties.&lt;/strong&gt;&lt;/em&gt;
Late work receives a penalty of 10% of the assignment’s total points per day (or partial day).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Free late days.&lt;/strong&gt;&lt;/em&gt;
Your first four late days are automatically waived. &lt;!-- Do not contact course staff to use these waived late days. --&gt;
This accounts for illnesses, religious observances, travel, and late course enrollment.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Extensions beyond the four free late days.&lt;/strong&gt;&lt;/em&gt;
Extensions beyond the four free late days require a documented medical or personal emergency and a
recommendation from your Residential College Dean. To request one, post privately on Ed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Late days and partners.&lt;/strong&gt;&lt;/em&gt;
If you work with a partner, late penalties apply to the group. The number of waived late days available to the group is the minimum number remaining among the partners.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Submission signal.&lt;/strong&gt;&lt;/em&gt;
We will not grade your submission until &lt;code&gt;acknowledgments.txt&lt;/code&gt; is submitted. If you plan to submit late, do not submit that file until you are finished and ready for grading.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;!--  ***Style.*** In addition to correctness, we grade *style*. Your code should be well-commented, consistently formatted, and compile without warnings. Your submission must have no Checkstyle warnings. Style issues may reduce your score. --&gt;
&lt;p&gt;&lt;strong&gt;Code Reviews.&lt;/strong&gt;
You must attend four code review sessions (20 minutes each) to review your graded programming assignments,
clarify feedback (grader comments, warnings, error messages, and deductions),
and discuss style and design. You will be asked to explain your code.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Credit:&lt;/strong&gt;&lt;/em&gt; credit is based on attendance, participation, and understanding of your code. UCAs will grade only on participation; grad TAs and faculty members will grade both on attendance and understanding. There will be a grade penalty for no-shows and rescheduling past the scheduling deadline.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Sign-up:&lt;/strong&gt;&lt;/em&gt; details forthcoming.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Partners:&lt;/strong&gt; for partner submissions, partners will complete code reviews separately. Both partners should understand and be able to explain all of their submitted code.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Programming Project.&lt;/strong&gt;
The project is a capstone that integrates topics from across the course.
It is about the size of two programming assignments.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Partner:&lt;/strong&gt;&lt;/em&gt; you are encouraged to work with a partner.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Late policy:&lt;/strong&gt;&lt;/em&gt;  late days may not be used on the project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exams.&lt;/strong&gt;
There is one in-class midterm exam and one final exam.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Midterm exam:&lt;/strong&gt;&lt;/em&gt; in class on Wednesday, October 14.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Final exam:&lt;/strong&gt;&lt;/em&gt; Sunday, December 20 4pm-7pm, room TBD.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Rescheduling:&lt;/strong&gt;&lt;/em&gt; Exams are rescheduled only in the event of a personal emergency.
In-class exams requires a recommendation from a Residential College Dean and approval from the instructor.
Final exam postponements require approval from the Registrar.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Regrades.&lt;/strong&gt; If you believe your work was graded incorrectly (or your participation was recorded incorrectly),
submit a regrade request within &lt;em&gt;three days&lt;/em&gt; of the grade being posted:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Written exams:&lt;/strong&gt;&lt;/em&gt; submit via &lt;em&gt;Gradescope&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Programming assignments/project:&lt;/strong&gt;&lt;/em&gt; submit via &lt;em&gt;Gradescope&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Lecture and precept participation:&lt;/strong&gt;&lt;/em&gt; post privately on &lt;em&gt;Ed&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;course-grades&#34;&gt;Course Grades&lt;/h3&gt;
&lt;p&gt;Your course grade will be calculated based on a weighted sum of the programming assignments, code reviews, programming project, exams, and participation.&lt;/p&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: left&#34;&gt;Component&lt;/th&gt;
          &lt;th style=&#34;text-align: right&#34;&gt;Weight&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Programming Assignments (Code testing)&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;18%&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Programming Assignments (Code reviews)&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;12%&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Project&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;5%&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Midterm Exam&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;25%&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Final Exam&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;35%&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Participation&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;5%&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Total&lt;/td&gt;
          &lt;td style=&#34;text-align: right&#34;&gt;100%&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Letter grades.&lt;/strong&gt;  Cutoffs are set at semester end and are not curved to a fixed distribution. The following thresholds guarantee at least the listed grade: A (93.0), A– (90.0), B+ (87.0), B (83.0), B– (80.0), C+ (77.0), C (73.0), C– (70.0), D (60.0). Grades are not rounded.&lt;/p&gt;
&lt;h3 id=&#34;course-collaboration-policy&#34;&gt;Course Collaboration Policy&lt;/h3&gt;
&lt;p&gt;This collaboration policy applies to all programming assignments and the project (both are referred to as “assignments” below).
We encourage collaboration with course staff, classmates, and lab TAs, but only as permitted below. Here is an executive summary:&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;your partner&lt;/th&gt;
          &lt;th&gt;course staff&lt;/th&gt;
          &lt;th&gt;COS 126 alums&lt;/th&gt;
          &lt;th&gt;COS 126 students&lt;/th&gt;
          &lt;th&gt;generative AI&lt;/th&gt;
          &lt;th&gt;other&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;strong&gt;discuss concepts with &amp;hellip;&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;strong&gt;acknowledge collaboration with &amp;hellip;&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;strong&gt;show your code/solutions to &amp;hellip;&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;strong&gt;view any code/solutions from &amp;hellip;&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;strong&gt;copy any code/solutions from &amp;hellip;&lt;/strong&gt;&lt;/td&gt;
          &lt;td&gt;yes&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
          &lt;td&gt;no&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Concepts vs. assignment-specific code.&lt;/strong&gt;
You may discuss general &lt;em&gt;concepts&lt;/em&gt; with classmates, but you may not discuss &lt;em&gt;assignment-specific code&lt;/em&gt;.
For example, you may discuss the syntax of a &lt;code&gt;for&lt;/code&gt; loop or how to read a sequence of numbers,
but you may not show, share, or review solution code with another student currently enrolled in COS 126.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Course materials.&lt;/strong&gt;
The course materials are sufficient to succeed in COS 126.
They include the textbook and companion booksite, the course website, lecture slides, and precepts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using outside resources.&lt;/strong&gt;
You may use outside resources to clarify lecture, reading, precept, and past-exam material.
If you learn a technique from an external source and apply it on an assignment,
it must be within the scope of the course, and you must cite the source in &lt;code&gt;acknowledgments.txt&lt;/code&gt;.
Be cautious with AI-integrated tools: they may produce inaccurate, incomplete, or out-of-scope guidance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Permitted resources for assignments.&lt;/strong&gt;
Once you start a programming assignment, you may use only course-approved resources.
“Starting” includes reading the specification; downloading the project files; and any design, coding, debugging, or testing.&lt;/p&gt;
&lt;!-- As a result, you may not use outside resources such as web search, online videos, or generative AI. --&gt;
&lt;p&gt;&lt;strong&gt;Collaboration with generative AI (GAI).&lt;/strong&gt;
You may not use generative AI for any part of a graded assessment in this course (programming assignments, the project, or exams). This includes using GAI to summarize specifications, generate solution ideas, write code, debug, add comments, or format work.
This prohibition applies to general-purpose AI systems (e.g., ChatGPT, Gemini, and Claude), AI coding assistants (e.g., Copilot, Cursor, and JetBrains Assistant), and AI-assisted web search.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Rationale&lt;/em&gt;: A core learning outcome of COS 126 is developing your own problem-solving and programming skills.
GAI can be helpful in many settings, but you must be able to reason about code and evaluate correctness independently.
These skills are essential regardless of your major and will prepare you to use AI tools responsibly in later coursework and beyond.&lt;/p&gt;
&lt;p&gt;If you are unsure whether a tool or use case is permitted, ask the course staff before using it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Your solutions.&lt;/strong&gt;
You must compose your solutions independently. “Solutions” includes everything you create for a graded assessment, including source code (and comments) and &lt;code&gt;readme.txt&lt;/code&gt;. It includes both draft and final work, whether correct or complete.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You may not share, expose, or make your solutions accessible to anyone who is taking COS 126 now or might take it in the future. Do not post solutions publicly (e.g., on a website or public repository), and do not leave printouts or files in shared locations. If you step away from your computer, lock it.&lt;/li&gt;
&lt;li&gt;You may not access any solutions other than your own. This includes other students’ work, solutions found online, and code produced by Generative AI tools.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These rules remain in effect after the semester ends.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Collaboration with course staff.&lt;/strong&gt;
You may discuss your solutions  with course staff (instructors and preceptors) during office hours or via private Ed posts. Do not post code on Ed or email us code. If we need to review your program, submit it on &lt;em&gt;TigerFile&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Collaboration with COS 126 classmates.&lt;/strong&gt;
You are encouraged to discuss general concepts with classmates, either privately or on Ed. Keep these discussions at a general
level and do not share, view, or review assignment solutions. If a classmate helps you, they must not look at their own solution while doing so.&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;For example, you may discuss:&lt;/th&gt;
          &lt;th&gt;But, you may not:&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;How to interpret an error message. For example, &amp;ldquo;What does &lt;code&gt;StackOverflowError&lt;/code&gt; mean?&amp;rdquo;&lt;/td&gt;
          &lt;td&gt;Access a classmate&amp;rsquo;s solutions (or allow a classmate to access your solutions).&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;The meaning of a piece of Java syntax. For example, &amp;ldquo;What is the purpose of the clause &lt;code&gt;Queue&amp;lt;String&amp;gt;&lt;/code&gt;&amp;rdquo;?&lt;/td&gt;
          &lt;td&gt;Lead a classmate step-by-step through any part of the assignment (or allow a classmate to do the same for you).&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;How to use a feature in IntelliJ or bash. For example, &amp;ldquo;How do I start the embedded terminal?&amp;rdquo;&lt;/td&gt;
          &lt;td&gt;Refer to your solutions while helping a classmate (or receive help from a classmate while they are referring to their solutions).&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Clarifications for the lectures, textbook, or assignment specifications.&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Solutions to book/booksite/precept exercises or old exam questions.&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Collaboration with students who have already taken COS 126.&lt;/strong&gt;
Anyone who successfully completed COS 126 in a prior term, including lab TAs and peer tutors, may assist you under the following rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They must not look at any other solutions, including their own, while helping you.&lt;/li&gt;
&lt;li&gt;They may look at your code.&lt;/li&gt;
&lt;li&gt;They must not write, type, or dictate code.&lt;/li&gt;
&lt;li&gt;They may help you debug, but they must not provide step-by-step directions for completing the assignment.&lt;/li&gt;
&lt;li&gt;They should offer high-level, thought-provoking suggestions rather than telling you exactly what to change.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Collaboration acknowledgment.&lt;/strong&gt; You must acknowledge all collaboration in &lt;code&gt;acknowledgments.txt&lt;/code&gt;.
Include the names and dates of any lab TAs, instructors, preceptors, and/or students who provided assistance.
Also cite any outside resources you used.&lt;/p&gt;
&lt;h3 id=&#34;partners&#34;&gt;Collaboration with a partner&lt;/h3&gt;
&lt;p&gt;Some assignments permit partnering. You are not required to partner, but we strongly recommend partnering on at least one partnered assignment. Pair programming helps you communicate about code, catch mistakes earlier, and often makes the work more efficient and less frustrating.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Group size.&lt;/strong&gt; At most two partners per group.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Eligibility.&lt;/strong&gt; Your partner must be a current COS 126 student (not necessarily in your precept).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Choosing a partner.&lt;/strong&gt; The best experience is usually with a similarly skilled partner.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Switching partners.&lt;/strong&gt; You may change partners between assignments.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Work together.&lt;/strong&gt; Complete all work together while sharing one screen, including design, coding, debugging, testing, commenting, writing &lt;code&gt;readme.txt&lt;/code&gt; and &lt;code&gt;acknowledgments.txt&lt;/code&gt;, and submitting files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No splitting.&lt;/strong&gt; You may not divide tasks or work separately.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Help sessions.&lt;/strong&gt; Attend office hours or the COS Lab together.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pair-programming protocol.&lt;/strong&gt; Use driver/navigator roles: the driver types; the navigator reviews, asks questions, and spots bugs. Swap roles about every 30 minutes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Protect your work.&lt;/strong&gt; Do not store or share code in a way that is accessible to anyone other than you and your partner. Shared private storage (e.g., Google Drive or Dropbox) is allowed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Late days.&lt;/strong&gt; Late penalties apply to the group. The number of waived late days available to the group is the minimum remaining among the partners.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Acknowledgment.&lt;/strong&gt; In &lt;code&gt;acknowledgments.txt&lt;/code&gt;, both partners must state that they followed the partnering rules.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ending a partnership.&lt;/strong&gt; To dissolve a partnership, contact the course administrator.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- - **Keep copies.** Both partners should keep copies of your final submissions. --&gt;
&lt;h3 id=&#34;plagiarism&#34;&gt;Plagiarism&lt;/h3&gt;
&lt;p&gt;Plagiarism and abetting plagiarism are serious academic violations.
Programming is a creative work, and the standards that apply to plagiarized prose also apply to plagiarized code.
Princeton&amp;rsquo;s &lt;a href=&#34;https://rrr.princeton.edu/students-and-university/24-academic-regulations&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Rights, Rules, Responsibilities&lt;/a&gt;
defines plagiarism as using &amp;ldquo;&lt;em&gt;the use of any outside source without proper acknowledgment.&lt;/em&gt;&amp;rdquo;
This includes verbatim copying (e.g., copy-and-paste) and thorough paraphrasing (e.g., renaming variables or rearranging code).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Citations.&lt;/strong&gt;
If you copy or adapt any code, you must cite the source in &lt;code&gt;acknowledgments.txt&lt;/code&gt;.
A citation is not required for code taken directly from the assignment specification.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Plagiarism detection.&lt;/strong&gt;
We use software tools to flag submissions for review for potential plagiarism, including paraphrased code.
We compare each submission (including interim submissions) against a
database that includes submissions from this offering, prior offerings, and other sources. These checks may occur during the semester or after it
ends.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Penalties.&lt;/strong&gt;
We refer alleged academic violations (e.g., plagiarism, abetting plagiarism, and failure to disclose the use of generative AI)
to the &lt;a href=&#34;https://odus.princeton.edu/student-support-and-community-standards/community-standards/committee-discipline&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Faculty–Student Committee on Discipline&lt;/a&gt; (CoD).
We do not bring cases lightly, but we must keep the playing field fair for students who follow the rules.&lt;/p&gt;
&lt;p&gt;If you are found responsible, you will receive a zero on the assignment, along with any additional penalties imposed by the CoD.
Findings involving multiple assignments may result in more serious course penalties, including a failing course grade.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Regret clause.&lt;/strong&gt;
If you neglected to cite a source (or disclose the use of generative AI), you may update &lt;code&gt;acknowledgments.txt&lt;/code&gt;
at any time before Dean’s Date and notify the course staff.
If you used an unauthorized source, you will likely receive a zero on the assignment for violating course policy.
However, with proper acknowledgments, it is not plagiarism (or failure to disclose the use of generative AI),
and we will not refer the case to the CoD.
Once a CoD case has been submitted, the regret clause no longer applies.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>The Atomic Nature of Matter</title>
      <link>https://www.cs.princeton.edu/courses/archive/fall26/cos126/project/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://www.cs.princeton.edu/courses/archive/fall26/cos126/project/</guid>
      <description>&lt;p&gt;&lt;br&gt;&lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/atomic/atomic.zip&#34;&gt;Download project ZIP&lt;/a&gt;
 |  &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Atomic&#34;&gt;Submit to TigerFile&lt;/a&gt;
&lt;/p&gt;
&lt;!--&lt;p style=&#34;color:red;&#34;&gt;&lt;i class=&#39;fas fa-bell&#39; style=&#39;font-size:48px;color:red&#39;&gt;&lt;/i&gt;  This assignment has not been officially released yet and is subject to change!&lt;/p&gt;

--&gt;
&lt;h3 id=&#34;getting-started&#34;&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Review Section 2.4 in the textbook, especially the part on depth-first search.&lt;/li&gt;
&lt;li&gt;Download and unzip &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/atomic/atomic.zip&#34;&gt;atomic.zip&lt;/a&gt;
, then open the &lt;code&gt;atomic&lt;/code&gt; project in &lt;em&gt;IntelliJ&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;You make work with a partner on this project subject to these &lt;a href=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/syllabus/#partners&#34;&gt;partnering rules&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;historical-perspective&#34;&gt;&lt;strong&gt;Historical Perspective&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Atoms played a central role in 20th-century physics and chemistry, but before 1908 the reality of atoms and molecules
was not universally accepted. In 1827, the botanist Robert Brown observed the random, erratic motion of microscopic
particles suspended in fluid. This phenomenon later became known as &lt;em&gt;Brownian motion&lt;/em&gt;. Einstein hypothesized that the
motion arises from countless collisions with much smaller particles, namely atoms and molecules.&lt;/p&gt;
&lt;p&gt;In one of his 1905 “miracle year” papers, Einstein developed a quantitative theory of Brownian motion to help justify
the existence of atoms as real, finite entities. His theory gave experimentalists a way to estimate molecular
quantities using an ordinary microscope by observing the collective effect of many molecular collisions on a larger
immersed particle. In 1908, Jean-Baptiste Perrin validated Einstein’s kinetic theory experimentally,
providing direct evidence for the atomic nature of matter.
Perrin’s experiments also yielded one of the earliest estimates of Avogadro’s number.
For this work, he won the 1926 Nobel Prize in Physics.&lt;/p&gt;
&lt;h3 id=&#34;the-problem&#34;&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;In this project, you will reproduce a modern version of Perrin&amp;rsquo;s experiment.
Your job is greatly simplified because modern video and computer technology,
combined with your programming skills, makes it possible to measure and track
the motion of an immersed particle undergoing Brownian motion accurately.
We provide video microscopy data of polystyrene spheres (&lt;em&gt;beads&lt;/em&gt;) suspended in water.&lt;/p&gt;
&lt;p&gt;The project has three pats:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;identify&lt;/strong&gt; beads in each frame,&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;track beads&lt;/strong&gt; between consecutive frames to measure their displacements, and&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;analyze&lt;/strong&gt; the displacement data by fitting Einstein’s model and estimating Avogadro’s number.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;the-data&#34;&gt;&lt;strong&gt;The Data&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;We provide 10 datasets, collected by William Ryu using fluorescent imaging.
Each dataset is stored in a subdirectory named &lt;code&gt;run_1&lt;/code&gt; through &lt;code&gt;run_10&lt;/code&gt;
and contains a sequence of 200  640-by-480 color images named &lt;code&gt;frame00000.jpg&lt;/code&gt; through &lt;code&gt;frame00199.jpg&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Here is a movie of several beads undergoing Brownian motion.&lt;/p&gt;
&lt;video class=&#34;video-shortcode&#34;  controls  width=ZgotmplZ poster=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/atomic/images/beads.jpg&#34;&gt;
    &lt;source src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/atomic/videos/atomic.webm&#34; type=&#34;video/webm&#34;&gt;
    There should have been a video here but your browser does not seem
    to support it.
&lt;/video&gt;

&lt;p&gt;Below is a typical raw image (left) and a cleaned up version (right) produced by thresholding, as described below.&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;















&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/atomic/images/beads.jpg&#34; alt=&#34;frame of polystyrene spheres immersed in water&#34; loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;















&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://www.cs.princeton.edu/courses/archive/fall26/cos126/static/assignments/atomic/images/beads-threshold.jpg&#34; alt=&#34;threshold frame of polystyrene spheres immersed in water&#34; loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Each image shows a two-dimensional cross section of a microscope slide.
The beads move within the the microscope&amp;rsquo;s field of view (the $x$- and $y$-directions).
They also move in the $z$-direction, entering and leaving the microscope&amp;rsquo;s depth of focus.
As a result, beads may appear with halos or disappear from the image entirely.&lt;/p&gt;
&lt;h3 id=&#34;i-particle-identification&#34;&gt;&lt;strong&gt;I. Particle Identification&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Your first task is to identify beads in noisy images. Each image is 640-by-480 pixels.
Each pixel is a &lt;code&gt;Color&lt;/code&gt; object; convert it to a luminance (intensity)
value between 0.0 (black) and 255.0 (white).&lt;/p&gt;
&lt;p&gt;Whiter pixels correspond to beads (foreground) and darker pixels to water (background).
The task has three steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Reading the image.&lt;/em&gt;
Use the &lt;a href=&#34;http://introcs.cs.princeton.edu/java/stdlib/javadoc/Picture.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Picture&lt;/a&gt; data type
to read the image.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Classifying the pixels as foreground or background.&lt;/em&gt;
Use &lt;em&gt;thresholding&lt;/em&gt; to separate foreground from background: pixels with luminance strictly below
a threshold $\tau$ are background; all others are foreground.
The example images above use $\tau = 180.0$.
Use the &lt;code&gt;intensity()&lt;/code&gt; method from
&lt;a href=&#34;https://introcs.cs.princeton.edu/31datatype/Luminance.java.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Luminance.java&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Finding the beads.&lt;/em&gt;
A bead appears as a roughly disc-shaped region of at least $min$ connected foreground pixels
(typically 25). A &lt;em&gt;blob&lt;/em&gt; (connected component) is a maximal set of connected foreground pixels,
regardless of shape.
We call any blob with at least $min$ pixels a &lt;em&gt;bead&lt;/em&gt;.
The &lt;em&gt;center of mass&lt;/em&gt; of a blob is the average of the $x$- and $y$-coordinates of its pixels.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Create a helper data type &lt;code&gt;Blob&lt;/code&gt; that has the following API.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;       &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Blob&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Creates an empty blob.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;Blob&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;                          
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Adds pixel (x, y) to this blob.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;y&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;          
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Returns the number of pixels in this blob.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;mass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;                      
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Euclidean distance between the centers of mass of the two blobs.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;distanceTo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Blob&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;that&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;    
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Returns a string representation of this blob (see below).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;toString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;               
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Tests this class by calling all instance methods directly.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;	&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here are some details about the required behavior:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Coordinates.&lt;/strong&gt; In this API, $x$ is the column index and $y$ is the row index.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Center of mass.&lt;/strong&gt; The center of mass is the average of the pixels&amp;rsquo; $x$- and $y$-coordinates.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;String representation.&lt;/strong&gt; The &lt;code&gt;toString()&lt;/code&gt; method returns a string that contains, in order:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the blob&amp;rsquo;s mass,&lt;/li&gt;
&lt;li&gt;one space character,&lt;/li&gt;
&lt;li&gt;the center of mass in the form $(x, y)$&lt;/li&gt;
&lt;li&gt;$x$ and $y$ formatted with four digits after the decimal point.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performance requirement.&lt;/strong&gt; The constructor and each instance method must run in constant time.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Next, implement a data type &lt;code&gt;BeadFinder&lt;/code&gt; with the following API.
Use &lt;em&gt;depth-first search&lt;/em&gt; to find connected components (blobs) in the thresholded
image efficiently.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;BeadFinder&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Finds all blobs in the given picture using luminance threshold tau.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;BeadFinder&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Picture&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;picture&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;tau&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Returns all beads (blobs with &amp;gt;= min pixels).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Blob&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;getBeads&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;min&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//  Test client (see below).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;static&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;main()&lt;/code&gt; method takes three command-line arguments:
an integer &lt;code&gt;min&lt;/code&gt;, a floating-point number &lt;code&gt;tau&lt;/code&gt;, and an image filename.
It constructs a &lt;code&gt;BeadFinder&lt;/code&gt; with threshold &lt;code&gt;tau&lt;/code&gt;
and print all beads (blobs with at least &lt;code&gt;min&lt;/code&gt; pixels), as shown here:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs BeadFinder 0 180.0 run_1/frame00001.jpg&lt;/span&gt;
29 (214.7241,  82.8276)
36 (223.6111, 116.6667)
 1 (254.0000, 223.0000)
42 (260.2381, 234.8571)
35 (266.0286, 315.7143)
31 (286.5806, 355.4516)
37 (299.0541, 399.1351)
35 (310.5143, 214.6000)
31 (370.9355, 365.4194)
28 (393.5000, 144.2143)
27 (431.2593, 380.4074)
36 (477.8611,  49.3889)
38 (521.7105, 445.8421)
35 (588.5714, 402.1143)
13 (638.1538, 155.0000)

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs BeadFinder 25 180.0 run_1/frame00001.jpg&lt;/span&gt;
29 (214.7241,  82.8276)
36 (223.6111, 116.6667)
42 (260.2381, 234.8571)
35 (266.0286, 315.7143)
31 (286.5806, 355.4516)
37 (299.0541, 399.1351)
35 (310.5143, 214.6000)
31 (370.9355, 365.4194)
28 (393.5000, 144.2143)
27 (431.2593, 380.4074)
36 (477.8611,  49.3889)
38 (521.7105, 445.8421)
35 (588.5714, 402.1143)
&lt;/pre&gt;

&lt;p&gt;In the sample frame, there are 15 blobs, 13 of which are beads.&lt;/p&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I assume the image dimensions are all 640-by-480?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No, your solution should handle images of any dimension.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;My program prints the same beads, but in a different order. Is that okay?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Yes. The output order depends on how you store blobs and how you traverse the image
(row-major vs. column-major).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What are the conventions for pixels in a &lt;code&gt;Picture&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;By convention, pixels are indexed by $(col, row)$. The first
argument to &lt;code&gt;get()&lt;/code&gt; is the column (increasing left-to-right)
and the second is the row (increasing top-to-bottom).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;ii-particle-tracking&#34;&gt;&lt;strong&gt;II. Particle Tracking&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;The next step is to determine how far a bead moves time $t$ to time $t + \Delta t$.
For our data, $\Delta t = 0.5$ seconds between frames.
Assume each bead moves only a small amount between frames and that beads never collide.
Beads may disappear between frames by leaving the field of view ($x$ or $y$)
or by moving out of focus ($z$).&lt;/p&gt;
&lt;p&gt;To track beads between consecutive frames, do the following:
for each bead at time $t + \Delta t$, find
the closest bead at time $t$ (Euclidean distance) and treat the pair as the same bead.
If the distance exceeds $\Delta$ pixels, assume that one of the beads has
either just appeared or just disappeared.&lt;/p&gt;
&lt;p&gt;Next, write &lt;code&gt;BeadTracker.java&lt;/code&gt; with a &lt;code&gt;main()&lt;/code&gt; method:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Read &lt;code&gt;min&lt;/code&gt;, &lt;code&gt;tau&lt;/code&gt;, &lt;code&gt;delta&lt;/code&gt;, and the image filenames from the command line.&lt;/li&gt;
&lt;li&gt;For each pair of consecutive frames, identify beads in both images using &lt;code&gt;BeadFinder&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Print each displacement (distance moved) that is at most &lt;code&gt;delta&lt;/code&gt;,
formatted with four digits after the decimal point, one per line, in the order discovered.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs BeadTracker 25 180.0 25.0 run_1/*.jpg&lt;/span&gt;
7.1833
4.7932
2.1693
5.5287
5.4292
4.3962
...
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Do I need to track individual beads across multiple frames?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;No. Although tracking beads across many frames can be more accurate,
this assignment only requires comparing beads in two consecutive frames.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;iii-data-analysis&#34;&gt;&lt;strong&gt;III. Data Analysis&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Einstein&amp;rsquo;s theory of Brownian motion links microscopic bead properties
(such as radius and diffusivity) to macroscopic fluid properties (such as temperature and viscosity).
Using video microscopy, we can estimate Avogadro’s number by observing the
collective effect of many water molecules on a bead.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Estimating the self-diffusion constant.&lt;/strong&gt; The self-diffusion constant $D$
describes the random motion of a bead in water due to thermal collisions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Model.&lt;/strong&gt; In one dimension, the Einstein–Smoluchowski equation implies that
a bead’s displacement over time $\Delta t$ has mean $0$ and variance $\sigma^2 = 2 D \Delta t$.&lt;/li&gt;
&lt;/ul&gt;
  &lt;!-- approximately Gaussian distribution, but we don&#39;t use this fact --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Estimation.&lt;/strong&gt; Estimate $\sigma^2$ by averaging the squared displacements in the
$x$- and $y$-directions.
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Let $(\Delta x_1, \Delta y_1), \ldots, (\Delta x_n, \Delta y_n)$ be the $n$ observed displacements (in pixels).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Convert pixels to meters: &lt;code&gt;BeadTracker&lt;/code&gt; reports pixels, but the formula uses meters.
To convert pixels to meters, multiply by $0.175 \times 10^{-6}$ (meters per pixel).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Let $r_1, \ldots, r_n$ denote the radial displacements.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;$ \sigma^2 \; =  \; \dfrac{(\Delta x^2_1+ \cdots + \Delta x^2_n) + (\Delta y^2_1+\cdots+\Delta y^2_n)}{2n}
\; = \; \dfrac{r^2_1+\cdots+r^2_n}{2n} $&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For our data, $\Delta t = 0.5$, so $D \approx \sigma^2$.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Estimating the Boltzmann constant.&lt;/strong&gt;
The Boltzmann constant $k$ is a fundamental physical constant that relates
a molecule&amp;rsquo;s average kinetic energy to its temperature.
The Stokes–Einstein relation
$$D = \dfrac{k\, T}{6 \, \pi \, \eta \, \rho}.$$
expresses the self-diffusion constant $D$ of a spherical bead in terms of $k$,
the temperature $T$, the viscosity $\eta$, and the bead radius $\rho$.
For our data:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$T = 297 \text{K}$,&lt;/li&gt;
&lt;li&gt;$\eta =  9.135 \times 10^{-4} \;  \text{N} \cdot \text{s} \cdot \text{m}^{-2}$, and&lt;/li&gt;
&lt;li&gt;$\rho = 0.5 \times 10^{-6} \text{m}$.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Solve the Stokes–Einstein equation for $k$ using your estimate of $D$.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Estimating Avogadro&amp;rsquo;s number.&lt;/strong&gt; Avogadro&amp;rsquo;s number $N_A$ is the number of particles in one mole.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Since $k = R / N_A$, we have $N_A = R / k$,
where $R \approx 8.31446 J \cdot \text{mol}^{-1} \cdot \text{K}^{-1}$ is the universal gas constant.&lt;/li&gt;
&lt;li&gt;Use $R / k$ as your estimate of Avogadro&amp;rsquo;s number $N_A$.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Write Avogadro.java.&lt;/strong&gt; For the final part, write &lt;code&gt;Avogadro.java&lt;/code&gt; with a &lt;code&gt;main()&lt;/code&gt; method that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;reads the radial displacements $r_1, r_2, r_3, \ldots$ from standard input;&lt;/li&gt;
&lt;li&gt;estimates Boltzmann&amp;rsquo;s constant $k$ and Avogadro&amp;rsquo;s number $N_A$ using the formulas above; and&lt;/li&gt;
&lt;li&gt;prints $k$ and $N_A$ in scientific notation with four digits after the decimal point.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are a few sample executions. Your output should match exactly, including formatting:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;more displacements-run_1.txt&lt;/span&gt;
 7.1833
 4.7932
 2.1693
 5.5287
 5.4292
 4.3962
...

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs Avogadro &amp;lt; displacements-run_1.txt&lt;/span&gt;
Boltzmann = 1.2535e-23
Avogadro  = 6.6329e+23

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs BeadTracker 25 180.0 25.0 run_1/*.jpg | java-introcs Avogadro&lt;/span&gt;
Boltzmann = 1.2535e-23
Avogadro  = 6.6329e+23
&lt;/pre&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Do I need to worry about converting units?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;All parameters are given in &lt;a href=&#34;https://en.wikipedia.org/wiki/International_System_of_Units&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;SI units&lt;/a&gt;.
The only conversion you need to do is from pixels to meters, as described above.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;My output matches the reference output, except sometimes they are off by 0.0001. Why could cause this?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It is likely a combination of floating-point roundoff error and printing only 4 digits after the decimal point.
For example, this discrepancy can arise if one solution computes the value 0.12345 (which gets rounded up to 0.1235)
and another computes the value 0.1234499999999 (which gets rounded down to 0.1234).
You need not worry about such discrepancies on this assignment.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Can I use Java&amp;rsquo;s built-in libraries?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;You are free to use and of the libraries introduced in the course,
including &lt;code&gt;java.util.ArrayList&lt;/code&gt;.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;possible-progress-steps&#34;&gt;&lt;strong&gt;Possible Progress Steps&lt;/strong&gt;&lt;/h3&gt;
&lt;details&gt;
  &lt;summary&gt;Click here to show possible progress steps for Blob&lt;/summary&gt;
  &lt;ol&gt;
&lt;li&gt;Observe that each directory &lt;code&gt;run_1&lt;/code&gt;, &lt;code&gt;run_2&lt;/code&gt;, &amp;hellip;, &lt;code&gt;run_9&lt;/code&gt; contains a sequence of 200 JPEG images. In total, these data files consume 70MB of space. The file &lt;code&gt;beads-run_1.txt&lt;/code&gt; lists the beads found in each frame of &lt;code&gt;run_1&lt;/code&gt; (using tau = 180.0 and min = 25). The files &lt;code&gt;displacements-run_1.txt&lt;/code&gt; and &lt;code&gt;displacements-run_2.txt&lt;/code&gt; are the output of &lt;code&gt;BeadTracker&lt;/code&gt; for those runs.&lt;/li&gt;
&lt;li&gt;Implement the &lt;code&gt;Blob&lt;/code&gt; data type. Do not store all of the individual pixels that comprise a blob; instead, store three values. Two alternatives are:
&lt;ul&gt;
&lt;li&gt;number of pixels, $x$-coordinate center of mass, and \(y\)-coordinate center of mass or&lt;/li&gt;
&lt;li&gt;number of pixels, sum of \(x\)-coordinates, and sum of \(y\)-coordinates needed to compute the center of mass.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Recall the &lt;code&gt;main()&lt;/code&gt; method is used to write your &lt;em&gt;test client&lt;/em&gt;. This is where you should thoroughly test your &lt;code&gt;Blob&lt;/code&gt; implementation.  For example, create various &lt;code&gt;Blob&lt;/code&gt; objects and call the various &lt;code&gt;Blob&lt;/code&gt; methods on these objects.&lt;/li&gt;
&lt;li&gt;Some FAQs:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;How can I implement the &lt;code&gt;toString()&lt;/code&gt; method to format the numbers?&lt;/strong&gt; Use &lt;code&gt;String.format()&lt;/code&gt;. It works like &lt;code&gt;StdOut.printf()&lt;/code&gt;, but returns the resulting string instead of printing it. See pp. 130–132 of the textbook to learn more about formatted printing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Which value should &lt;code&gt;distanceTo()&lt;/code&gt; return if the mass of one or both blobs is zero?&lt;/strong&gt; We recommend &lt;code&gt;Double.NaN&lt;/code&gt;. Since this corner case is not specified in the API, we will not test it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What should &lt;code&gt;toString()&lt;/code&gt; return if the mass is zero?&lt;/strong&gt; We recommend returning the value &lt;code&gt;&amp;quot;0 (NaN, NaN)&amp;quot;&lt;/code&gt;. Since this corner case is not specified in the API, we will not test it.&lt;/li&gt;
&lt;/ul&gt;

&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;Click here to show possible progress steps for BeadFinder&lt;/summary&gt;
  &lt;ol&gt;
&lt;li&gt;This is the most challenging code to implement.&lt;/li&gt;
&lt;li&gt;Review Section 2.4 in the textbook, especially the part on depth-first search. Finding all the pixels in a blob is similar to finding a percolating path.&lt;/li&gt;
&lt;li&gt;Write the constructor to find all of the blobs and initialize the instance variables. Most of the work for the &lt;code&gt;BeadFinder&lt;/code&gt; data type will be here.&lt;/li&gt;
&lt;li&gt;The crux of this part is to write a &lt;em&gt;private&lt;/em&gt; recursive method &lt;code&gt;dfs()&lt;/code&gt; that locates all of the foreground pixels in the same blob as the foreground pixel &lt;em&gt;(x, y)&lt;/em&gt;. To do this, use &lt;em&gt;depth-first search&lt;/em&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Mark pixel &lt;em&gt;(x, y)&lt;/em&gt; as in the current blob.&lt;/li&gt;
&lt;li&gt;Then recursively mark all of its foreground neighbors as in the current blob (but do not recur if the pixel has previously been marked or the pixel indices are out-of-bounds).&lt;/li&gt;
&lt;li&gt;&lt;em&gt;It is up to you to decide which arguments would be useful for the &lt;code&gt;dfs()&lt;/code&gt; method.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;The constructor should call &lt;code&gt;dfs()&lt;/code&gt; from each unmarked pixel &lt;em&gt;(x, y)&lt;/em&gt;. All of the pixels encountered during a single call to &lt;code&gt;dfs()&lt;/code&gt; comprise one blob.&lt;/li&gt;
&lt;li&gt;Next, implement the method &lt;code&gt;getBeads(int min)&lt;/code&gt; that searches through the blobs and stores all of the beads (blobs that contain at least the specified number of pixels) in a &lt;code&gt;Blob&lt;/code&gt; array. The length of the array should be equal to the number of beads. To determine the number of beads, you may find it helpful to implement a private method &lt;code&gt;countBeads(int min)&lt;/code&gt; that counts and returns the number of beads.&lt;/li&gt;
&lt;li&gt;Implement a &lt;code&gt;main()&lt;/code&gt; method that takes as command-line arguments &lt;code&gt;min&lt;/code&gt;, &lt;code&gt;tau&lt;/code&gt;, and the name of a JPEG file. The &lt;code&gt;main(&lt;/code&gt;) method prints the list of beads.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;5&#34;&gt;
&lt;li&gt;Some FAQs:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Can I assume that the dimensions of all of the images are 640-by-480 pixels?&lt;/strong&gt; No, do not hardwire these constants into your program. Use &lt;code&gt;picture.width()&lt;/code&gt; and &lt;code&gt;picture.height()&lt;/code&gt; for the width and height, respectively.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;To compute the luminance of a pixel:&lt;/strong&gt; First, get the &lt;code&gt;Color&lt;/code&gt; value of that pixel. Then, use the appropriate method in &lt;a href=&#34;https://introcs.cs.princeton.edu/31datatype/Luminance.java.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Luminance.java&lt;/a&gt; (Program 3.1.3) to get the luminance value for that color.  There is no need to copy this code.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Are diagonal pixels  &lt;em&gt;not&lt;/em&gt; considered adjacent?&lt;/strong&gt;  Use only the four ordinal neighbors (north, east, south, and west).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Must I print the beads and displacements in the same order as shown in the assignment specification?&lt;/strong&gt; No, the order is not specified.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;6&#34;&gt;
&lt;li&gt;Testing:  The initial description of &lt;code&gt;BeadFinder&lt;/code&gt; shows the output from running &lt;code&gt;BeadFinder&lt;/code&gt; with &lt;code&gt;run_1/frame00001.jpg&lt;/code&gt;. Note that the order in which you print the beads is not important. Here are the results for &lt;code&gt;run_1/frame00000.jpg&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadFinder 0 180.0 run_1/frame00000.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   37 (220.0270, 122.8919)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   1 (254.0000, 223.0000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   17 (255.4118, 233.8824)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   23 (265.8261, 316.4348)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   36 (297.8333, 394.5000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   39 (312.3077, 215.8205)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   23 (373.0000, 357.1739)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   19 (390.8421, 144.8421)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   31 (433.7742, 375.4839)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   32 (475.5000,  44.5000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   31 (525.2903, 443.2903)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   24 (591.0000, 399.5000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   35 (632.7714, 154.5714)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadFinder 25 180.0 run_1/frame00000.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   37 (220.0270, 122.8919)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   36 (297.8333, 394.5000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   39 (312.3077, 215.8205)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   31 (433.7742, 375.4839)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   32 (475.5000,  44.5000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   31 (525.2903, 443.2903)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   35 (632.7714, 154.5714)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs BeadFinder 0 180.0 run_6/frame00010.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    1 ( 25.0000, 373.0000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    1 ( 26.0000, 372.0000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    1 ( 27.0000, 373.0000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    1 ( 29.0000, 369.0000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   63 ( 34.2063,  32.3175)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    9 ( 97.0000, 341.0000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   65 (141.4615,  54.0615)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   70 (165.8571, 165.2857)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   60 (173.5667, 200.5333)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   50 (198.7000, 113.0200)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    1 (254.0000, 223.0000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   89 (276.9101, 306.6629)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   24 (296.3750,  82.9583)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   62 (306.6774, 474.6774)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   59 (339.1356,  81.5932)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   68 (358.9706, 159.0588)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   40 (397.0750,  39.2000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   86 (573.3488, 427.0581)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   51 (611.7451, 143.8235)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   53 (636.1132, 230.6038)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   14 (634.5000, 421.7143)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   26 (636.5000,  35.0000)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadFinder 25 180.0 run_6/frame00010.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   63 ( 34.2063,  32.3175)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   65 (141.4615,  54.0615)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   70 (165.8571, 165.2857)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   60 (173.5667, 200.5333)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   50 (198.7000, 113.0200)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   89 (276.9101, 306.6629)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   62 (306.6774, 474.6774)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   59 (339.1356,  81.5932)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   68 (358.9706, 159.0588)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   40 (397.0750,  39.2000)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   86 (573.3488, 427.0581)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   51 (611.7451, 143.8235)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   53 (636.1132, 230.6038)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   26 (636.5000,  35.0000)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;Click here to show possible progress steps for BeadTracker&lt;/summary&gt;
  &lt;ol&gt;
&lt;li&gt;The &lt;code&gt;main()&lt;/code&gt; method in &lt;code&gt;BeadTracker&lt;/code&gt; takes an arbitrary number of command-line arguments, &lt;code&gt;args[0]&lt;/code&gt;, &lt;code&gt;args[1]&lt;/code&gt;, and so forth.&lt;/li&gt;
&lt;li&gt;You need to consider only two frames at a time, so &lt;strong&gt;do not&lt;/strong&gt; store all of the frames at the same time.&lt;/li&gt;
&lt;li&gt;Use the &lt;a href=&#34;http://introcs.cs.princeton.edu/java/stdlib/javadoc/Picture.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Picture&lt;/a&gt; data type to read a JPEG file.&lt;/li&gt;
&lt;li&gt;Some FAQs&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What should I do if several of the beads in frame &lt;code&gt;t+1&lt;/code&gt; have the same bead in frame &lt;code&gt;t&lt;/code&gt; as their closest bead?&lt;/strong&gt; That happens only rarely, so you should not worry about it—just let the bead in frame &lt;code&gt;t&lt;/code&gt; get paired a second time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;I am able to find beads and blobs correctly, but my &lt;code&gt;BeadTracker&lt;/code&gt; gives a few errors, despite that it is mostly working. Why could this be?&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;Check that, for each bead in frame &lt;code&gt;t + 1&lt;/code&gt;, you are finding the closest bead in frame &lt;code&gt;t&lt;/code&gt;, and not vice versa.&lt;/li&gt;
&lt;li&gt;Be sure to discard distances greater than &lt;em&gt;delta&lt;/em&gt;, not greater than or equal to &lt;em&gt;delta&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Why do I have to compare each bead in frame &lt;code&gt;t + 1&lt;/code&gt; to each bead in frame &lt;code&gt;t&lt;/code&gt;? Why can&amp;rsquo;t I do it the other way around?&lt;/strong&gt; It is an arbitrary choice, but one that you must follow because it is prescribed in the assignment specification.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Can I assume that all of the runs consist of 200 frames?&lt;/strong&gt; No, do not hardwire &lt;code&gt;200&lt;/code&gt; into your program. Use &lt;code&gt;args.length&lt;/code&gt; for the number of command-line arguments.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How can I specify 200 image names on the command line?&lt;/strong&gt; Use the &lt;em&gt;wildcard&lt;/em&gt; capability of the terminal. For example, the following specifies (in alphabetical order) all &lt;code&gt;.jpg&lt;/code&gt; files in the &lt;code&gt;run_1&lt;/code&gt; directory.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadTracker 25 180.0 25.0 run_1/*.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;5&#34;&gt;
&lt;li&gt;Testing: For reference, &lt;code&gt;displacements-run_1.txt&lt;/code&gt;, &lt;code&gt;displacements-run_2.txt&lt;/code&gt;, and &lt;code&gt;displacements-run_6.txt&lt;/code&gt; contain a list of all of the displacements (using &lt;em&gt;tau&lt;/em&gt; = 180.0 and &lt;em&gt;min&lt;/em&gt; = 25) for &lt;code&gt;run_1&lt;/code&gt;, &lt;code&gt;run_2&lt;/code&gt;, and &lt;code&gt;run_6&lt;/code&gt;, respectively. They were obtained by running&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadTracker 25 180.0 25.0 run_1/*.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   7.1833
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   4.7932
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   2.1693
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   5.5287
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   5.4292
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   4.3962
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   ...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadTracker 25 180.0 25.0 run_2/*.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   5.1818
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   7.6884
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   6.7860
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   6.4907
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   4.2102
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   1.1412
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   4.4724
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   7.5191
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   3.0659
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   4.4238
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   5.0600
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   1.7280
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   ...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadTracker 25 180.0 25.0 run_6/*.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   11.1876
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   12.4269
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   10.3113
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    1.3954
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    3.3196
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    0.4732
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    1.7367
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    3.0060
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    4.6087
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    1.3282
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;Click here to show possible progress steps for Avogadro&lt;/summary&gt;
  &lt;ol&gt;
&lt;li&gt;The &lt;code&gt;main()&lt;/code&gt; method in &lt;code&gt;Avogadro&lt;/code&gt; reads a sequence of floating-point numbers from standard input and prints the estimate of Avogadro&amp;rsquo;s number using the formulas provided in the assignment.&lt;/li&gt;
&lt;li&gt;To calculate \(σ^2\), use the second formula listed with radial displacements; these are the results from &lt;code&gt;BeadTracker&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Some FAQs:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;How accurate of an estimate should I get?&lt;/strong&gt; You should get within 10% or so of the exact value for Avogadro&amp;rsquo;s number \(6.022142 × 10^{23}\). The standard deviation of the radius of the beads is about 10%, so you should not expect results more accurate than this. Your output, however, should agree &lt;em&gt;exactly&lt;/em&gt; with ours.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;My physics is a bit rusty. Do I need to worry about converting units?&lt;/strong&gt; Not much, since all of the constants are in SI units. The only conversion you should need to do is to convert from distances measured in pixels (the radial displacements) to distances measured in meters, by using the conversion factor of \(0.175 × 10^{−6}\) meters per pixel.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Checkstyle complains about the variables &lt;code&gt;I&lt;/code&gt; named &lt;code&gt;T&lt;/code&gt; and &lt;code&gt;R&lt;/code&gt;. Which names should I use instead?&lt;/strong&gt; A constant variable (a variable whose value does not change during the execution of a program, or from one execution of the program to the next) should begin with an uppercase letter and use underscores to separate any word boundaries, such as &lt;code&gt;GRAVITATIONAL_CONSTANT&lt;/code&gt;. Constant variables should have more meaningful names, such as &lt;code&gt;TEMPERATURE&lt;/code&gt; or &lt;code&gt;GAS_CONSTANT&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;4&#34;&gt;
&lt;li&gt;Testing - below are the output for &lt;code&gt;displacements-run_1.txt&lt;/code&gt;, &lt;code&gt;displacements-run_2.txt&lt;/code&gt;, and &lt;code&gt;displacements-run_6.txt&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs Avogadro &amp;lt; displacements-run_1.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Boltzmann = 1.2535e-23
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Avogadro  = 6.6329e+23
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs Avogadro &amp;lt; displacements-run_2.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Boltzmann = 1.4200e-23
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Avogadro  = 5.8551e+23
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs Avogadro &amp;lt; displacements-run_6.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Boltzmann = 1.3482e-23
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Avogadro  = 6.1670e+23
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
  &lt;summary&gt;Click here to show possible progress steps for system testing&lt;/summary&gt;
  &lt;ol&gt;
&lt;li&gt;As a final test, combine the data collection (&lt;code&gt;BeadTracker&lt;/code&gt;) for &lt;code&gt;run_1&lt;/code&gt;, &lt;code&gt;run_2&lt;/code&gt;, and &lt;code&gt;run_6&lt;/code&gt; with the data analysis (&lt;code&gt;Avogadro&lt;/code&gt;). The data for &lt;code&gt;run_2&lt;/code&gt; contains light boundary pixels and &lt;code&gt;run_6&lt;/code&gt; contains pixels whose luminance is exactly 180.0.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadTracker 25 180.0 25.0 run_1/*.jpg | java-introcs Avogadro
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   Boltzmann = 1.2535e-23
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   Avogadro  = 6.6329e+23
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs BeadTracker 25 180.0 25.0 run_2/*.jpg | java-introcs Avogadro
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   Boltzmann = 1.4200e-23
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   Avogadro  = 5.8551e+23
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;java-introcs BeadTracker 25 180.0 25.0 run_6/*.jpg | java-introcs Avogadro
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   Boltzmann = 1.3482e-23
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   Avogadro  = 6.1670e+23
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;performance-analysis&#34;&gt;&lt;strong&gt;Performance Analysis&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Formulate a hypothesis for the running time (in seconds) of &lt;code&gt;BeadTracker&lt;/code&gt;
as a function of the input size $n$, where $n$ is the total number of pixels read
across all processed frames. Use a power-law model: $$ T(n) = a \, n^b.$$&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use the doubling hypothesis and justify your results with empirical data.
Provide data from at least three experiments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Report only numeric values for  $a$ and $b$.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Answer all questions in &lt;code&gt;readme.txt&lt;/code&gt;.&lt;/p&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How can I estimate the running time of &lt;code&gt;BeadTracker&lt;/code&gt;?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Use the &lt;a href=&#34;http://introcs.cs.princeton.edu/java/stdlib/javadoc/Stopwatch.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Stopwatch&lt;/a&gt; data type from Section 4.1.
Remember to remove it and any additional print statements from your submitted version of &lt;code&gt;BeadTracker.java&lt;/code&gt;.
When you execute &lt;code&gt;BeadTracker&lt;/code&gt;, &lt;em&gt;redirect the output to a file&lt;/em&gt; to avoid measuring the time to print the output
to the terminal.
Run &lt;code&gt;BeadTracker&lt;/code&gt; with a variety of input sizes which allow you to get good timing data and form a doubling hypothesis.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How can I run &lt;code&gt;BeadTracker&lt;/code&gt; with a variety of input sizes?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;All of the runs have 200 frames. However, when you are performing timing experiments,
you can simply use a subset of them. Use use the wildcard capability of the terminal
to run 10 frames, 20 frames, 40 frames, 80 frames, and 160 frames, as follows:&lt;/p&gt;
&lt;pre class=&#34;terminal&#34;&gt;
&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xint BeadTracker 25 180.0 25.0 run_1/frame000[0]*.jpg    &amp;gt; temp.txt&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xint BeadTracker 25 180.0 25.0 run_1/frame000[0-1]*.jpg  &amp;gt; temp.txt&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xint BeadTracker 25 180.0 25.0 run_1/frame000[0-3]*.jpg  &amp;gt; temp.txt&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xint BeadTracker 25 180.0 25.0 run_1/frame000[0-7]*.jpg  &amp;gt; temp.txt&lt;/span&gt;

&lt;span class=&#34;prompt&#34;&gt;~/Desktop/atomic&amp;gt;&lt;/span&gt; &lt;span class=&#34;command&#34;&gt;java-introcs -Xint BeadTracker 25 180.0 25.0 run_1/frame000*.jpg run_1/frame001[0-5]*.jpg &amp;gt; temp.txt&lt;/span&gt;

&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Do I need to use the &lt;code&gt;-Xint&lt;/code&gt; option?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;You can try your experiments with or without the &lt;code&gt;-Xint&lt;/code&gt; option.  Recall,
that &lt;code&gt;-Xint&lt;/code&gt; turns off Java optimization, so you may get clearer results when you use the doubling method.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How long should &lt;code&gt;BeadTracker&lt;/code&gt; take?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It depends on the speed of your computer, but processing 200 frames should take
about 10 seconds or less without the &lt;code&gt;-Xint&lt;/code&gt; option and about two minutes with the &lt;code&gt;-Xint&lt;/code&gt; option.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;How much memory should my program use?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;The reference solution uses less than 10 MB.
You will receive a deduction if you use substantially more. The most common
way to waste memory is to hold references to an array of &lt;code&gt;Picture&lt;/code&gt; objects in &lt;code&gt;BeadTracker&lt;/code&gt;
instead of only two at a time. You can use the &lt;code&gt;-Xmx&lt;/code&gt; option to
limit how much memory Java uses: for example, the following command limits the
memory available to Java to 10 MB.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs -Xint -Xmx10m BeadTracker &lt;span class=&#34;m&#34;&gt;25&lt;/span&gt; 180.0 25.0 run_1/*.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;When I test with a very small luminance threshold, I get a &lt;code&gt;StackOverflowError&lt;/code&gt;, but my code works for larger luminance thresholds. What does this mean?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;&lt;p&gt;Since DFS is recursive, it consumes memory proportional to the height of the function-call tree. If the luminance
threshold is small, the blobs can be very big, and the height of the function-call tree may be very large. We will not
test your program on inputs with such big blobs. If, however, you are determined to get it to work on such cases, use
the command-line option &lt;code&gt;-Xss20m&lt;/code&gt; to increase the stack space.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   java-introcs -Xint -Xss20m BeadTracker 25 18.0 25.0 run_1/*.jpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;h3 id=&#34;submission&#34;&gt;&lt;strong&gt;Submission.&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Upload all required files to &lt;a href=&#34;https://tigerfile.cs.princeton.edu/COS126_F2026/Atomic&#34;&gt;TigerFile&lt;/a&gt;
:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Blob.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BeadFinder.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BeadTracker.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Avogadro.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;acknowledgments.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Do not submit &lt;code&gt;stdlib.jar&lt;/code&gt;, &lt;code&gt;Luminance.java&lt;/code&gt;, &lt;code&gt;Stack.java&lt;/code&gt;, &lt;code&gt;Queue.java&lt;/code&gt;, or &lt;code&gt;ST.java&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;grading-breakdown&#34;&gt;&lt;strong&gt;Grading Breakdown&lt;/strong&gt;&lt;/h3&gt;
&lt;div class=&#34;md-table md-table-grading&#34;&gt;
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Files&lt;/th&gt;
          &lt;th&gt;Points&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;Blob.java&lt;/td&gt;
          &lt;td&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;BeadFinder.java&lt;/td&gt;
          &lt;td&gt;30&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;BeadTracker.java&lt;/td&gt;
          &lt;td&gt;20&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Avogadro.java&lt;/td&gt;
          &lt;td&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Analysis and readme.txt&lt;/td&gt;
          &lt;td&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td&gt;80&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&#34;enrichment&#34;&gt;&lt;strong&gt;Enrichment.&lt;/strong&gt;&lt;/h3&gt;
&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is polystyrene?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;It is an inexpensive plastic that is used in many everyday things including plastic forks, drinking cups, and the case
of your desktop computer. Styrofoam is a popular brand of polystyrene foam. Computational biologists use micron size
polystyrene beads (also known as microspheres and latex beads) to &lt;em&gt;capture&lt;/em&gt; a single DNA molecule, e.g., for a DNA
test.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;What is the history of measuring Avogadro&amp;rsquo;s number?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;In 1811, Avogadro hypothesized that the number of molecules in a liter of gas at a given temperature and pressure is
the same for all gases. Unfortunately, he was never able to determine this number that would later be named after him.
Johann Josef Loschmidt, an Austrian physicist, gave the first estimate for this number using the kinetic gas theory. In
1873 Maxwell estimated the number of be around \(4.3 × 10^{23}\); later Kelvin estimated it to be around \(5 ×
10^{23}\). Perrin gave the first &amp;ldquo;accurate&amp;rdquo; estimate (\(6.5–6.8 × 10^{23}\)) of, what he coined, Avogadro&amp;rsquo;s number.
The most accurate estimates for Avogadro&amp;rsquo;s number and Boltzmann&amp;rsquo;s constant are computed using x-ray crystallography:
Avogadro&amp;rsquo;s number is approximately \(6.022142 × 10^{23}\); Boltzmann&amp;rsquo;s constant is approximately \(1.3806503 ×
10^{−23}\).&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;details class=&#34;qa&#34;&gt;
  &lt;summary&gt;&lt;strong&gt;Q.&lt;/strong&gt;&lt;span class=&#34;qatxt&#34;&gt;Where can I learn more about Brownian motion?&lt;/span&gt;&lt;/summary&gt;
  &lt;div class=&#34;answer&#34;&gt;&lt;strong&gt;A.&lt;/strong&gt;&lt;div class=&#34;qatxt&#34;&gt;Here&amp;rsquo;s the &lt;a href=&#34;https://en.wikipedia.org/wiki/Brownian_motion&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Wikipedia entry&lt;/a&gt;. You can learn about the theory in ORF 309.
It may be the first subject you will be asked about if you interview on Wall Street.&lt;/div&gt;&lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;This assignment was created by David Botstein, Tamara Broderick, Ed Davisson, Daniel Marlow, William Ryu, and Kevin Wayne.&lt;/p&gt;
&lt;p&gt;Copyright © 2005-2026, &lt;a href=&#34;https://www.cs.princeton.edu/~wayne&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Kevin Wayne&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
