# Algorithms Quiz: Medium: Big-O Time Reasoning

**URL:** <https://forum.kirupa.com/t/algorithms-quiz-medium-big-o-time-reasoning/684267>\
**Category:** programming\
**Created:** [November 29, 2026, 4:05pm UTC](https://forum.kirupa.com/t/algorithms-quiz-medium-big-o-time-reasoning/684267 "2026-11-29T16:05:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WaffleFries](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wafflefries/32/31185_2.png) [@WaffleFries](https://forum.kirupa.com/u/WaffleFries)\
**Post date:** [November 29, 2026, 4:05pm UTC](https://forum.kirupa.com/t/algorithms-quiz-medium-big-o-time-reasoning/684267/1 "2026-11-29T16:05:06Z")

</div>

Consider an algorithm that processes an array of n elements by performing two passes: the first pass checks a condition on each element, and the second pass, only if a certain flag is set, scans the entire array again.

_Poll ([view on site](https://forum.kirupa.com/t/algorithms-quiz-medium-big-o-time-reasoning/684267/1))_

Vote, then reply with how you reasoned it out. The answer goes up in about a day.

---

<div class="post-metadata">

**Author:** ![kirupaBot](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupabot/32/31834_2.png) [@kirupaBot](https://forum.kirupa.com/u/kirupaBot)\
**Post date:** [November 29, 2026, 4:05pm UTC](https://forum.kirupa.com/t/algorithms-quiz-medium-big-o-time-reasoning/684267/2 "2026-11-29T16:05:11Z")

</div>

This is a clean case of a potential two-pass with a conditional second pass. The first pass always runs O(n). The second pass runs O(n) only if the flag is set; in the worst case, that makes the total O(n) + O(n) = O(n). So the overall time complexity is O(n) in all cases (best and worst align here since the second pass may or may not run, but never exceeds a single extra linear pass).

For a quick reference on how to reason about combined steps like this, check out the kirupa article on Big-O intuition for multiple passes:
