• :00Days
• :00Hours
• :00Mins
• 00Seconds
A new era for learning is coming soon

Suggested languages for you:

Americas

Europe

Q1E

Expert-verified
Found in: Page 202

### Discrete Mathematics and its Applications

Book edition 7th
Author(s) Kenneth H. Rosen
Pages 808 pages
ISBN 9780073383095

# List all the steps used by algorithm 1 to find the maximum of the list 1, 8, 12, 9, 11, 2, 14, 5, 10, 4

The maximum of 1, 8, 12, 9, 11, 2, 14, 5, 10, 4 is 14.

See the step by step solution

## Step 1: Finding the maximum element in a finite sequence by algorithm:

$proceduremax\left({a}_{1},{a}_{2},......,{a}_{n}:integers\right)\phantom{\rule{0ex}{0ex}}max:al\phantom{\rule{0ex}{0ex}}fori:=2ton\phantom{\rule{0ex}{0ex}}ifmax<{a}_{i}thenmax:={a}_{i}\phantom{\rule{0ex}{0ex}}returnmax\left\{maxisthelargestelement\right\}$

## Step 2: Writing the steps used by the algorithm:

Set max = 1

Compare 1 with 8, since 1 < 8 , set max = 8

Compare 8 with 12, since 8 < 12 , set max = 12

Compare 12 with 9, since 12 < 9 , set max = 12

Compare 12 with 11, since 12 < 11 , set max = 12

Compare 12 with 2, since 12 < 2 , set max = 12

Compare 12 with 14, since 12 < 14 , set max = 14

Compare 14 with 5, since 14 < 5 , set max = 14

Compare 14 with 10, since 14 < 10 , set max = 14

Compare 14 with 4, since 14 < 4 , set max = 14

Therefore, the maximum of the given list 1, 8, 12, 9, 11, 2, 14, 5, 10, 4 is 14.