# Algorithms

• Mar 4th 2009, 08:32 AM
Hongosh
Algorithms
I am having trouble with these algorithms....i know the computer syntax for them but i am having trouble simplifing them to mathmatical terms only....

1. describe an algorithm that takes as input a list of n integers and produces as output the largest difference obtained by subracting an integer in the list from the one following it....(i think i have this one, i need more help on the next two)

2. describe an algorithm that takes as input a list of n integers and finds the number of negative integers in the list.

3. describe an algorithm that takes as input a list of n distinct integers and finds the location of the largest even integer in the list or returns 0 if there are no even integers in the list.
• Mar 4th 2009, 11:33 AM
HallsofIvy
Quote:

Originally Posted by Hongosh
I am having trouble with these algorithms....i know the computer syntax for them but i am having trouble simplifing them to mathmatical terms only....

1. describe an algorithm that takes as input a list of n integers and produces as output the largest difference obtained by subracting an integer in the list from the one following it....(i think i have this one, i need more help on the next two)

input \$\displaystyle a_n\$. If n> 0, output \$\displaystyle a_n- a_{n-1}\$.

Quote:

2. describe an algorithm that takes as input a list of n integers and finds the number of negative integers in the list.