Write an algorithm in pseudocode for each description of the

Write an algorithm in pseudocode for each description of the input and output

Write an algorithm in pseudocode for each description of the input and output Input: a_1, a_2, ..., a_n, a sequence of numbers, where n greaterthanorequalto 2 n, the length of the sequence. Output: The second smallest number in the sequence.

Solution

Smallest=SecondSmallest=list[0]
For i=0 to n
If list[i]<Smallest
Smallest=list[i]
Else if list[i]<SecondSmallest
SecondSmallest=list[i]
End If
End For
Print SecondSmallest

Write an algorithm in pseudocode for each description of the input and output Write an algorithm in pseudocode for each description of the input and output Inpu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site