Linear

If we are adding or subtracting by some constant, it is linear.

for (int i=0; i<n; i++)
  cout << "wow";
``
$$
\sum_{i=0}^{n-1} = n = \Theta(n)
$$
 
```cpp
for (int i=2; i<n; i++) 
  cout << "wow";
for (int i=0; i<n/2; i++)
  cout << "wow";
``
$$
\sum_{n/2 - 1}^{i=0} \Theta(1) = \frac{n}{2} = \Theta(n)
$$
 
```cpp
for (int i=0; i<n; i=i+3)
  cout << "wow";

“cpp
for (int i=n; i>0; i—)
cout << “wow”;

$$
\text{Missing answer} = \Theta(n)
$$

# Logarithmic

If we are multiplying or dividing by some constant, it is logarithmic.

```cpp
for (int i=n; i>0; i=i/2)
  cout << "wow";
for (int i=1; i<n; i=i*2)
  cout << "wow";
for (int i=m; i>0; i=i/10)
  cout << "wow";

Quadratic

If there are nested loops, multiply the runtime of each loop.

for (int i=0; i<n; i++)
  for (int j=0; j<n; j++)
    cout << "wow";
for (int i=0; i<n; i++)
  for (int j=0; j<i; j++)
    cout << "wow";

Gauss’ Formula

Weird ones

for (int i=0; i<n; i++)
  for (int j=1; j<n; j=j*2)
    cout << "wow";
for (int i=0; i<n; i++)
  for (int j=1; j<i; j=j*2)
    cout << "wow";

Non nested

Just add them instead of multiply

for (int i=0; i<n; i++)
  cout << "wow";
 
for (int i=0; i<n; i++)
  cout << "wow";