XML and Databases. Outline. XPath. Outline - Lectures. XPath Data Model. Outline - Assignments. XPath. Sebastian Maneth NICTA and UNSW

Size: px
Start display at page:

Download "XML and Databases. Outline. XPath. Outline - Lectures. XPath Data Model. Outline - Assignments. XPath. Sebastian Maneth NICTA and UNSW"

Transcription

1 Outline XML n Dtses Leture 6 Noe Seleting Queries: XPth XPth Dt Moel: 7 types of noes 2. Simple Exmples 3. Lotion Steps n Pths 4. Vlue Comprison, n Other Funtions Sestin Mneth NICTA n UNSW CSE@UNSW -- Semester 1, XPth Query lnguge to selet ( sequene of) noes of n XML oument W3C Stnr Most importnt XML query lnguge: use in mny other stnrs suh s XQuery, XSLT, XPointer, XLink, Cve: version 2.0 is onsierly more expressive thn 1.0 We stuy XPth 1.0 Terminology: Inste of XPth query we often sy XPth expression. (An expression is the primry onstrution of the XPth grmmr; it mthes the proution Expr of the XPth grmmr.) Outline - Letures 1. Introution to XML, Enoings, Prsers 2. Memory Representtions for XML: Spe vs Aess Spee 3. RDBMS Representtion of XML 4. DTDs, Shems, Regulr Expressions, Amiguity 5. XML Vlition using Automt 6. Noe Seleting Queries: XPth 7. Tree Automt for Effiient XPth Evlution, Prllel Evlution 8..XPth Properties: kwr xes, ontinment test 9. Streming Evlution: how muh memory o you nee? 10. XPth Evlution using RDBMS 11. XSLT stylesheets n trnsform 12. XQuery XML query lnguge XPth 3 4 Outline - Assignments XPth Dt Moel 1. Re XML, using DOM prser. Crete oument sttistis. 2. SAX Prse into memory struture: Tree n DAG XPth Query Q XML oument D Evlute Q on D (in XPth t moel) sequene of result noes 3. Mp XML into RDBMS 20. April 4. XPth evlution 11. My 5. XPth into SQL Trnsltion 25. June Doument D is moele s tree. THERE ARE SEVEN TYPES OF NODES in the XPth Dt Moel: 7 noe types root noes element noes text noes ttriute noes nmespe noes proessing instrution noes omment noes 5 6 1

2 XPth Dt Moel XPth Dt Moel XPth Query Q XML oument D Evlute Q on D (in XPth t moel) sequene of result noes Unique IDs An element noe my hve unique ientifier (ID). Vlue of the ttriute tht is elre in the DTD s type ID. No two elements in oument my hve the sme unique ID. If n XML proessor reports two elements in oument s hving the sme unique ID (whih is possile only if the oument is invli) then the seon element in o. orer must e trete s not hving unique ID. Doument D is moele s tree. NOTE: If oument hs no DTD, then no element will hve unique ID. THERE ARE SEVEN TYPES OF NODES in the XPth Dt Moel: 7 noe types root noes element noes text noes ttriute noes nmespe noes proessing instrution noes omment noes for rest of leture: this is ALL you nee to know out XML noes! root noes element noes text noes ttriute noes nmespe noes proessing instrution noes omment noes for rest of leture: this is ALL you nee to know out XML noes! 7 8 Doument D is moele s tree. XPth Dt Moel For eh noe string-vlue n e etermine. (sometimes prt of the noe, sometimes ompute from esennts, sometimes expne-nme: lol nme + nmespe URI) There is n orer, oument orer, efine on ll noes. orrespons to the position of the first hrter of the XML repr of the noe, in the oument (fter entity expnsion) Attriute n nmespe noes pper efore the hilren of n element. Orer of ttriute n nmespe noes is implementtion-epenent Every noe (esies root) hs extly one prent (whih is root or n element noe) XPth Query Q XML oument D XPth Result Sequenes Evlute Q on D (in XPth t moel) sequene of result noes Orere in oument orer Contins no uplites 9 10 Simple Exmples Simple Exmples In revite XPth syntx. In revite syntx. Q0: / Doument: <i> <ook> <uthor>aiteoul</uthor> <uthor>hull</uthor> <uthor>vinu</uthor> <title>fountions of Dtses</title> <yer>1995</yer> </ook> <ook> <uthor>ullmnn</uthor> Selets the oument root (lwys the prent of the oument element) oument root is virtul n invisile, in this exmple. If <?xml version="1.0"?> is present, then it is returne (s first entry) in the result of Q0. <title>priniples of Dtse n Knowlege Bse Systems</title> <yer>1998</yer> </ook> </i> oument element, if lele i Q1: /i/ook/yer hil noes tht re lele ook Doument: <i> hil noes tht re lele yer <ook> <uthor>aiteoul</uthor> <uthor>hull</uthor> <uthor>vinu</uthor> <title>fountions of Dtses</title> <yer>1995</yer> </ook> <ook> <uthor>ullmnn</uthor> <title>priniples of Dtse n Knowlege Bse Systems</title> <yer>1998</yer> </ook> </i> Note XPth Evlutors usully return the full sutree of the selete noe

3 Simple Exmples In revite syntx. oument element, if lele i Q1: /i/ook/yer hil noes tht re lele ook Doument: <i> hil noes tht re lele yer <ook> <uthor>aiteoul</uthor> <uthor>hull</uthor> Result of query Q1 = <uthor>vinu</uthor> (element) noes N1, N2 <title>fountions of Dtses</title> <yer>1995</yer> sutree t N1 is <yer>1995</yer> </ook> n sutree t N2 is <yer>1998</yer> <ook> <uthor>ullmnn</uthor> <title>priniples of Dtse n Knowlege Bse Systems</title> <yer>1998</yer> </ook> </i> 13 Simple Exmples reltive to the In revite syntx. ontext-noe = root noe esennt or self noes Q2: //uthor hil noes tht re lele uthor Doument: <i> <ook> <uthor>aiteoul</uthor> <uthor>hull</uthor> <uthor>vinu</uthor> <title>fountions of Dtses</title> <yer>1995</yer> </ook> <ook> <uthor>ullmnn</uthor> <title>priniples of Dtse n Knowlege Bse Systems</title> <yer>1998</yer> </ook> </i> // is short for /esennt-or-self::noe()/. For exmple, //uthor is short for /esennt-or-self::noe()/hil::uthor 14 In revite syntx. Q2: //uthor Simple Exmples Desennt or self noes tht re lele uthor Doument: <i> <ook> <uthor>aiteoul</uthor> <uthor>hull</uthor> <uthor>vinu</uthor> <title>fountions of Dtses</title> <yer>1995</yer> </ook> <ook> <uthor>ullmn</uthor> reltive to the ontext-noe = root noe Result of query Q2 = sequene of (element) noes ( N1, N2, N3, N4 ) <title>priniples of Dtse n Knowlege Bse Systems</title> <yer>1998</yer> </ook> </i> // is short for /esennt-or-self::noe()/. For exmple, //uthor is short for /esennt-or-self::noe()/hil::uthor 15 In revite syntx. Q3: //// Simple Exmples -hil of -o. element e 16 In revite syntx. Simple Exmples In revite syntx. Simple Exmples Q3: //// -hil of -o. element Q3: //// -hil of -o. element ALL -noes in this sutree e ALL -noes in this sutree e

4 Simple Exmples Simple Exmples In revite syntx. Q4: /*/ In revite syntx. Q5: // In revite syntx. Simple Exmples In revite syntx. Arevitions, so fr An Axis Q6: //* / is revition for /hil:: A Noetest // is revition for /esennt-or-self::noe()/hil:: Chil n esennt-or-self re only 2 out of 12 possile xes. An Axis is sequene of noes. It is evlute reltive to ontext-noe. Other xes: esennt prent nestor-or-self nestor -siling preeing-siling ttriute preeing In revite syntx. Arevitions, so fr An Axis In revite syntx. Exmples: Preites / is revition for /hil:: Q7: //[./] hs -hil (ontext-noes re ll -noes ) A Noetest // is revition for /esennt-or-self::noe()/hil:: // is revition for /esennt-or-self::noe()/. is revition for self::noe().. is revition for prent::noe() Chil n esennt-or-self re only 2 out of 12 possile xes. An Axis is sequene of noes. It is evlute reltive to ontext-noe. Other xes: esennt prent nestor-or-self nestor -siling preeing-siling ttriute preeing

5 Exmples: Preites Exmples: Preites In revite syntx. Q8: //[./]/ hs -hil In revite syntx. Q9: //[./]//.. hs -hil selet prent(s) of ontext-noe(s) prent(s) of the ontext-noe(s) All -hilren of the ontext-noe(s) Q9 selets -noes tht hve -hil AND -hil Exmples: Preites Exmples: Preites In revite syntx. Q9: //[./]//.. hs -hil selet prent(s) of ontext-noe(s) In revite syntx. Q9: //[./]//.. hs -hil selet prent(s) of ontext-noe(s) prent(s) of the ontext-noe(s) prent(s) of the ontext-noe(s) Q9 selets -noes tht hve -hil AND -hil More iret wy: //[./ n./] (sme s //[./] on *this* tree..!) Q9 selets -noes tht hve -hil AND -hil More iret wy: //[./ n./] (sme s //[./] on *this* tree..!) Exmples: Preites Exmples: Preites (or Filters ) In revite syntx. Q9: //[]//.. hs -hil selet prent(s) of ontext-noe(s) prent(s) of the ontext-noe(s) In revite syntx. //[ n ] evlutes to true/flse A Filter Q9 selets -noes tht hve -hil AND -hil More iret wy: //[ n ] (sme s //[./] on *this* tree..!) -noes tht hve -hil AND -hil We o not nee./ ::noe()/hil:: equivlent to

6 Exmples: Preites (or Filters ) Exmples: Preites In revite syntx. In revite syntx. //[ n ] evlutes to true/flse A Filter Question How to only selet the other -noe? //[ n ] evlutes to true/flse A Filter Question How to only selet the other -noe? Cn use not( ) in filter! Cn use not( ) in filter! Mny more possiilities, of ourse: //[prent::] //[../../] //[../] //[not()] oes not hve -hil //[not()] CAVE: wht oes //[../] give?? Exmples: Preites Exmples: Preites In revite syntx. In revite syntx. //[ n ] evlutes to true/flse A Filter Question How to only selet the other -noe? //[ n ] evlutes to true/flse A Filter Question How to only selet the other -noe? Cn use not( ) in filter! Mny more possiilities, of ourse: //[prent::] //[../../] //[../] Cn use not( ) in filter! Mny more possiilities, of ourse: //[prent::] //[../../] //[../] //[not()] CAVE: wht oes //[../] give?? //[not()] n you sy -noe tht hs only -hilren? Exmples: Preites Exmples: Preites In revite syntx. In revite syntx. //[ n ] evlutes to true/flse A Filter Question How to only selet the other -noe? //[not()] sme s.. on this tree //[not(hil::*[not(self::)])] not the se tht ll hilren re not lele hols if n only if Cn use not( ) in filter! Mny more possiilities, of ourse: //[prent::] //[../../] //[../] ll hilren re lele //[not()] n you sy -noe tht hs only -hilren? YES! nees it of logi //[not(hil::*[not(self::)])]

7 Exmples: Preites Exmples: Preites In revite syntx. In revite syntx. //[not()] sme s.. on this tree //[not(hil::*[not(self::)])] //[not()] sme s.. on this tree //[not(hil::*[not(self::)])] not the se tht ll hilren re not lele not the se tht ll hilren re not lele hols if n only if hols if n only if ll hilren re lele ll hilren re lele Duplite elimintion //[not()]//.. ontext-noes for prent seletion (/..) ontext-noes Duplite elimintion for nestor seletion //[not()]//nestor::* Exmples: Preites Exmples: Preites In revite syntx. In revite syntx. //[not()] sme s.. on this tree //[not(hil::*[not(self::)])] //[not()] sme s.. on this tree //[not(hil::*[not(self::)])] not the se tht ll hilren re not lele not the se tht ll hilren re not lele hols if n only if hols if n only if ll hilren re lele ll hilren re lele Duplite elimintion mye //*[.//[not()]] Duplite elimintion mye //*[.//[not()]] No.. //[not()]//nestor::* //[not()]//nestor::* How to selet the -noe? Equivlent one, without use of nestor?? No use of nestor? Exmples: Preites Exmples: Preites In revite syntx. In revite syntx. //[not()] sme s.. on this tree //[not(hil::*[not(self::)])] //[not()] sme s.. on this tree //[not(hil::*[not(self::)])] not the se tht ll hilren re not lele not the se tht ll hilren re not lele hols if n only if hols if n only if ll hilren re lele ll hilren re lele Duplite elimintion mye //*[.//[not()]] No.. Duplite elimintion mye //*[.//[not()]] No.. //[not()]//nestor::* No use of nestor? How to selet the -noe? //*[esennt-or-self::[not()]] 41 //[not()]//nestor::* How to selet the -noe? //*[.//[not()] or not(hil::*[not(self::)]) n./*] only -hilren hs hil (not lef) 42 7

8 XPth Query Q XML oument D More Detils Evlute Q on D (in XPth t moel) sequene of result noes Lotion Steps & Pths A Lotion Pth is sequene of Lotion Steps Lotion Pths [1] LotionPth ::= ReltiveLotionPth AsoluteLotionPth Initil Context will e is root noe [2] AsoluteLotionPth ::= '/' ReltiveLotionPth? AreviteAsoluteLotionPth NOT orret (t lest not for intermeite expr s) An expression evlutes to n ojet, whih hs one of the following four si types noe-set (n unorere olletion of noes w/o uplites) oolen (true or flse) numer ( floting-point numer) string ( sequene of UCS hrters) [3] ReltiveLotionPth ::= Step ReltiveLotionPth '/' Step AreviteReltiveLotionPth Lotion Steps [4] Step ::= AxisSpeifier NoeTest Preite* AreviteStep [5] AxisSpeifier ::= AxisNme ':: AreviteAxisSpeifier Lotion Steps & Pths A Lotion Pth is sequene of Lotion Steps A Lotion Step is of the form xis :: noetest [ Filter_1 ] [ Filter_2 ] [ Filter_n ] Lotion Steps & Pths A Lotion Pth is sequene of Lotion Steps A Lotion Step is of the form xis :: noetest [ Filter_1 ] [ Filter_2 ] [ Filter_n ] Filters (k preites, (filter) expressions) evlute to true/flse XPth queries, evlute with ontext-noe = urrent noe Boolen opertors: n, or Empty string/sequene re onverte to flse Filters (k preites, (filter) expressions) evlute to true/flse text() noetest: * or noe-nme (oul e expne nmespes) or omment() proessing -instrution(in) noe() Exmple hil::text() selet ll text noe hilren of the ontext noe the noetest noe() is true for ny noe. ttriute::* selet ll ttriutes of the ontext noe Lotion Steps & Pths Lotion Steps & Pths A Lotion Pth is sequene of Lotion Steps Axis = sequene of noes (is evlute reltive to ontext-noe) A Lotion Step is of the form xis :: noetest [ Filter_1 ] [ Filter_2 ] [ Filter_n ] Filters (k preites, (filter) expressions) evlute to true/flse text() noetest: * or noe-nme (oul e expne nmespes) or omment() proessing 12 Axes -instrution(in) Forwr Axes: Bkwr Axes: noe() In o orer hil esennt-or-self esennt -siling prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 47 In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 48 8

9 Lotion Steps & Pths Lotion Steps & Pths Axis = sequene of noes (is evlute reltive to ontext-noe) Axis = sequene of noes (is evlute reltive to ontext-noe) In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 49 In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 50 Lotion Steps & Pths Lotion Steps & Pths Axis = sequene of noes (is evlute reltive to ontext-noe) Axis = sequene of noes (is evlute reltive to ontext-noe) In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 51 In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 52 Lotion Steps & Pths Lotion Steps & Pths Axis = sequene of noes (is evlute reltive to ontext-noe) Axis = sequene of noes (is evlute reltive to ontext-noe) In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 53 In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 54 9

10 Lotion Steps & Pths Lotion Steps & Pths Axis = sequene of noes (is evlute reltive to ontext-noe) Axis = sequene of noes (is evlute reltive to ontext-noe) In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 55 In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 56 Lotion Steps & Pths Lotion Steps & Pths Axis = sequene of noes (is evlute reltive to ontext-noe) Axis = sequene of noes (is evlute reltive to ontext-noe) In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 57 In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 58 Lotion Steps & Pths Lotion Steps & Pths Axis = sequene of noes (is evlute reltive to ontext-noe) Axis = sequene of noes (is evlute reltive to ontext-noe) nestor preeing self esennt following In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 59 In o orer Forwr Axes: hil esennt-or-self esennt -siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer 60 10

11 Context of n XPth evlution: Lotion Pth Evlution (1) ontext-noe (2) ontext position n size (oth non-negtive integers) (3) set of vrile inings (= mppings from vrile nmes to vlues) (4) funtion lirry (= mpping from funtion nmes to funtions) (5) set of nmespe elrtions (tw: ontext position is ontext size) Applition etermines the Initil Context. If pth strts with /, then Initil Context hs ontext-noe = root noe ontext-position = ontext-size = 1 61 Lotion Pth Semntis A Lotion Pth P is sequene of Lotion Steps _1 :: n_1 [ F_1_1 ] [ F_1_2 ] [ F_1_n1 ] / _2 :: n_2 [ F_2_1 ] [ F_2_2 ] [ F_2_n2 ] / _m :: n_m [ F_m_1 ] [ F_m_2 ] [ F_m_nm] S0 = initil sequene of ontext-noes (1) (to eh) ontext-noe N in S0, pply xis _1: gives sequene S1 of noes (2) remove from S1 ny noe M for whih test n_1 evlutes to flse ny of filters F_1_1,,F_1_n1 evlute to flse. Apply steps (1)&(2) for step 2, to otin from S1 the sequene S2 3, S2 S3 m S{m-1} Sm = result of P 62 No Looking Bk Attriute Axis Bkwr Axes re not neee!! How to test ttriute noes Exmples possile to rewrite every XPth query into n equivlent one tht oes not use kwr xes. Very nie result! Cn you see how this oul e one? We sw n exmple of removing nestor xis. But, of ourse the rewritten query must e the sme ON EVERY possile tree!! = 1 = 2 = 1 = 1.0 //ttriute::* Result: ="1" ="1" ="2" ="1.0" Rememer, these re just NODEs. //ttriute::*/. gives sme result Questions how muh lrger oes the query get, when you remove ll kwr xis? Is this useful for effiient query evlution?! An //ttriute::/.. gives < ="1"></>< ="2"></></></></> < ="2"></></></> < ="1.0"></></></> How to test ttriute vlues Attriute Axis & Vlue Tests Exmples How to test ttriute vlues Attriute Axis & Vlue Tests Exmples numer (flot) omprison //*[ttriute::=1] //*[ttriute::=1] (selets the two re noes) (selets the two re noes) = 1 = 1 = 1.0 = 1 = 1 = 1.0 Wth out //*[ttriute::= 1 ] only gives //*[ttriute::= 1.0 ] only gives = 2 = 2 string omprison

12 How to test ttriute vlues Attriute Axis & Vlue Tests Exmples numer (flot) omprison //*[ttriute::=1] (selets the two re noes) Wth out = 1 //*[ttriute::= 1 ] only gives = 1 = 1.0 //*[ttriute::= 1.0 ] only = 2 string omprison ttriute:: is revite How to test ttriute vlues Attriute Axis & Vlue Tests Exmples numer (flot) omprison //*[ttriute::=1] (selets the two re noes) Wth out = 1 //*[ttriute::= 1 ] only gives = 1 = 1.0 //*[ttriute::= 1.0 ] only = 2 string omprison ttriute:: is revite //*[@!="1"] selets oth -noes //*[@>1] selets only left -noe //*[@=//@] selets wht?? (hint: = is string omp. here) Tests in Filters Text Noes or n =,!= <=, <, >=, > The opertors re ll left ssoitive. For exmple, 3 > 2 > 1 is equivlent to (3 > 2) > 1, whih evlutes to flse. But, 3 > 2 > 0.9 evlutes to true. Cn you see why? For two strings u,v Boolen true oere to flot 1.0 How test text noes & vlues = 1 = 1 = 1.0 //text() Result: foo foo Br //*[text()= foo ] Result: the two re noes u<=v u<v u>=v u>v Alwys return flse! Unless oth u n v re numers. [ 1.0 >= 1 ] evlutes to true. = 2 foo foo r Question: Wht is the result for //*[text()=///text()] Useful Funtions (on Boolens) oolen(ojet):oolen Converts rgument into true/flse: numer is true if it is not equl to zero (or NN) noe-set is true if it is non-empty string is true if its length is non-zero - for other ojets, onversion epens on type not(true)=flse, not(flse)=true true():oolen flse():oolen ( oolen mens {true/flse}) lng(string):oolen Returns true if lnguge speifie y xml:lng ttriutes is sme s string ount Counts numer or results = 1 Useful Funtions (on Noe Sets) = 1 = 2 foo foo r /[ount(//*[text()=///text()])=2] Wht is the result? = 1.0 Useful even for use with self-xis: hil::*[self::hpter or self::ppenix] hpter or ppenix hilren of ontext noe

13 Useful Funtions (on Noe Sets) Useful Funtions (on Noe Sets) ount Counts numer or results /[ount(//*[text()=///text()])=2] ount Counts numer or results /[ount(//*[text()=///text()])=2] Wht is the result? Wht is the result? Sme result s: Sme result s: = 1 /[ount(//*[text()="foo"]) > ount(//*[text()="r"])] = 1 /[ount(//*[text()="foo"]) > ount(//*[text()="r"])] = 1 = 1.0 = 1 = 1.0 = 2 foo foo r = 2 foo foo r Wht is the result for: //[ount()=0] (sme s //[not()]) Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext = 1 = 1 = 1.0 //*[position()=2] = 1 = 1 = 1.0 //*[position()=2] //*[position()=2 n../../] Sme s //*[position()=2 n./] = 2 = 2 foo foo r foo foo r Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext = 1 = 1 = 1.0 //*[position()=2] //*[position()=2 n../../] Sme s //*[position()=2 n./] = 1 = 1 = 1.0 //*[position()=2] //*[position()=2 n../../] Sme s //*[position()=2 n./] = 2 = 2 //*[position()=lst()] //*[position()=lst()-1] foo foo r foo foo r

14 Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext = 1 = 1 = 1.0 //*[position()=2] //*[position()=2 n../../] Sme s //*[position()=2 n./] = 1 = 1 = 1.0 //*[position()=2] //*[position()=2 n../../] Sme s //*[position()=2 n./] = 2 = 2 foo foo r //*[position()=lst()-1 n./text()= foo ] foo foo r //*[position()=lst()-1 n./text()= foo ] 79 Useful: hil::*[self::hpter or self::ppenix][position()=lst()] selets the lst hpter or ppenix hil of the ontext noe 80 Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext = 1 = 1 = 1.0 //*[position()=2] //*[position()=2 n../../] Sme s //*[position()=2 n./] = 1 = 1 = 1.0 //*[position()=2] //*[position()=2 n../../] Sme s //*[position()=2 n./] = 2 = 2 foo foo r //*[position()=lst()-1 n./text()= foo ] foo foo r //*[position()=lst()-1 n./text()= foo ] */*[position()=1]/*[position()=2]/*[position()=2] */*[position()=1]/*[position()=2]/*[position()=2] llows solute lotion of ny noe ( l Dewey) 81 Arevition: */*[1]/*[2]/*[2] 82 Useful Funtions (on Noe Sets) Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext Returns ontext-position from the evl. ontext = 1 = 1 = 1.0 = 2 //*[position()=2] //*[position()=2 n../../] Sme s //*[position()=2 n./] ooks ook ook ook ook lst 20 How o you selet the lst 20 ook-hilren of ooks? foo foo r //*[position()=lst()-1 n./text()= foo ] */*[position()=1]/*[position()=2]/*[position()=2] Arevition: */*[1]/*[2]/*[2] Wht is result for //*[./*[2]/*[2]]

15 Useful Funtions (on Noe Sets) lst() returns ontex-size from the evlution ontext Returns ontext-position from the evl. ontext Useful Funtions (on Noe Sets) lst():numer returns ontex-size from the evlution ontext :numer eturns ontext-position from the evl. Context ooks ook ook ook ook lst 20 How o you selet the lst 20 ook-hilren of ooks? /ooks/ook[position()>lst()-20] i(ojet):noe-set i( foo ) selets the element with unique ID foo lol-nme(noe-set?):string returns the lol prt of the expne-nme of the noe nmespe-uri(noe-set?):string returns the nmespe URI of the expne-nme of the noe nme(noe-set?):string returns string ontining QNme representing the expne-nme of the noe Useful Funtions (on Noe Sets) Useful Funtions (on Noe Sets) Noes hve n ientity XPth 2.0 hs muh lerer omprison opertors!! Creful with equlity ( = ) XPth 2.0 hs muh lerer omprison opertors!! <> <>tt</> <>tt</> </> //[*[1]=*[2]] gives empty result. But: //[ontins(*[1],*[2])] gives the -noe. Different noes! Sorry. This is wrong. Equlity ( = ) is se on string vlue of noe! Gives lso -noe string-vlue ( tt ) is ontine in tt <> <> <>re</> <>green</> <>lue</> </> <> <>yellow</> <>ornge</> <>green</> </> </> //[/ = /] selets -noe!!! Sorry. This is wrong. Equlity ( = ) is se on string vlue of noe! Gives lso -noe there exists noe in the noe set for / with sme string vlue s noe in noe set / Useful Funtions (on Noe Sets) Useful Funtions (Strings) Creful with equlity ( = ) XPth 2.0 hs muh lerer omprison opertors!! The string-vlue of n element noe is the ontention of the string-vlues of ll text noe esennts in oument orer. <> <> <>re</> <>green</> <>lue</> </> <> <>yellow</> <>ornge</> <>green</> </> </> //[/ = /] selets -noe!!! Sorry. This is wrong. Equlity ( = ) is se on string vlue of noe! Gives lso -noe there exists noe in the noe set for / with sme string vlue s noe in noe set / = 1 = 1 = 1.0 = 2 foo foo r //*[.="foo"] //*[.= foor ] Wht out //[/!= /]

16 Useful Funtions (Strings) The string-vlue of n element noe is the ontention of the string-vlues of ll text noe esennts in oument orer. //*[.="foo"] //*[.= foor ] Useful Funtions (Strings) The string-vlue of n element noe is the ontention of the string-vlues of ll text noe esennts in oument orer. //*[.="foo"] //*[.= foor ] = 1 = 1 = 1.0 = 2 foo foo r ont(st_1, st_2,, st_n) = st_1 st_2 st_n strtswith(, ) = true ontins( r, ) = true sustring-efore("1999/04/01","/") = sustring-fter("1999/04/01","19") = 99/04/01 sustring("12345",2,3) = 234 string-length( foo ) = 3 normlize-spe( foo r ) = foo r trnslte( r","","abc") = BAr returns the first rgument string with ourrenes of hrters in the seon rgument string reple y the hrter t the orresponing position in the thir rgument string NOTE: The trnslte funtion is not suffiient solution for se onversion in ll lnguges Wht is the result to this: //*[ontins(.,"r")] Useful Funtions (Numers) Disply Numer Result numer(ojet):numer Opertors on Numers +,-,*,iv,mo Converts rgument to numer - the oolen true is onverte to 1, flse is onverte to 0 - string tht onsists of optionl whitespe followe y n optionl minus sign followe y Numer followe y whitespe is onverte to the IEEE 754 numer tht is nerest to the mthemtil vlue represente y the string. sum(noe-set):numer returns sum, for eh noe in the rgument noe-set, of the result of onverting the string-vlues of the noe to numer floor(numer):numer returns lrgest integer tht is not greter thn the rgument eiling(numer):numer returns the smllest integer tht is not less thn the rgument roun(numer):numer returns integer losest to the rgument. (if there re 2, tke ove: roun(0.5)=1 n roun(-0.5)=0 //*[text()=(7 mo (ount(//)+2))]/text() k n n n Use n Disply Numer Result XPth Query Evlution //*[text()=7 mo ((ount(//)+2)]/text() How to implement? How expensive? omplexity? k Wht re the most iffiult queries? n n n n Next time Effiient Algorithms: whih queries run how fst? First, fous on nvigtionl queries: only /, //, lel-test, [ filters ] (tehniques for vlue omprison/queries lrey well-known from rel. DB s ) Similr for ritrry lrge numers / oolens, noe-sets Try it

17 ontext noe mens yer 2003 Experiments with urrent systems Doument: <> </> </> </> Xpth Query (reltive to ): hil::*/prent::*/hil::*/ prent::*/hil::* Next 4 slies from Georg Gottlo n Christoph Koh "XPth Query Proessing". Invite tutoril t DBPL Tree of noes visite is of size Q O( D )!!! exponentil! qurti Doument: <></></></> Core Xpth on Xln n XT Queries: //prent::// prent::/ Core Xpth on Mirosoft IE6: polynomil omine omplexity, qurti t omplexity XPth Query Evlution Full XPth on IE6: Exponentil omine omplexity! Exponentil query omplexity Stti Methos (use, e.g., for Query Optimiztion ) Given Xpth queries Q1, Q2: Is result set of Q1 inlue in result set of Q2? Are result sets equl? Is their intersetion empty? for ll possile ouments (proly we will look t this in Leture 8 or 9)

18 Simple Exmples Is //[ount()=ount(*)] equivlent to //[not(hil::*[not(self::)])] END Leture 6 on ll possile trees?

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved. Chpter 9 Greey Tehnique Copyright 2007 Person Aison-Wesley. All rights reserve. Greey Tehnique Construts solution to n optimiztion prolem piee y piee through sequene of hoies tht re: fesile lolly optiml

More information

COMPUTER EDUCATION TECHNIQUES, INC. (XML ) SA:

COMPUTER EDUCATION TECHNIQUES, INC. (XML ) SA: In orer to lern whih questions hve een nswere orretly: 1. Print these pges. 2. Answer the questions. 3. Sen this ssessment with the nswers vi:. FAX to (212) 967-3498. Or. Mil the nswers to the following

More information

Class Overview. Database Design. Database Design Process. Database Design. Introduction to Data Management CSE 414

Class Overview. Database Design. Database Design Process. Database Design. Introduction to Data Management CSE 414 Introution to Dt Mngement CSE 44 Unit 6: Coneptul Design E/R Digrms Integrity Constrints BCNF Introution to Dt Mngement CSE 44 E/R Digrms ( letures) CSE 44 Autumn 08 Clss Overview Dtse Design Unit : Intro

More information

CS 241 Week 4 Tutorial Solutions

CS 241 Week 4 Tutorial Solutions CS 4 Week 4 Tutoril Solutions Writing n Assemler, Prt & Regulr Lnguges Prt Winter 8 Assemling instrutions utomtilly. slt $d, $s, $t. Solution: $d, $s, nd $t ll fit in -it signed integers sine they re 5-it

More information

XML and Databases. Sebastian Maneth NICTA and UNSW. Lecture 2 Memory Representations for XML: Space vs Access Speed. -- Semester 1, 2010

XML and Databases. Sebastian Maneth NICTA and UNSW. Lecture 2 Memory Representations for XML: Space vs Access Speed. -- Semester 1, 2010 1 XML n Dtbses Leture 2 Memory Representtions for XML: Spe vs Aess Spee Sebstin Mneth NICTA n UNSW CSE@UNSW -- Semester 1, 2010 2 XML n Dtbses Leture 2 Memory Representtions for XML: Spe vs Aess Spee Sebstin

More information

CMPUT101 Introduction to Computing - Summer 2002

CMPUT101 Introduction to Computing - Summer 2002 CMPUT Introdution to Computing - Summer 22 %XLOGLQJ&RPSXWHU&LUFXLWV Chpter 4.4 3XUSRVH We hve looked t so fr how to uild logi gtes from trnsistors. Next we will look t how to uild iruits from logi gtes,

More information

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string. CS 340, Fll 2016 Sep 29th Exm 1 Nme: Note: in ll questions, the speil symol ɛ (epsilon) is used to indite the empty string. Question 1. [10 points] Speify regulr expression tht genertes the lnguge over

More information

Advanced Programming Handout 5. Enter Okasaki. Persistent vs. Ephemeral. Functional Queues. Simple Example. Persistent vs.

Advanced Programming Handout 5. Enter Okasaki. Persistent vs. Ephemeral. Functional Queues. Simple Example. Persistent vs. Avne Progrmming Hnout 5 Purel Funtionl Dt Strutures: A Cse Stu in Funtionl Progrmming Persistent vs. Ephemerl An ephemerl t struture is one for whih onl one version is ville t time: fter n upte opertion,

More information

Type Checking. Roadmap (Where are we?) Last lecture Context-sensitive analysis. This lecture Type checking. Symbol tables

Type Checking. Roadmap (Where are we?) Last lecture Context-sensitive analysis. This lecture Type checking. Symbol tables Type Cheking Rodmp (Where re we?) Lst leture Contet-sensitie nlysis Motition Attriute grmmrs Ad ho Synt-direted trnsltion This leture Type heking Type systems Using synt direted trnsltion Symol tles Leil

More information

CS 551 Computer Graphics. Hidden Surface Elimination. Z-Buffering. Basic idea: Hidden Surface Removal

CS 551 Computer Graphics. Hidden Surface Elimination. Z-Buffering. Basic idea: Hidden Surface Removal CS 55 Computer Grphis Hidden Surfe Removl Hidden Surfe Elimintion Ojet preision lgorithms: determine whih ojets re in front of others Uses the Pinter s lgorithm drw visile surfes from k (frthest) to front

More information

Greedy Algorithm. Algorithm Fall Semester

Greedy Algorithm. Algorithm Fall Semester Greey Algorithm Algorithm 0 Fll Semester Optimiztion prolems An optimiztion prolem is one in whih you wnt to fin, not just solution, ut the est solution A greey lgorithm sometimes works well for optimiztion

More information

10.2 Graph Terminology and Special Types of Graphs

10.2 Graph Terminology and Special Types of Graphs 10.2 Grph Terminology n Speil Types of Grphs Definition 1. Two verties u n v in n unirete grph G re lle jent (or neighors) in G iff u n v re enpoints of n ege e of G. Suh n ege e is lle inient with the

More information

CS201 Discussion 10 DRAWTREE + TRIES

CS201 Discussion 10 DRAWTREE + TRIES CS201 Discussion 10 DRAWTREE + TRIES DrwTree First instinct: recursion As very generic structure, we could tckle this problem s follows: drw(): Find the root drw(root) drw(root): Write the line for the

More information

Pattern Matching. Pattern Matching. Pattern Matching. Review of Regular Expressions

Pattern Matching. Pattern Matching. Pattern Matching. Review of Regular Expressions Pttern Mthing Pttern Mthing Some of these leture slides hve een dpted from: lgorithms in C, Roert Sedgewik. Gol. Generlize string serhing to inompletely speified ptterns. pplitions. Test if string or its

More information

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards A Tutology Checker loosely relted to Stålmrck s Algorithm y Mrtin Richrds mr@cl.cm.c.uk http://www.cl.cm.c.uk/users/mr/ University Computer Lortory New Museum Site Pemroke Street Cmridge, CB2 3QG Mrtin

More information

COMMON FRACTIONS. or a / b = a b. , a is called the numerator, and b is called the denominator.

COMMON FRACTIONS. or a / b = a b. , a is called the numerator, and b is called the denominator. COMMON FRACTIONS BASIC DEFINITIONS * A frtion is n inite ivision. or / * In the frtion is lle the numertor n is lle the enomintor. * The whole is seprte into "" equl prts n we re onsiering "" of those

More information

MITSUBISHI ELECTRIC RESEARCH LABORATORIES Cambridge, Massachusetts. Introduction to Matroids and Applications. Srikumar Ramalingam

MITSUBISHI ELECTRIC RESEARCH LABORATORIES Cambridge, Massachusetts. Introduction to Matroids and Applications. Srikumar Ramalingam Cmrige, Msshusetts Introution to Mtrois n Applitions Srikumr Rmlingm MERL mm//yy Liner Alger (,0,0) (0,,0) Liner inepenene in vetors: v, v2,..., For ll non-trivil we hve s v s v n s, s2,..., s n 2v2...

More information

Introduction to Algebra

Introduction to Algebra INTRODUCTORY ALGEBRA Mini-Leture 1.1 Introdution to Alger Evlute lgeri expressions y sustitution. Trnslte phrses to lgeri expressions. 1. Evlute the expressions when =, =, nd = 6. ) d) 5 10. Trnslte eh

More information

Compilers Spring 2013 PRACTICE Midterm Exam

Compilers Spring 2013 PRACTICE Midterm Exam Compilers Spring 2013 PRACTICE Midterm Exm This is full length prctice midterm exm. If you wnt to tke it t exm pce, give yourself 7 minutes to tke the entire test. Just like the rel exm, ech question hs

More information

Distance vector protocol

Distance vector protocol istne vetor protool Irene Finohi finohi@i.unirom.it Routing Routing protool Gol: etermine goo pth (sequene of routers) thru network from soure to Grph strtion for routing lgorithms: grph noes re routers

More information

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

In the last lecture, we discussed how valid tokens may be specified by regular expressions. LECTURE 5 Scnning SYNTAX ANALYSIS We know from our previous lectures tht the process of verifying the syntx of the progrm is performed in two stges: Scnning: Identifying nd verifying tokens in progrm.

More information

Paradigm 5. Data Structure. Suffix trees. What is a suffix tree? Suffix tree. Simple applications. Simple applications. Algorithms

Paradigm 5. Data Structure. Suffix trees. What is a suffix tree? Suffix tree. Simple applications. Simple applications. Algorithms Prdigm. Dt Struture Known exmples: link tble, hep, Our leture: suffix tree Will involve mortize method tht will be stressed shortly in this ourse Suffix trees Wht is suffix tree? Simple pplitions History

More information

Dr. D.M. Akbar Hussain

Dr. D.M. Akbar Hussain Dr. D.M. Akr Hussin Lexicl Anlysis. Bsic Ide: Red the source code nd generte tokens, it is similr wht humns will do to red in; just tking on the input nd reking it down in pieces. Ech token is sequence

More information

Section 2.3 Functions. Definition: Let A and B be sets. A function (mapping, map) f from A to B, denoted f :A B, is a subset of A B such that

Section 2.3 Functions. Definition: Let A and B be sets. A function (mapping, map) f from A to B, denoted f :A B, is a subset of A B such that Setion 2.3 Funtions Definition: Let n e sets. funtion (mpping, mp) f from to, enote f :, is suset of suh tht x[x y[y < x, y > f ]] n [< x, y 1 > f < x, y 2 > f ] y 1 = y 2 Note: f ssoites with eh x in

More information

CSc 453 Compilers and Systems Software. 6 : Top-Down Parsing I

CSc 453 Compilers and Systems Software. 6 : Top-Down Parsing I C 45 Compilers n ystems oftwre 6 : op-down Prsing I Christin Collberg Deprtment of Computer iene University of rizon ollberg@gmil.om Copyright 2009 Christin Collberg eptember 14, 2009 1 Overview 2 Compiler

More information

Lecture 13: Graphs I: Breadth First Search

Lecture 13: Graphs I: Breadth First Search Leture 13 Grphs I: BFS 6.006 Fll 2011 Leture 13: Grphs I: Bredth First Serh Leture Overview Applitions of Grph Serh Grph Representtions Bredth-First Serh Rell: Grph G = (V, E) V = set of verties (ritrry

More information

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5 CS321 Lnguges nd Compiler Design I Winter 2012 Lecture 5 1 FINITE AUTOMATA A non-deterministic finite utomton (NFA) consists of: An input lphet Σ, e.g. Σ =,. A set of sttes S, e.g. S = {1, 3, 5, 7, 11,

More information

A matching algorithm for measuring the structural similarity between an XML document and a DTD and its applications $

A matching algorithm for measuring the structural similarity between an XML document and a DTD and its applications $ Informtion Systems 29 (2004) 23 46 A mthing lgorithm for mesuring the struturl similrity etween n XML oument n DTD n its pplitions $ Elis Bertino, Giovnn Guerrini, Mro Mesiti, * Diprtimento i Informti

More information

Asurveyofpractical algorithms for suffix tree construction in external memory

Asurveyofpractical algorithms for suffix tree construction in external memory Asurveyofprtil lgorithms for suffix tree onstrution in externl memory M. Brsky,, U. Stege n A. Thomo University of Vitori, PO Box, STN CSC Vitori, BC, VW P, Cn SUMMAY The onstrution of suffix trees in

More information

CSCE 531, Spring 2017, Midterm Exam Answer Key

CSCE 531, Spring 2017, Midterm Exam Answer Key CCE 531, pring 2017, Midterm Exm Answer Key 1. (15 points) Using the method descried in the ook or in clss, convert the following regulr expression into n equivlent (nondeterministic) finite utomton: (

More information

Midterm Exam CSC October 2001

Midterm Exam CSC October 2001 Midterm Exm CSC 173 23 Otoer 2001 Diretions This exm hs 8 questions, severl of whih hve suprts. Eh question indites its point vlue. The totl is 100 points. Questions 5() nd 6() re optionl; they re not

More information

COMP 423 lecture 11 Jan. 28, 2008

COMP 423 lecture 11 Jan. 28, 2008 COMP 423 lecture 11 Jn. 28, 2008 Up to now, we hve looked t how some symols in n lphet occur more frequently thn others nd how we cn sve its y using code such tht the codewords for more frequently occuring

More information

Containers: Queue and List

Containers: Queue and List Continers: Queue n List Queue A ontiner in whih insertion is one t one en (the til) n eletion is one t the other en (the he). Also lle FIFO (First-In, First-Out) Jori Cortell n Jori Petit Deprtment of

More information

Ma/CS 6b Class 1: Graph Recap

Ma/CS 6b Class 1: Graph Recap M/CS 6 Clss 1: Grph Recp By Adm Sheffer Course Detils Adm Sheffer. Office hour: Tuesdys 4pm. dmsh@cltech.edu TA: Victor Kstkin. Office hour: Tuesdys 7pm. 1:00 Mondy, Wednesdy, nd Fridy. http://www.mth.cltech.edu/~2014-15/2term/m006/

More information

Bayesian Networks: Directed Markov Properties (Cont d) and Markov Equivalent DAGs

Bayesian Networks: Directed Markov Properties (Cont d) and Markov Equivalent DAGs Byesin Networks: Direte Mrkov Properties (Cont ) n Mrkov Equivlent DAGs Huizhen Yu jney.yu@s.helsinki.fi Dept. Computer Siene, Univ. of Helsinki Proilisti Moels, Spring, 2010 Huizhen Yu (U.H.) Byesin Networks:

More information

Error Numbers of the Standard Function Block

Error Numbers of the Standard Function Block A.2.2 Numers of the Stndrd Funtion Blok evlution The result of the logi opertion RLO is set if n error ours while the stndrd funtion lok is eing proessed. This llows you to rnh to your own error evlution

More information

V = set of vertices (vertex / node) E = set of edges (v, w) (v, w in V)

V = set of vertices (vertex / node) E = set of edges (v, w) (v, w in V) Definitions G = (V, E) V = set of verties (vertex / noe) E = set of eges (v, w) (v, w in V) (v, w) orere => irete grph (igrph) (v, w) non-orere => unirete grph igrph: w is jent to v if there is n ege from

More information

Distributed Systems Principles and Paradigms

Distributed Systems Principles and Paradigms Distriuted Systems Priniples nd Prdigms Christoph Dorn Distriuted Systems Group, Vienn University of Tehnology.dorn@infosys.tuwien..t http://www.infosys.tuwien..t/stff/dorn Slides dpted from Mrten vn Steen,

More information

From Dependencies to Evaluation Strategies

From Dependencies to Evaluation Strategies From Dependencies to Evlution Strtegies Possile strtegies: 1 let the user define the evlution order 2 utomtic strtegy sed on the dependencies: use locl dependencies to determine which ttriutes to compute

More information

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016 Solving Prolems y Serching CS 486/686: Introduction to Artificil Intelligence Winter 2016 1 Introduction Serch ws one of the first topics studied in AI - Newell nd Simon (1961) Generl Prolem Solver Centrl

More information

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22)

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22) Homework Context Free Lnguges III Prse Trees nd Homework #5 (due 10/22) From textbook 6.4,b 6.5b 6.9b,c 6.13 6.22 Pln for tody Context Free Lnguges Next clss of lnguges in our quest! Lnguges Recll. Wht

More information

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example:

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example: Boxes nd Arrows There re two kinds of vriles in Jv: those tht store primitive vlues nd those tht store references. Primitive vlues re vlues of type long, int, short, chr, yte, oolen, doule, nd flot. References

More information

Comparison-based Choices

Comparison-based Choices Comprison-se Choies John Ugner Mngement Siene & Engineering Stnfor University Joint work with: Jon Kleinerg (Cornell) Senhil Mullinthn (Hrvr) EC 17 Boston June 28, 2017 Preiting isrete hoies Clssi prolem:

More information

Functor (1A) Young Won Lim 8/2/17

Functor (1A) Young Won Lim 8/2/17 Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published

More information

FEEDBACK: The standard error of a regression is not an unbiased estimator for the standard deviation of the error in a multiple regression model.

FEEDBACK: The standard error of a regression is not an unbiased estimator for the standard deviation of the error in a multiple regression model. Introutory Eonometris: A Moern Approh 6th Eition Woolrige Test Bnk Solutions Complete ownlo: https://testbnkre.om/ownlo/introutory-eonometris-moern-pproh-6th-eition-jeffreym-woolrige-test-bnk/ Solutions

More information

Lexical Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

Lexical Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Lexicl Anlysis Amith Snyl (www.cse.iit.c.in/ s) Deprtment of Computer Science nd Engineering, Indin Institute of Technology, Bomy Septemer 27 College of Engineering, Pune Lexicl Anlysis: 2/6 Recp The input

More information

Definition of Regular Expression

Definition of Regular Expression Definition of Regulr Expression After the definition of the string nd lnguges, we re redy to descrie regulr expressions, the nottion we shll use to define the clss of lnguges known s regulr sets. Recll

More information

Functor (1A) Young Won Lim 10/5/17

Functor (1A) Young Won Lim 10/5/17 Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published

More information

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 21 Sndiwy Fong Tody's Topics Homework 8 Review Optionl Homework 9 (mke up on Homework 7) Homework 8 Review Question1: write Prolog regulr grmmr for the following lnguge:

More information

COMP108 Algorithmic Foundations

COMP108 Algorithmic Foundations Grph Theory Prudene Wong http://www.s.liv..uk/~pwong/tehing/omp108/201617 How to Mesure 4L? 3L 5L 3L ontiner & 5L ontiner (without mrk) infinite supply of wter You n pour wter from one ontiner to nother

More information

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries Tries Yufei To KAIST April 9, 2013 Y. To, April 9, 2013 Tries In this lecture, we will discuss the following exct mtching prolem on strings. Prolem Let S e set of strings, ech of which hs unique integer

More information

Distributed Systems Principles and Paradigms. Chapter 11: Distributed File Systems

Distributed Systems Principles and Paradigms. Chapter 11: Distributed File Systems Distriuted Systems Priniples nd Prdigms Mrten vn Steen VU Amsterdm, Dept. Computer Siene steen@s.vu.nl Chpter 11: Distriuted File Systems Version: Deemer 10, 2012 2 / 14 Distriuted File Systems Distriuted

More information

Generating Editors for Direct Manipulation of Diagrams

Generating Editors for Direct Manipulation of Diagrams Generting Eitors for Diret Mnipultion of Digrms Gerhr Viehstet n Mrk Mins Lehrstuhl für Progrmmiersprhen Universität Erlngen-Nürnerg Mrtensstr. 3, 91058 Erlngen, Germny E-mil: fviehste,minsg@informtik.uni-erlngen.e

More information

Hash-based Subgraph Query Processing Method for Graph-structured XML Documents

Hash-based Subgraph Query Processing Method for Graph-structured XML Documents Hsh-bse Subgrph Query Proessing Metho for Grph-struture XML Douments Hongzhi Wng Hrbin Institute of Teh. wngzh@hit.eu.n Jinzhong Li Hrbin Institute of Teh. lijzh@hit.eu.n Jizhou Luo Hrbin Institute of

More information

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs. Lecture 5 Wlks, Trils, Pths nd Connectedness Reding: Some of the mteril in this lecture comes from Section 1.2 of Dieter Jungnickel (2008), Grphs, Networks nd Algorithms, 3rd edition, which is ville online

More information

Parallelization Optimization of System-Level Specification

Parallelization Optimization of System-Level Specification Prlleliztion Optimiztion of System-Level Speifition Luki i niel. Gjski enter for Emedded omputer Systems University of liforni Irvine, 92697, US {li, gjski} @es.ui.edu strt This pper introdues the prlleliztion

More information

Ma/CS 6b Class 1: Graph Recap

Ma/CS 6b Class 1: Graph Recap M/CS 6 Clss 1: Grph Recp By Adm Sheffer Course Detils Instructor: Adm Sheffer. TA: Cosmin Pohot. 1pm Mondys, Wednesdys, nd Fridys. http://mth.cltech.edu/~2015-16/2term/m006/ Min ook: Introduction to Grph

More information

GENG2140 Modelling and Computer Analysis for Engineers

GENG2140 Modelling and Computer Analysis for Engineers GENG4 Moelling n Computer Anlysis or Engineers Letures 9 & : Gussin qurture Crete y Grn Romn Joles, PhD Shool o Mehnil Engineering, UWA GENG4 Content Deinition o Gussin qurture Computtion o weights n points

More information

COMPUTER EDUCATION TECHNIQUES, INC. (WEBLOGIC_SVR_ADM ) SA:

COMPUTER EDUCATION TECHNIQUES, INC. (WEBLOGIC_SVR_ADM ) SA: In orer to lern whih questions hve een nswere orretly: 1. Print these pges. 2. Answer the questions. 3. Sen this ssessment with the nswers vi:. FAX to (212) 967-3498. Or. Mil the nswers to the following

More information

Table-driven look-ahead lexical analysis

Table-driven look-ahead lexical analysis Tle-riven look-he lexil nlysis WUU YANG Computer n Informtion Siene Deprtment Ntionl Chio-Tung University, HsinChu, Tiwn, R.O.C. Astrt. Moern progrmming lnguges use regulr expressions to efine vli tokens.

More information

AI Adjacent Fields. This slide deck courtesy of Dan Klein at UC Berkeley

AI Adjacent Fields. This slide deck courtesy of Dan Klein at UC Berkeley AI Adjcent Fields Philosophy: Logic, methods of resoning Mind s physicl system Foundtions of lerning, lnguge, rtionlity Mthemtics Forml representtion nd proof Algorithms, computtion, (un)decidility, (in)trctility

More information

10.5 Graphing Quadratic Functions

10.5 Graphing Quadratic Functions 0.5 Grphing Qudrtic Functions Now tht we cn solve qudrtic equtions, we wnt to lern how to grph the function ssocited with the qudrtic eqution. We cll this the qudrtic function. Grphs of Qudrtic Functions

More information

Minimal Memory Abstractions

Minimal Memory Abstractions Miniml Memory Astrtions (As implemented for BioWre Corp ) Nthn Sturtevnt University of Alert GAMES Group Ferury, 7 Tlk Overview Prt I: Building Astrtions Minimizing memory requirements Performnes mesures

More information

Agenda & Reading. Class Exercise. COMPSCI 105 SS 2012 Principles of Computer Science. Arrays

Agenda & Reading. Class Exercise. COMPSCI 105 SS 2012 Principles of Computer Science. Arrays COMPSCI 5 SS Principles of Computer Science Arrys & Multidimensionl Arrys Agend & Reding Agend Arrys Creting & Using Primitive & Reference Types Assignments & Equlity Pss y Vlue & Pss y Reference Copying

More information

MTH 146 Conics Supplement

MTH 146 Conics Supplement 105- Review of Conics MTH 146 Conics Supplement In this section we review conics If ou ne more detils thn re present in the notes, r through section 105 of the ook Definition: A prol is the set of points

More information

Final Exam Review F 06 M 236 Be sure to look over all of your tests, as well as over the activities you did in the activity book

Final Exam Review F 06 M 236 Be sure to look over all of your tests, as well as over the activities you did in the activity book inl xm Review 06 M 236 e sure to loo over ll of your tests, s well s over the tivities you did in the tivity oo 1 1. ind the mesures of the numered ngles nd justify your wor. Line j is prllel to line.

More information

Lesson 4.4. Euler Circuits and Paths. Explore This

Lesson 4.4. Euler Circuits and Paths. Explore This Lesson 4.4 Euler Ciruits nd Pths Now tht you re fmilir with some of the onepts of grphs nd the wy grphs onvey onnetions nd reltionships, it s time to egin exploring how they n e used to model mny different

More information

Lecture 12 : Topological Spaces

Lecture 12 : Topological Spaces Leture 12 : Topologil Spes 1 Topologil Spes Topology generlizes notion of distne nd loseness et. Definition 1.1. A topology on set X is olletion T of susets of X hving the following properties. 1. nd X

More information

What are suffix trees?

What are suffix trees? Suffix Trees 1 Wht re suffix trees? Allow lgorithm designers to store very lrge mount of informtion out strings while still keeping within liner spce Allow users to serch for new strings in the originl

More information

CS553 Lecture Introduction to Data-flow Analysis 1

CS553 Lecture Introduction to Data-flow Analysis 1 ! Ide Introdution to Dt-flow nlysis!lst Time! Implementing Mrk nd Sweep GC!Tody! Control flow grphs! Liveness nlysis! Register llotion CS553 Leture Introdution to Dt-flow Anlysis 1 Dt-flow Anlysis! Dt-flow

More information

WORKSHOP 19 GLOBAL/LOCAL MODELING USING FEM FIELDS

WORKSHOP 19 GLOBAL/LOCAL MODELING USING FEM FIELDS WORKSHOP 19 GLOBAL/LOCAL MODELING USING FEM FIELDS WS19-1 WS19-2 Prolem Desription This exerise is use to emonstrte how to mp isplement results from the nlysis of glol(overll) moel onto the perimeter of

More information

5 ANGLES AND POLYGONS

5 ANGLES AND POLYGONS 5 GLES POLYGOS urling rige looks like onventionl rige when it is extene. However, it urls up to form n otgon to llow ots through. This Rolling rige is in Pington sin in Lonon, n urls up every Friy t miy.

More information

Lecture 7: Integration Techniques

Lecture 7: Integration Techniques Lecture 7: Integrtion Techniques Antiderivtives nd Indefinite Integrls. In differentil clculus, we were interested in the derivtive of given rel-vlued function, whether it ws lgeric, eponentil or logrithmic.

More information

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig CS311H: Discrete Mthemtics Grph Theory IV Instructor: Işıl Dillig Instructor: Işıl Dillig, CS311H: Discrete Mthemtics Grph Theory IV 1/25 A Non-plnr Grph Regions of Plnr Grph The plnr representtion of

More information

Theory of Computation CSE 105

Theory of Computation CSE 105 $ $ $ Theory of Computtion CSE 105 Regulr Lnguges Study Guide nd Homework I Homework I: Solutions to the following problems should be turned in clss on July 1, 1999. Instructions: Write your nswers clerly

More information

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2: Solutions. Please write your name in the upper corner of each page.

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2: Solutions. Please write your name in the upper corner of each page. 6045J/18400J: Automt, Computbility nd Complexity Mrh 30, 2005 Quiz 2: Solutions Prof Nny Lynh Vinod Vikuntnthn Plese write your nme in the upper orner of eh pge Problem Sore 1 2 3 4 5 6 Totl Q2-1 Problem

More information

Solids. Solids. Curriculum Ready.

Solids. Solids. Curriculum Ready. Curriulum Rey www.mthletis.om This ooklet is ll out ientifying, rwing n mesuring solis n prisms. SOM CUES The Som Cue ws invente y Dnish sientist who went y the nme of Piet Hein. It is simple 3 # 3 #

More information

LR Parsing, Part 2. Constructing Parse Tables. Need to Automatically Construct LR Parse Tables: Action and GOTO Table

LR Parsing, Part 2. Constructing Parse Tables. Need to Automatically Construct LR Parse Tables: Action and GOTO Table TDDD55 Compilers nd Interpreters TDDB44 Compiler Construction LR Prsing, Prt 2 Constructing Prse Tles Prse tle construction Grmmr conflict hndling Ctegories of LR Grmmrs nd Prsers Peter Fritzson, Christoph

More information

CSE 401 Midterm Exam 11/5/10 Sample Solution

CSE 401 Midterm Exam 11/5/10 Sample Solution Question 1. egulr expressions (20 points) In the Ad Progrmming lnguge n integer constnt contins one or more digits, but it my lso contin embedded underscores. Any underscores must be preceded nd followed

More information

COMBINATORIAL PATTERN MATCHING

COMBINATORIAL PATTERN MATCHING COMBINATORIAL PATTERN MATCHING Genomic Repets Exmple of repets: ATGGTCTAGGTCCTAGTGGTC Motivtion to find them: Genomic rerrngements re often ssocited with repets Trce evolutionry secrets Mny tumors re chrcterized

More information

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example:

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example: cisc1110 fll 2010 lecture VI.2 cll y vlue function prmeters more on functions more on cll y vlue nd cll y reference pssing strings to functions returning strings from functions vrile scope glol vriles

More information

Pipeline Example: Cycle 1. Pipeline Example: Cycle 2. Pipeline Example: Cycle 4. Pipeline Example: Cycle 3. 3 instructions. 3 instructions.

Pipeline Example: Cycle 1. Pipeline Example: Cycle 2. Pipeline Example: Cycle 4. Pipeline Example: Cycle 3. 3 instructions. 3 instructions. ipeline Exmple: Cycle 1 ipeline Exmple: Cycle X X/ /W X X/ /W $3,$,$1 lw $,0($5) $3,$,$1 3 instructions 8 9 ipeline Exmple: Cycle 3 ipeline Exmple: Cycle X X/ /W X X/ /W sw $6,($7) lw $,0($5) $3,$,$1 sw

More information

COMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples

COMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples COMPUTER SCIENCE 123 Foundtions of Computer Science 6. Tuples Summry: This lecture introduces tuples in Hskell. Reference: Thompson Sections 5.1 2 R.L. While, 2000 3 Tuples Most dt comes with structure

More information

Approximate Joins for Data Centric XML

Approximate Joins for Data Centric XML Approximte Joins for Dt Centri XML Nikolus Augsten 1, Mihel Böhlen 1, Curtis Dyreson, Johnn Gmper 1 1 Fulty of Computer Siene, Free University of Bozen-Bolzno Dominiknerpltz 3, Bozen, Itly {ugsten,oehlen,gmper}@inf.uniz.it

More information

Graph theory Route problems

Graph theory Route problems Bhelors thesis Grph theory Route prolems Author: Aolphe Nikwigize Dte: 986 - -5 Sujet: Mthemtis Level: First level (Bhelor) Course oe: MAE Astrt In this thesis we will review some route prolems whih re

More information

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures Other Issues Stck Mnipultion support for procedures (Refer to section 3.6), stcks, frmes, recursion mnipulting strings nd pointers linkers, loders, memory lyout Interrupts, exceptions, system clls nd conventions

More information

Lecture 8: Graph-theoretic problems (again)

Lecture 8: Graph-theoretic problems (again) COMP36111: Advned Algorithms I Leture 8: Grph-theoreti prolems (gin) In Prtt-Hrtmnn Room KB2.38: emil: iprtt@s.mn..uk 2017 18 Reding for this leture: Sipser: Chpter 7. A grph is pir G = (V, E), where V

More information

Problem Final Exam Set 2 Solutions

Problem Final Exam Set 2 Solutions CSE 5 5 Algoritms nd nd Progrms Prolem Finl Exm Set Solutions Jontn Turner Exm - //05 0/8/0. (5 points) Suppose you re implementing grp lgoritm tt uses ep s one of its primry dt strutures. Te lgoritm does

More information

CS 236 Language and Computation. Alphabet. Definition. I.2.1. Formal Languages (10.1)

CS 236 Language and Computation. Alphabet. Definition. I.2.1. Formal Languages (10.1) C 236 Lnguge nd Computtion Course Notes Prt I: Grmmrs for Defining yntx (II) Chpter I.2: yntx nd Grmmrs (10, 12.1) Anton etzer (Bsed on ook drft y J. V. Tucker nd K. tephenson) Dept. of Computer cience,

More information

Premaster Course Algorithms 1 Chapter 6: Shortest Paths. Christian Scheideler SS 2018

Premaster Course Algorithms 1 Chapter 6: Shortest Paths. Christian Scheideler SS 2018 Premster Course Algorithms Chpter 6: Shortest Pths Christin Scheieler SS 8 Bsic Grph Algorithms Overview: Shortest pths in DAGs Dijkstr s lgorithm Bellmn-For lgorithm Johnson s metho SS 8 Chpter 6 Shortest

More information

Slides for Data Mining by I. H. Witten and E. Frank

Slides for Data Mining by I. H. Witten and E. Frank Slides for Dt Mining y I. H. Witten nd E. Frnk Simplicity first Simple lgorithms often work very well! There re mny kinds of simple structure, eg: One ttriute does ll the work All ttriutes contriute eqully

More information

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Solving Prolems y Serching CS 486/686: Introduction to Artificil Intelligence 1 Introduction Serch ws one of the first topics studied in AI - Newell nd Simon (1961) Generl Prolem Solver Centrl component

More information

this grammar generates the following language: Because this symbol will also be used in a later step, it receives the

this grammar generates the following language: Because this symbol will also be used in a later step, it receives the LR() nlysis Drwcks of LR(). Look-hed symols s eplined efore, concerning LR(), it is possile to consult the net set to determine, in the reduction sttes, for which symols it would e possile to perform reductions.

More information

Outline. CS38 Introduction to Algorithms. Graphs. Graphs. Graphs. Graph traversals

Outline. CS38 Introduction to Algorithms. Graphs. Graphs. Graphs. Graph traversals Outline CS38 Introution to Algorithms Leture 2 April 3, 2014 grph trversls (BFS, DFS) onnetivity topologil sort strongly onnete omponents heps n hepsort greey lgorithms April 3, 2014 CS38 Leture 2 2 Grphs

More information

Representation of Numbers. Number Representation. Representation of Numbers. 32-bit Unsigned Integers 3/24/2014. Fixed point Integer Representation

Representation of Numbers. Number Representation. Representation of Numbers. 32-bit Unsigned Integers 3/24/2014. Fixed point Integer Representation Representtion of Numbers Number Representtion Computer represent ll numbers, other thn integers nd some frctions with imprecision. Numbers re stored in some pproximtion which cn be represented by fixed

More information

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy Recognition of Tokens if expressions nd reltionl opertors if è if then è then else è else relop

More information

12/9/14. CS151 Fall 20124Lecture (almost there) 12/6. Graphs. Seven Bridges of Königsberg. Leonard Euler

12/9/14. CS151 Fall 20124Lecture (almost there) 12/6. Graphs. Seven Bridges of Königsberg. Leonard Euler CS5 Fll 04Leture (lmost there) /6 Seven Bridges of Königserg Grphs Prof. Tny Berger-Wolf Leonrd Euler 707-783 Is it possile to wlk with route tht rosses eh ridge e Seven Bridges of Königserg Forget unimportnt

More information

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits Systems I Logic Design I Topics Digitl logic Logic gtes Simple comintionl logic circuits Simple C sttement.. C = + ; Wht pieces of hrdwre do you think you might need? Storge - for vlues,, C Computtion

More information

Fault tree conversion to binary decision diagrams

Fault tree conversion to binary decision diagrams Loughorough University Institutionl Repository Fult tree onversion to inry deision digrms This item ws sumitted to Loughorough University's Institutionl Repository y the/n uthor. Cittion: ANDREWS, J.D.

More information

Lists in Lisp and Scheme

Lists in Lisp and Scheme Lists in Lisp nd Scheme Lists in Lisp nd Scheme Lists re Lisp s fundmentl dt structures, ut there re others Arrys, chrcters, strings, etc. Common Lisp hs moved on from eing merely LISt Processor However,

More information