Give the pseudocode of an algorithm that takes as input a li

Give the pseudocode of an algorithm that takes as input a list of n integers and finds the location of the last even integer in the list or returns 0 if there are no even integers in the list.

Solution

Let A[n] be the array of integers

evenNum=-1;

for i=1 to n

if A[i] is even

evenNum =i;

endif

endfor

if evenNum==-1

exit

return 0

else

return 1

endif

 Give the pseudocode of an algorithm that takes as input a list of n integers and finds the location of the last even integer in the list or returns 0 if there

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site