Linear Search Algorithm: Declare Integer I SRCH Declare Integer X For I To Length X Ifx I Is SRCH Then Print SRCH
Linear Search Algorithm: Declare Integer I SRCH Declare Integer X For I To Length X Ifx I Is SRCH Then Print SRCH
DECLARE INTEGER i, srch = 72 DECLARE INTEGER x [] = [ 20, 15, 12, 30, -5, 72, 456 ] FOR i = 0 TO LENGTH (x) - 1 IF x [i] IS srch THEN PRINT "Found ", srch END END IF NEXT i PRINT "Did not find ", srch END
Matrix-Multiplication Algorithm
// == // | 10 // | // | 20 // == == 30 | == == | 5 | == ==
| 10 x 5 + 30 x 7 (260) | |
| X | 40 | ==
| = |
| 7 | == ==
| 20 x 5 + 40 * 7 (380) | == ==
DECLARE INTEGER m = 2 // Number of rows in left matrix (a) DECLARE INTEGER p = 2 // Number of columns in left matrix (a) // Number of rows in right matrix (b) DECLARE INTEGER n = 1 // Number of columns in right matrix (b) // Note: cs1 must equal rs2 DECLARE INTEGER c [m][n] // c holds 2 rows by 1 columns // All elements initialize to 0 FOR i = 0 TO m - 1 FOR j = 0 TO n - 1 FOR k = 0 TO p - 1 c [i][j] = c [i][j] + a [i][k] * b [k][j] NEXT k NEXT j NEXT i