title: Determining the number of steps in an algorithm
body: <p>I was going through my <a href="http://www.um.edu.mt/ict/studyunit/CSA1017" rel="nofollow noreferrer">Data Structures and Algorithms</a> notes, and came across the following examples regarding Time Complexity and Big-O Notation: <a href="https://i.stack.imgur.com/ZwaxV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZwaxV.png" alt="Example 1" /></a> <a href="https://i.stack.imgur.com/YIqn7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YIqn7.png" alt="Example 2" /></a> <a href="https://i.stack.imgur.com/IVo8c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IVo8c.png" alt="Example 3" /></a> The columns on the left count the number of operations carried out in each line. I didn't understand why almost all the lines in the first example have a multiple of 2 in front of them, whereas the other two examples don't. Obviously this doesn't affect the resulting <em>O(n)</em>, but I would still like to know where the 2 came form.</p>