Find a result

Report a typo

What is the result of the pseudocode function below?

function func(array):
    if len(array) == 0 then:
        return -1

    result = array[1]

    for i in [2, len(array)]:
        if array[i] < result then:
            result = array[i]

    return result 

The input numbers are 4 6 3 1 5.

NB: Recall that in pseudocode, the indexing starts from 1.

Enter a number
___

Create a free account to access the full topic