Disk defragmentation utility

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Disk defragmentation utility

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does a defragmenter do to the pieces of a file on a hard disk drive?
A Joins them together in one contiguous block
B Deletes the pieces it does not need
2. A file is fragmented. What does this mean?
A Its pieces are scattered in different places on the disk
B Its data has been compressed to take up less space
3. Why does defragmenting a hard disk drive make file access faster?
A The read head does not have to jump around to find each piece
B The files become smaller so they load quicker
4. Which storage device benefits from defragmentation?
A Solid-state drive (SSD)
B Hard disk drive (HDD)
5. Why is a defragmenter not needed for an SSD?
A An SSD cannot store fragmented files at all
B An SSD has no moving parts, so scattered data is read just as fast

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1defragmenter Aif driveType == "SSD": skip defragmentation
2fragmented file BA utility that rearranges the scattered pieces of files on a hard disk drive so each file is stored together, which speeds up reading
3A defragmenter joins the pieces of each file into one contiguous block, so the file is stored together CA file whose pieces are stored in different places on the disk instead of next to each other
4Defragmenting is not needed for solid-state storage, because an SSD has no moving parts to jump around the disk DDefragmenting is for hard disk drives, not SSDs. An SSD has no moving parts, so it gains no speed from this.
5Defragmenter: deletes old files to free up space on the disk EBefore: A1 B1 A2 B2 A3 -> After: A1 A2 A3 B1 B2
6Run the defragmenter on an SSD to make it faster FA defragmenter does not delete files. It only rearranges the pieces of files so each file is stored together.

Definitions

defragmenter

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
IF drive = "___" THEN defragment(drive) ENDIF
2.
IF drive = "SSD" THEN needsDefrag ← _____ ENDIF
3.
IF pieces _ 1 THEN fragmented ← TRUE ENDIF
4.
drive ← "HDD" __________(drive) OUTPUT "Files are now contiguous"
5.
WHILE pieces > 1 pieces ← pieces _ 1 ENDWHILE

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A IF drive_type = "HDD" THEN
B RUN antivirus
C ELSE
D OUTPUT "Not needed"
E ENDIF
Question 2
A fragments ← 0
B WHILE fragments > 1
C JOIN two fragments
D fragments ← fragments - 1
E ENDWHILE
Question 3
A INPUT drive_type
B IF drive_type = "SSD" THEN
C OUTPUT "Defrag now"
D ELSE
E RUN defragmenter
F ENDIF
Question 4
A FOR each file on the disk
B IF pieces < 1 THEN
C JOIN pieces together
D ENDIF
E NEXT file
Question 5
A fragmented ← TRUE
B WHILE fragmented = TRUE
C JOIN file pieces together
D fragmented ← TRUE
E ENDWHILE

Answer Key

Disk defragmentation utility
Section A: Quick Questions
Q1
A — Joins them together in one contiguous block
Q2
A — Its pieces are scattered in different places on the disk
Q3
A — The read head does not have to jump around to find each piece
Q4
B — Hard disk drive (HDD)
Q5
B — An SSD has no moving parts, so scattered data is read just as fast
Section B: Match the Pairs
Q1
defragmenter → A utility that rearranges the scattered pieces of files on a hard disk drive so each file is stored together, which speeds up reading
Q2
fragmented file → A file whose pieces are stored in different places on the disk instead of next to each other
Q3
A defragmenter joins the pieces of each file into one contiguous block, so the file is stored together → Before: A1 B1 A2 B2 A3 -> After: A1 A2 A3 B1 B2
Q4
Defragmenting is not needed for solid-state storage, because an SSD has no moving parts to jump around the disk → if driveType == "SSD": skip defragmentation
Q5
Defragmenter: deletes old files to free up space on the disk → A defragmenter does not delete files. It only rearranges the pieces of files so each file is stored together.
Q6
Run the defragmenter on an SSD to make it faster → Defragmenting is for hard disk drives, not SSDs. An SSD has no moving parts, so it gains no speed from this.
Section C: Definitions
Q1
defragmenter — A utility that rearranges the scattered pieces of files on a hard disk drive so each file is stored together, which speeds up reading. It is not needed for SSDs.
Section D: Fill in the Blanks
Q1
IF drive = "HDD" THEN defragment(drive) ENDIF
Q2
IF drive = "SSD" THEN needsDefrag ← FALSE ENDIF
Q3
IF pieces > 1 THEN fragmented ← TRUE ENDIF
Q4
drive ← "HDD" defragment(drive) OUTPUT "Files are now contiguous"
Q5
WHILE pieces > 1 pieces ← pieces - 1 ENDWHILE
Section E: Spot the Error
Q1
B — An antivirus scans for malware and does not join file pieces together. A hard disk drive needs the defragmenter, so the line should be RUN defragmenter.
Q2
A — The count must start at the number of scattered pieces, such as 12. Starting at 0 means the WHILE condition is false and no pieces are ever joined.
Q3
C — Solid-state drives have no moving parts, so scattered files do not slow them down. For an SSD the message should say that defragmenting is not needed.
Q4
B — A file is fragmented when it is stored in more than one piece. The test should be pieces > 1, so only fragmented files are joined together.
Q5
D — Once the pieces are joined the file is no longer fragmented, so the flag must be set to FALSE. Setting it to TRUE again makes the loop run forever.