Describe using pseudocode an algorithm that takes a list of

Describe (using pseudocode) an algorithm that takes a list of n integers (n GE 1) and finds the location of the last even integer, and returns a 0 if there are no even integers. Use the definition of big-O and any big-O estimates we have already proven, to prove 1(2) - 2(3) +...+(n-1)n is O(n^3)

Solution

7. procedure lasteven(a1,...,an: integers)

location:=0

for i:=1 to n

if 2|ai then location:=i.

 Describe (using pseudocode) an algorithm that takes a list of n integers (n GE 1) and finds the location of the last even integer, and returns a 0 if there are

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site