reset password
Author Message
306645006
Posts: 4
Posted 15:37 Mar 26, 2019 |

I'm not really sure how to do the MaxOfThree program with an auxiliary variable. Specifically, I was unsure about what to make the auxiliary variable.

tnguye116
Posts: 3
Posted 15:45 Mar 26, 2019 |

I think an auxiliary variable means that it is a variable that stores a temporary variable. So the variable changes throughout the program to help with comparisons and such  (please correct me if I’m wrong).

 

So for this program, I think it would be a good idea to make the auxiliary variable the one that stores the new maximum after each comparison. 

Last edited by tnguye116 at 15:47 Mar 26, 2019.
wcwir
Posts: 75
Posted 14:05 Mar 27, 2019 |

Tyler is right. At each point in this problem you can store the best candidate for maximum in this auxiliary variable. As you perform comparisons you update the value of that variable based on the outcome of the comparisons, and once you're done performing the comparisons the auxiliary variable will hold the answer.

-----------------------

In general, 'auxiliary' variable just means means one that helps you out. Another example: you have two variables, a and b, and you want to swap their values. But:

a = b; b = a;

doesn't work: now both a and b have the same value (the starting value of b). Instead, you can do:

a = temp; a = b; b = temp;

now a has the value b started with, and b has the value a started with; temp was the auxiliary variable.

(You can also solve the problem of swapping numerical values without the temp, but temp helped.)