hwk2 - 2.1 Matrix addition 1 R1;R2;C1;C2 N, V o P . for k...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2.1 Matrix addition 1 R1;R2;C1;C2 N, V o P . for k := 1 to N do read (R1;R2;C1;C2; V ); for i := R1 to R2 do for j := C1 to C2 do A[i][j] := A[i][j] + V ; end end end oe + . 4g D X D c X D c g D c . . .. k. * KA F C1. read for 1 ~` o oeP 8 D c A[i][j]+V. C2. @ ; j(. )g D forx e c P c oe x N~ 5X o oe + E oe k=1g D c ; A(i,j)g D c A[i][j]+NVK for. 2~ ` o oe P N*V~` o oe P KA c 8 D V. A(i,j) read for. 2X c 8 D ooe P k=2g D c 8 c x h @ ; . x e . x 3g D * R1. R2g * i(. ) V O(N^3) . l R1, R2, C1, C2X D forg D c for. 2 o oe P V o oeP . . . , N~ ` o oe P 5g c for k:= 2.2 Half-Circle Property M ooe . A D x h . 180 ) Q. ^ l c 1 . . ^ l c m @ 180e m @ @ . . . AB oe P 180 oeP h oe P K oe P . r oe 180^ D c r K A A . oeP ; A 1 c Q p X ; @ c B^ d c > .. A, B ) D c 180 P .e KA oe P A. B 1 K 4 . r r r property r . . Q^ D 180. (. B D c x.K , . AB oe P , r AB oe P . 4~ ` o oe P oe P . oe P ,. 180 o P , . AB oe P ,r . 4 @ ; .^ D c theta^ c 180 r ( break Half-circle property^ D c r r K F AB=||A||||B||cos(theta) D c ; A . 180^ c @ . , . cos(theta)=-1K D c K A h oe ; F M O(N) M o oe 180 . o P @ space complexity. linear D 2.3 Anagram K ooe P oe K F ) o P (J @ ; A F . l P P loe ; A F p ; A A F LA L A F LA F ` LA F ` k D p X c M . afternoon NO c r D ~ ` oeP d c O(n). O(log n) o oe 1 l oe P x. E h oe x e h. . c e p A F K c p X c . d .1 LA F LA @ m ; o oe ; A F 1 @ ) K @ ; E oe P ~ o oe P. . .. ,r c F . oe P aefnnoort oe P ` LA F . x e h c Nxe h c ~ ` oe M l Dc FA . @ A F D oe P O(NlogN)1 linear. O(L) (Ll D L p X c @ ) m ; @ ) @; L . 1 e F K O(MlogNK) ^ c ^ l c s h oe M . ...
View Full Document

Ask a homework question - tutors are online