Progress Exam 3 — Lists and loops

First half of class. Open book; no AI, no collaboration, and no device but the lab computer. Lists in Java, while and for.

Monday, November 16, the first half of class. Fifty minutes, four problems, in Java.

How it works

In an exam seat, as Progress Exam 2 was. Four problems, a file each, in a seat of your own: an editor in the browser, already open, with Lst.java and Check.java beside your files.

  1. Open Brightspace in LockDown Browser and start the quiz Progress Exam 3.
  2. In its header, click open my seat. The seat’s README is the exam’s text, and each problem is the comment at the top of its file, Problem1.java to Problem4.java: your functions and their checks go under it, in the same file.
  3. Run, just above void main(), runs that file’s checks.
  4. The header’s second link, submit my files, sends everything in your seat to your repository. Press it whenever you like; the last one counts, and what is in your seat at the end is sent for you anyway.
  5. When you are done, submit the quiz: its Submit button is what closes LockDown Browser.

There is no countdown on the screen. The finish time is on the board. Your files save as you type, so you can go back to an earlier problem whenever you want.

Open book. This website, the textbook and Java’s documentation, which LockDown Browser lets you open, Java’s own error messages, and anything you bring on paper: notes, or printouts of your own files. The files on the lab computer cannot be opened from inside LockDown Browser, so print what you want to have.

No AI, no collaboration, and no device but the lab computer you take the exam on. Phones and laptops are put away until your exam is in. The course AI policy applies in full, and on an exam it is not negotiable. You work alone.

What it covers

Lists and loops: weeks 10 to 12 on the schedule, Classes 18 to 22, A9 to A11.

  • Week 10 — lists in Java: Lst, the arrow, and map, filter and fold.
  • Week 11 — while loops: the walk with todo, a loop that stops early, loops with no list behind them.
  • Week 12 — for loops, and a loop inside a loop, as far as Wednesday’s class reached.

In more detail:

  • Lists with Lst: Lst.of, the arrow, and Lst.filter, Lst.map and Lst.fold in one line each — Lists in Java.
  • Lists by hand: a switch with a case for Lst.Empty() and one for Lst.Link(var u, var rest), a function that calls itself on the rest, a list built one link at a time, and a helper that carries a value down the calls — Class 19.
  • while: the walk with todo, a loop with two names that change, a list that comes out backwards, a loop that stops early by its condition, by a return or by a break, and do — [CU] 6.1 — while Loops, Class 20 and Class 21.
  • for, as far as Wednesday’s class reached: the three lines in one header, a loop inside a loop, and map written by hand — [CU] 6.2 — for Loops and Class 22.

Not on it: arrays, ArrayList, and anything from before week 10 except as loops use it, such as ? :, && and records.

Style is graded, not just correctness

The syllabus says exams are “graded for both correctness and style”, as on the first two. Concretely, on this one:

  • Every function has a // line above it with a purpose statement.
  • Every function has at least two Check.is lines in main, worked out by you before the body, one of them at the edge: the empty list, or 0.
  • The form the problem asks for: one line with an arrow where it says one line, a switch with both cases and no default where it says by hand, a loop where it says a loop.
  • Names say what the thing holds.

A correct function with no checks does not get full marks. A function with good checks and a body you could not finish gets most of them. That is the same deal every assignment since A4 has offered, and it is deliberate.

Decide now what you will do if you run short. Go through all four problems and write the // line and the Check.is lines before you write any bodies. The deal above holds on every problem, and a problem you never open is the one that gets nothing.

Practice, and how to prepare

Rewrite one function from each of A9 and A10, in a new file, without looking at your old answer. Then write it the other way: the fold as a loop, the loop as a switch. Recognizing a solution and producing one are different skills, and only the second one is on the exam.

The in-class pages from Class 18 on have more: every function on them was written in the room, and each says when it is done. Lists in Java and Check.java are the two pages worth having open during the exam.

If something goes wrong

If a page in the seat says something you did not expect, put your hand up. Your files are safe in the seat whatever the page says.

Make-ups are covered by the syllabus: one per exam, voluntary, requested within a week of the grade going up. If you cannot be there on Monday, November 16, tell me before the day rather than after it.