Suppose an array has n elements. we visit element #1 one time, element #2 two times, element #3 three times, and so forth. how many total visits will there be?

Respuesta :

AL2006
The number of visits is an arithmetic sequence.
There are ' n ' terms.  They're just the counting numbers from 1 to 'n' .
The first  term is 1, the second term is 2, ... , the last term is 'n' .

The formula for finding the sum of an arithmetic sequence is 

          Sum = n (first term + last term)/2  .

This formula is indicating that the sum of the arithmetic sequence
is just equal to the average of the first and last term, multiplied by
the number of terms.

So the number of visits is

                         n (1 + n)/2   .