Skip to content

Practice Exam 1, Problem 4: Streaming with O(1) State

Midterm 1 practice exam, problem 4 of 5 · Length: 7:14 · Exercises: 12c_wc (Week 5), on the short reads of 11c_cat (Week 5) · Answer key: Solutions (PDF)

Worked on pages 14 to 16: (a) count_fd's state after each read; (b) what goes wrong when in_word moves inside the loop; (c) writing longest_line with one 512-byte buffer. The answer key's handwriting is written onto the exam page as each step is worked.

Download the video (MP4, 24 MB) · Captions (WebVTT) · All five problems