Algorithm for printing @ symbols
Consider this algorithm for printing @ symbols in a particular pattern.
While n is less than or equal to 10:
print n @ symbols
go to next line
n = n + 1
a.
i.Show what is displayed as a result of this algorithm when n has an initial value of 4.
ii.How many @ symbols are printed in total when n has an initial value of 4?
b.Write down an expression that gives the total number of @ symbols that are printed by this algorithm for any value of n. Hint: consider the number of @ symbols if n = 1, and then subtract the number of @ symbols that are missing if n > 1
c.If printing an @ symbol is considered to be a step, write down the Big O notation for this algorithm. Explain your answer.
13
Answer
Answers can only be viewed under the following conditions:
- The questioner was satisfied with and accepted the answer, or
- The answer was evaluated as being 100% correct by the judge.

1.7K
The answer is accepted.
Join Matchmaticians Affiliate Marketing
Program to earn up to a 50% commission on every question that your affiliated users ask or answer.
- answered
- 1197 views
- $5.89
Related Questions
- Algebra 2 problem about a ticket system
- Find $a,b,c$ so that $\begin{bmatrix} 0 & 1& 0 \\ 0 & 0 & 1\\ a & b & c \end{bmatrix} $ has the characteristic polynomial $-\lambda^3+4\lambda^2+5\lambda+6=0$
- The last six digits of the number $30001^{18} $
- Fields and Galois theory
- Algebra Word Problem 1
- Length of a matrix module
- Integral of trig functions
- Use Rouche’s Theorem to show that all roots of $z ^6 + (1 + i)z + 1 = 0$ lines inside the annulus $ \frac{1}{2} \leq |z| \leq \frac{5}{4}$
I think c. is ambiguous. I would say it's O(1), since the number of @ symbols you can print is bounded, but I can see the argument for O(n^2).
Awesome, really appreciate your help Alessandro, hope you have a great new year!