What are the final values for x and y for each


In designing algorithms, we have to accomplish a certain objective. Three algorithms are given below.

What does each algorithm accomplish when the initial values of x and y are 2 and 3, respectively?

What are the final values for x and y for each algorithm?

Assuming that setting up variables is more efficient than performing mathematical operations, which one is more efficient and why?

1: t1 = x; t2 = y; x = t2; y = t1

2: z = x; x = y; y = z

3: x = x + y; y = x - y; x = x - y

Solution Preview :

Prepared by a verified Expert
Basic Statistics: What are the final values for x and y for each
Reference No:- TGS01215642

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)