You are on page 1of 2
fungde AreaOrientadaTriingulo(Ponto A, Ponte B, Ponto Cc): real fungi retome ((AxtC.y - A.ytC.x + ALyiBox - AxOBy + ‘cux*B.y = Cxy*Box) / 2); fn fungdo pontozntriangulo(Fonte Py Ponto Pi, Ponto P2, Ponto P3): ‘keel lenbdai, Lenbde2, Landes, 67 fungde alinhados(Fonto A, Ponte B, Ponto C, Ponto D): booleano ipo ae ecb sao alsnhados «nao tem im erecho em comm °/ faste ‘se ((2ado(A, B,C) = 0) @ (lado(A, By D) = 0)) sutgo retorse (nad am(C, A, 8) 220 em(D, Ay 3) & BBD em(A, C; D) = BRS em(B, Cy D))7 fungio sefocan(Ponto A, Ponto B, Ponto ¢, Ponto D): boo pooleano /7 teeta se AB e cD ee tocan */ [alinhadse(A, B,C, 2) ou auperpestoe(R, B,C, D)) Ay 8) 08 omiD, Ay B) ow 8 = dxesordentadatetinguto(Pl, 22, 73): & 5} Si emis, Cy DIT Jamiel © dreaoriencadateiangais(é, #2, 23) / s1 fin, Simba? = deecordsncadatesangelo(@i, By Pa) / 8 moda: = Srssorienvadatesangelo(il P2,"P) / 5) NAIVE-STRING-MATCHER(T, P) tag, TERT ((Hambeak > 9) «(Demand > 0) « ameénr > 9) Tlength 2 m= Pllength Inc Ladotponco A, pono B, pono P 9 A es 5 eee 4 fPll.m)==T [s+ 1.9 tm) Tloat 5 = areaOrientadaTrienguio( A, 8, 5 print “Pattern occurs with shift” » MC earn 12 // -1 dizetza FINITE-AUTOMATON-MATCHER (T. 5.1) else it( S> 0) 1 on = Tlength return I: // 1 eaquerds 2 4q=0 else. 3 fori = lton return 0; // 0 colanear ao segnento AB ? 4 bq. TE) 5 m 6 print “Pattern oceurs with shift” i — am 5(q,4) = o(Pya) fungdo sobre(Ponto A, Ponto 3): booleano ee A 2B coinciden */ BLACK 17 blacken wits shed ag, atsene (PX = Ra) € Bey = A): DFs(@) ae 1 for cach vex u 6. fungdo em(Ponto P, Ponts &, Ponto 8): boolean Bde os oar 7etesta se P esth “dentro’ de AB, mas nao coincide com Aon BD Mel =| i J+ P pertence & rete as */ 4 tine = 0 5 foreach venex we. Jt 20 AB nde for vertical, test , a 2 sg.28 tg for vertical, cowear om xy senaoy om y - rear t Be jhe wetarne ( (Ax < Bex) @ (Px < B.x)) o UA > Pix) 8 (Pe > Bax) )——_DES-Visir(G.u) 1 time = time +1 1 site veres has jus been discovered do retorne (((A-y < Poy) @ (Bey < Bey) 8 a aid ae (aly > Ply) by > BL) 7 aaa eae 4 foreah ve G.Adju) HP expe edge (us) S— ifvclor == wire | zetorne false; 6 vraw fin. 7 DFS.Visin(G.») 8 ° funcdo extremo(Fonte P, Fonte A, Ponto B): booleanc /* testa se P coincide com um ponto extremo de AB */ retorne (sobre(P, A) ou sobre(P, B)); fin, fungdo iguais(Ponto A, Fonto B, Ponto C, Ponto D): booleano 7* testa se AB © CD sao iguais (coincidentes) */ Angeie setorne ((sobre(A, C) © scbre(B, D)) ou (sobre(A, D) 8 sobre(B, C)})7 IST-KRUSKAL(G. w) A=0 for each vers v € G.V Make-Ser(v) sort the edges of G.E into nondecreasing order by weight w for each edge (u,v) € G.E, Laken in nondecreasing order by weigh if Fin-Ser(u) 4 FiNp-Ser(v) A= AUtG¥)} Utoxtu,») return A M 1 2 3 4 5 6 7 8 9 fungdo seincontran(Ponto A, Ponto By Ponto C, Ponto D)+ 7 testa se AB © CD se encontran (un ponto extreno coincidente) */ se iguais(A, B, C, D) entio retorne retore ((sebre(A, ¢) # nto en(D, A, 8) @ nto en(s) C; D)) oe {sebre(a, 9) @ Bas omic, A, 8) Bas em(By Cy D)) BU fungae superpostos(Ponte A, Ponto By Fonte C, Fonte 0): booleano Tetesta te AB « Cb sao alinhados © ten tm trecho em comin 7 insets J ((lado(A, By C) = 0) © (lado(A, B, D) = 0)) (en(c, Ay B) on emid, A, B) ow fem(Ay C, D) 98 en(B, Cy D))T fin.

You might also like