Purchase Solution

Analyzing an Algorithm for Assignment Statements

Not what you're looking for?

Ask Custom Question

For the following algorithm find the number of times the assignment statement (:=) is executed during the running of the program. Answer the question by giving a formula in terms of n:

i := 1;
while i < n + 1 do
i := i + 2;
for j := 1 to i do S od
od

Purchase this Solution

Solution Summary

The solution finds the number of times the assignment statement is executed during the running of the program.

Solution Preview

Solution:
Assume the number of times is m.

From i:=1 we can get the number of time for this part is 1;

From i:=i+2 we ...

Purchase this Solution


Free BrainMass Quizzes
Solving quadratic inequalities

This quiz test you on how well you are familiar with solving quadratic inequalities.

Multiplying Complex Numbers

This is a short quiz to check your understanding of multiplication of complex numbers in rectangular form.

Probability Quiz

Some questions on probability

Know Your Linear Equations

Each question is a choice-summary multiple choice question that will present you with a linear equation and then make 4 statements about that equation. You must determine which of the 4 statements are true (if any) in regards to the equation.

Graphs and Functions

This quiz helps you easily identify a function and test your understanding of ranges, domains , function inverses and transformations.