Skip to main contentSkip to solution

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 O(n)O(n). Time that grows in direct proportion to the input size is called linear, so these are linear time algorithms.


Options 3 and 4: n2n^2 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 n2n^2.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question