Ask your own question, for FREE!
Discrete Math 9 Online
OpenStudy (vortish):

Consider an algorithm that uses only assignment statements that replaces the quintuple (v, w, x, y, z) with (w, x, y, z, v). What is the minimum number of assignment statements needed?

ganeshie8 (ganeshie8):

So you need to shift everything to left by 1 position

OpenStudy (vortish):

i dont understand

OpenStudy (vortish):

is the answer 1?

ganeshie8 (ganeshie8):

(v, w, x, y, z) with (w, x, y, z, v). ``` a=v v=w w=x x=y y=z z=a ```

ganeshie8 (ganeshie8):

im guessing you will need 6 assign statements in above sequence ^

OpenStudy (vortish):

were does a come in to the equation

ganeshie8 (ganeshie8):

it is a temporary variable to save the contents of `v`

OpenStudy (vortish):

oh k so i still dont understand what the answer would be

ganeshie8 (ganeshie8):

you need a minimum of 6 assignments if you work it like above

OpenStudy (vortish):

can you explain it i dont learn by some one saying I need the steps to figure it out

OpenStudy (anonymous):

assignments are always destructive. they replace the contents of the variable with a new value. therefore it is impossible to preserve all the data without a temporary variable.

OpenStudy (vortish):

ok

OpenStudy (anonymous):

Now check ganeshie8's list of assignments and confirm for yourself that it does indeed work.

OpenStudy (vortish):

i would assume that it would because a would logically be the next letter after z

OpenStudy (anonymous):

The name \(a\) is arbitrary, it could be anything. You could actually name it \(temp\) if you like.

OpenStudy (vortish):

so now that i understand it how do i write the answer by 6 or the vxyza

OpenStudy (vortish):

@Alchemista I understand the equation but how do I write the answer

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!