127k views
4 votes
Identify the steps that are used to find the maximum element from the following finite sequence

1, 8, 12, 9, 11, 2, 14, 5, 10, 4.

User Tedinoz
by
8.5k points

1 Answer

5 votes
1) Assign the first value to a variable x. This is x will take value 1.

2) Read the next value in the sequence. If this value is greater than current value of x, replace the value of x with the new elemente. Else, just continue.

3) If there are more elements in the sequence repeat steps from 2. Else, you already have the maximum element of the sequence in x.
User Enloz
by
8.1k points

No related questions found