Invitation to Computer Science 8th Edition

$$n=7, A_{1}=22, A_{2}=18, A_{3}=23, A_{4}=17, A_{5}=25, A_{6}=30, A_{7}=2$$ \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$.
$$n=7, A_{1}=22, A_{2}=18, A_{3}=23, A_{4}=17, A_{5}=25, A_{6}=30, A_{7}=2$$ \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$.