Any algorithm that has a loop (usually from 1 to n) will have the time complexity as __________ and such algorithms are known as_________________.
Any algorithm that has a loop (usually from 1 to n) will have the time complexity as __________ and such algorithms are known as_________________.
Solution
✅ Correct Option: 2
A single loop running from 1 to n executes its body n times, so the time complexity is proportional to n, written . Time that grows in direct proportion to the input size is called linear, so these are linear time algorithms.
Options 3 and 4: time comes from a nested loop (a loop inside a loop), not a single loop.
Option 1: n and "quadratic" do not go together, since quadratic means .
Related questions:
2025: 21 May Shift 1