Algorithm for Average of N numbers GIVENS X
Algorithm for Average of N numbers GIVENS: X N (An array of values) (Length of array X) RESULTS: Average (The average of the values in the array X) INTERMEDIATES: Sum (Sum of array values) Index (Current position in array) HEADER Average Find. Average(X, N) Sum 0 Index < N ? false true Sum + X[Index] Index + 1 Average Sum / N
Standard Deviation Algorithm (1) GIVENS: X N (an array containing a collection of real numbers) (the length of the array) RESULTS: St. Dev (the standard deviation of the values in the array) INTERMEDIATES: Sum (accumulates the sum of the array) Sum. Index (used as array index to find sum of array) Average (average of array elements) Diff. Sq. Sum (accumulates the sum of the squares of the differences) Diff. Sq. Index (used as array index to find sum of squares of differences) HEADER St. Dev Standard. Deviation(X, N)
Standard Deviation Algorithm (2) Sum 0 Sum. Index 0 false true Sum. Index < N ? Sum + X[Sum. Index] Sum. Index + 1 Average Sum / N Diff. Sq. Sum 0 Diff. Sq. Index 0 true Diff. Sq. Index < N ? false Diff. Sq. Sum + (X[Diff. Sq. Index] – Average) Diff. Sq. Index + 1 St. Dev Sqrt( Diff. Sq. Sum / (N – 1) )
Algorithm for Distance of Thrown Ball (1) GIVENS: V RESULTS: Range (Initial velocity of the ball, in metres / second) (An array of for how far the ball will travel for various angles. The values will be for 0 degrees up to 90 degrees, in increments of 10 degrees. Result is in metres) INTERMEDIATES: G (Constant: Acceleration due to gravity = 9. 8 m/s 2) Deg. To. Rad (Constant: Degrees to radians conversion = / 180) Theta (Current horizontal angle, in degrees) Theta. Rad (Current horizontal angle, in radians) HEADER Range Find. Distance(V)
Algorithm for Distance of Thrown Ball (2) Theta 0 G 9. 8 Deg. To. Rad / 180 Range Make. New. Array(10) Theta ≤ 90 ? false true Theta. Rad Theta × Deg. To. Rad Range[Theta/10] 2 × V × sin(Theta. Rad) × cos(Theta. Rad) / G Theta + 10
- Slides: 5