Question: function printToScreen(n) for i = 1 to n for j = 1 to i print(*); end print( ); end Respond to the following: What does
function printToScreen(n) for i = 1 to n for j = 1 to i print("*"); end print(" "); end
Respond to the following:
What does the printToScreen function do? Please provide a detailed response. Specifically, describe the pattern formed by the *'s being printed. Note that print("*") will print one star and print(" ") will print a carriage return, which effectively brings the cursor to a new line.
In terms of n, how many computational steps are performed by the printToScreen function? Justify your response. Note:One computational step is considered one operation: one assignment, one comparison, et cetera. For example, the execution of print("Hello") may be considered one computational step: one print operation.
What is the Big-O (worst-case) time complexity of the printToScreen function in terms of n? Justify your response.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
