Invitation to Computer Science 8th Edition

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

Chapter 2 - 2.4 - Conclusion - Practice Problems - Page 85: 2

Answer

\begin{equation} n=7, A_{1}=22, A_{2}=18, A_{3}=23, A_{4}=17, A_{5}=25, A_{6}=30, A_{7}=2 \end{equation} \begin{array}{l} {\textbf {Largest So Far}} & {\textbf {Location} } & {\textbf {i} } &{\textbf { Operation }} \\ {\text {22}} & {\text {1} } & {\text {2} } &{\text { Compare } A_{2} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } &{\text { Is } 18>22 ? \text { No }} \\ {\text {22}} & {\text {1} } & {\text {3} } & {\text { Compare } A_{3} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } &{\text { Is } 23>22 ? \text { Yes, so reset values }} \\ {\text {23}} & {\text {3} } & {\text {4} } & {\text { Compare } A_{4} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } & {\text { Compare } A_{4} \text { Is 17 > 23? No}} \\ {\text {23}} & {\text {3} } & {\text {5} } &{\text { Compare } A_{5} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } & {\text { Compare } A_{4} \text { Is 25 > 23? Yes, so reset values}} \\ {\text {25}} & {\text {5} } & {\text {6} } &{\text { Compare } A_{6} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } & {\text { Compare } A_{4} \text { Is 30 > 25? Yes, so reset values}} \\ {\text {30}} & {\text {6} } & {\text {7} } & {\text { Compare } A_{7} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } & {\text { Is } 2>30 ? \text { No }} \end{array} Output: Largest $=30 .$ Location $=6$.

Work Step by Step

\begin{equation} n=7, A_{1}=22, A_{2}=18, A_{3}=23, A_{4}=17, A_{5}=25, A_{6}=30, A_{7}=2 \end{equation} \begin{array}{l} {\textbf {Largest So Far}} & {\textbf {Location} } & {\textbf {i} } &{\textbf { Operation }} \\ {\text {22}} & {\text {1} } & {\text {2} } &{\text { Compare } A_{2} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } &{\text { Is } 18>22 ? \text { No }} \\ {\text {22}} & {\text {1} } & {\text {3} } & {\text { Compare } A_{3} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } &{\text { Is } 23>22 ? \text { Yes, so reset values }} \\ {\text {23}} & {\text {3} } & {\text {4} } & {\text { Compare } A_{4} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } & {\text { Compare } A_{4} \text { Is 17 > 23? No}} \\ {\text {23}} & {\text {3} } & {\text {5} } &{\text { Compare } A_{5} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } & {\text { Compare } A_{4} \text { Is 25 > 23? Yes, so reset values}} \\ {\text {25}} & {\text {5} } & {\text {6} } &{\text { Compare } A_{6} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } & {\text { Compare } A_{4} \text { Is 30 > 25? Yes, so reset values}} \\ {\text {30}} & {\text {6} } & {\text {7} } & {\text { Compare } A_{7} \text { and largest so far. }} \\ {\text { }} & {\text { } } & {\text { } } & {\text { Is } 2>30 ? \text { No }} \end{array} Output: Largest $=30 .$ Location $=6$.
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.