A4 — File system and data wrap-up

Revisit text encodings and file formats, and pretend to be a file system.

Due Sep 23, 2026

Estimated time to complete (just the assignment, excluding the prep materials): 1–1.5 hours.

Prep materials: Week 4: File system and data wrap-up

What to do

Submit all your answers to Assignment 4 Submission on Brightspace. You can use a text response field, a text file, or a Markdown file.

Part 1. Text

  1. The following stream of bytes represents some text encoded using either UTF-8 or UTF-32:

    F0 9F 93 9A F0 9F 93 96 4C 69 62 72 61 72 69 65 73 20 61 72 65 20 61 77 65 73 6F 6D 65 21 F0 9F 93 96
    1. In what base are these bytes represented? Why do you think so?

    2. Without asking AI about these specific byte values, how would you go about determining which encoding it is?

      Click here for a hint

      Review both encodings, consider the binary representation of the first few bytes, and consider the size of the encoded text.

    3. For this part, you can use AI to help you decode the bytes. Which text is encoded in the byte stream? How do you know that the result is correct?

    4. Do you think your approach for determining the encoding would work for any stream of bytes? Why or why not?

    5. Optional (ungraded): if you do not feel confident about converting between different bases, practice converting a few bytes to decimal and binary (you will need this for an exam).

  2. Use the Internet to find out how text editors decide which encoding to use when opening a text file. Describe your findings briefly. Were you surprised by what you learned? Why or why not? How does your approach from the previous question relate to this?

Part 2. Media

Pick a file format that was not covered in the prep materials (for example, .epub, .jpg, .png, .mp3, .mp4, .avi, etc.) and use the Internet to find out how it works.

Include the prompt that you’ve used to search for information about the file format, provide at least one source to verify the information, and summarize your findings in a few sentences. Some file formats are complex, and you do not need to understand everything about them.

Part 3. File system

This part is similar to the box storage challenge from class, but this time we will use a file system with blocks of bytes instead of slots of boxes.

Each block can hold 8 bytes, and the file system has 10 blocks in total. A block can only hold bytes of a single file.

File content is modified in the following order (the order matters!):

  • New file A: 7 bytes
  • New file B: 14 bytes
  • File A is extended by 5 bytes
  • File B is reduced by 10 bytes
  • New file C: 22 bytes
  1. For each of the 10 blocks, specify which file bytes it contains at the end of the modification sequence.

  2. Describe the corresponding “index card”, i.e., meta-information that the directory with those files would contain, such as the file and the blocks it occupies.

  3. Specify a possible outcome of the defragmentation process for this file system, i.e., how the blocks would be rearranged to make the files occupy contiguous blocks. Describe both the new block arrangement and the corresponding index card.

  4. How would the defragmentation process work for this example, step by step?

    Click here for a hint

    Consider the following block structure for blocks of 4 bytes:

    #1: A A A A
    #2: B B B _
    #3: A A A A
    #4: _ _ _ _

    To make A-bytes contiguous, we could copy B-bytes to #4 first, then copy A-bytes to #2. After that, we could also copy B-bytes to #3, and consider #4 to be empty.

Grading

Graded for correctness.