Under-extrusion and over-extrusion in 3D Printing - Time & Space Complexity
When 3D printing, the amount of filament pushed out affects print quality. We want to understand how the time to fix extrusion issues grows as the problem size changes.
How does the effort to correct under-extrusion or over-extrusion scale with the size of the print?
Analyze the time complexity of this extrusion adjustment process.
for each layer in print:
check extrusion amount
if extrusion too low:
increase flow rate
else if extrusion too high:
decrease flow rate
print layer
This code checks and adjusts extrusion for every layer during printing.
Look at what repeats as the print grows.
- Primary operation: Looping through each layer to check and adjust extrusion.
- How many times: Once per layer, so as many times as there are layers.
As the number of layers increases, the checks and adjustments increase too.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 layers | 10 checks and possible adjustments |
| 100 layers | 100 checks and possible adjustments |
| 1000 layers | 1000 checks and possible adjustments |
Pattern observation: The work grows directly with the number of layers; doubling layers doubles the work.
Time Complexity: O(n)
This means the time to manage extrusion issues grows in a straight line with the number of layers printed.
[X] Wrong: "Adjusting extrusion once fixes all layers, so time doesn't grow with layers."
[OK] Correct: Each layer can have different extrusion needs, so checks and adjustments must happen repeatedly, increasing with layers.
Understanding how tasks scale with input size helps you think clearly about printer performance and troubleshooting. This skill is useful for solving real-world problems step by step.
"What if extrusion adjustments were only made every 10 layers instead of every layer? How would the time complexity change?"