Ironing for smooth top surfaces in 3D Printing - Time & Space Complexity
When 3D printing, ironing is a step that smooths the top surface of a print by moving the nozzle over it again.
We want to understand how the time to complete ironing changes as the size of the top surface grows.
Analyze the time complexity of the following ironing process.
for each top_layer in print_layers:
for each line in top_layer.surface_lines:
move_nozzle_along(line)
extrude_small_amount_for_ironing()
end
end
This code moves the nozzle over every line on the top surface of each layer to smooth it out.
Look at what repeats in the code:
- Primary operation: Moving the nozzle along each line on the top surface.
- How many times: Once for every line in the top surface of each layer.
The time to iron grows as the number of lines on the top surface grows.
| Input Size (number of lines) | Approx. Operations |
|---|---|
| 10 | About 10 nozzle passes |
| 100 | About 100 nozzle passes |
| 1000 | About 1000 nozzle passes |
Pattern observation: The time increases directly with the number of lines to iron.
Time Complexity: O(n)
This means the ironing time grows in a straight line as the top surface size grows.
[X] Wrong: "Ironing time stays the same no matter how big the top surface is."
[OK] Correct: Because the nozzle must cover every line on the surface, bigger surfaces need more passes and more time.
Understanding how ironing time grows helps you think about print speed and quality trade-offs in real projects.
"What if the ironing process skipped every other line? How would the time complexity change?"