Invitation to Computer Science 8th Edition

Published by Cengage Learning
ISBN 10: 1337561916
ISBN 13: 978-1-33756-191-4

Chapter 1 - Exercises - Page 89: 26

Answer

$\bullet$ Set value of Previous to 0 $\bullet$ Set value of $V$ to the first element of the list $\bullet$ Set the value of Exists to $N O$ $\bullet$ While both $(V \geq-1)$ and (Exists $=N O )$ do $\bullet \quad$ Set value of Previous to $V$ $\bullet\quad$ Set value of $V$ to next element from the list $\bullet\quad$ If Previous $=V$ then $\bullet\quad\quad$ Set Exists to $Y E S$ $\bullet\quad\quad$ Set value of Number to $V$ $\bullet$ End of loop. $\bullet$ If Exists $=Y E S$ then $\bullet \quad$ Print "Yes, the numbers Number and Number are adjacent" $\bullet$ Else $\bullet\quad$ Print "No, there are not"

Work Step by Step

$\bullet$ Set value of Previous to 0 $\bullet$ Set value of $V$ to the first element of the list $\bullet$ Set the value of Exists to $N O$ $\bullet$ While both $(V \geq-1)$ and (Exists $=N O )$ do $\bullet \quad$ Set value of Previous to $V$ $\bullet\quad$ Set value of $V$ to next element from the list $\bullet\quad$ If Previous $=V$ then $\bullet\quad\quad$ Set Exists to $Y E S$ $\bullet\quad\quad$ Set value of Number to $V$ $\bullet$ End of loop. $\bullet$ If Exists $=Y E S$ then $\bullet \quad$ Print "Yes, the numbers Number and Number are adjacent" $\bullet$ Else $\bullet\quad$ Print "No, there are not"
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.