Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Math 2-1 Copyright © Genetic Computer School 2007 Lesson 2 More uses of Matrices Arrays.

Similar presentations


Presentation on theme: "Discrete Math 2-1 Copyright © Genetic Computer School 2007 Lesson 2 More uses of Matrices Arrays."— Presentation transcript:

1 Discrete Math 2-1 Copyright © Genetic Computer School 2007 Lesson 2 More uses of Matrices Arrays

2 Discrete Math 2-2 Copyright © Genetic Computer School 2007 Lesson 2 Overview Building arrays from raw data Adding rows or columns Array arithmetic Arrays for pricing More about matrices An array example Binary trees Back and trace pointers Networks Networks as arrays

3 Discrete Math 2-3 Copyright © Genetic Computer School 2007 Building arrays from raw data One dimension array Arr: array[1..3] of Real= (10.25, -20.15, 30.85); Multi-dimension array Arr: array[1..2,1..3] of Real= ((10.25, -20.15, 30.85), (14.50, 14.45, 10.75));

4 Discrete Math 2-4 Copyright © Genetic Computer School 2007 Adding rows or columns Var arr:Array[1..2,1..3] of Integer; … (* adding row 2 *) Result:=0; For i:=1 to 3 do Result:=Result + arr[2][i];

5 Discrete Math 2-5 Copyright © Genetic Computer School 2007 Array arithmetic Add/Subtract arrays: Arrays must be same format (same number of columns and number of rows) “Scalar" multiplication: Multiply the “scalar” with all elements of the array Multiply two array: in order to multiply arrays A and B the number of columns in A must equal the number of rows in B

6 Discrete Math 2-6 Copyright © Genetic Computer School 2007 Arrays for pricing Array multiplication for order costing

7 Discrete Math 2-7 Copyright © Genetic Computer School 2007 More about matrices The common operations on a matrix Add a constant vector/matrix to a matrix Multiply/divide a scalar to a matrix Add/Subtract from another matrix Cell-by-cell multiplication Multiply by a row/column vector Multiply, selectively, by a square matrix Multiply by another matrix

8 Discrete Math 2-8 Copyright © Genetic Computer School 2007 An array example “A manufacturing company, in factories at Andover and Bristol respectively, employs the following numbers of people in 4 grades for each of 6 job-categories and at different monthly pay scales”

9 Discrete Math 2-9 Copyright © Genetic Computer School 2007 Binary trees

10 Discrete Math 2-10 Copyright © Genetic Computer School 2007 Binary trees

11 Discrete Math 2-11 Copyright © Genetic Computer School 2007 Back and trace pointers BACK POINTERS can be added to each node so that it is possible to work up the tree from any node to trace its ancestors. TRACE POINTER can also be added which, from any node, would allow to trace the next in alphabetical (or numerical) sequence.

12 Discrete Math 2-12 Copyright © Genetic Computer School 2007 Networks

13 Discrete Math 2-13 Copyright © Genetic Computer School 2007 Networks as arrays Star network A B C D A0 1 1 1 S =B1 0 0 0 C1 0 0 0 D1 0 0 0

14 Discrete Math 2-14 Copyright © Genetic Computer School 2007 Networks as arrays Ring A B C D A 0 0 0 0 R =B 0 0 1 1 C 0 1 0 1 D 0 1 1 0

15 Discrete Math 2-15 Copyright © Genetic Computer School 2007 Networks as arrays LAN A B C D A0 0 1 1 L =B0 0 0 0 C1 0 0 1 D1 0 1 0


Download ppt "Discrete Math 2-1 Copyright © Genetic Computer School 2007 Lesson 2 More uses of Matrices Arrays."

Similar presentations


Ads by Google