Location Steps and Paths

Size: px
Start display at page:

Download "Location Steps and Paths"

Transcription

1 Locatio Steps ad Paths 3 INTHIS CHAPTER Uderstadig Locatio Steps ad Paths How do locatio paths work? We took a look at locatio paths i the overview i Chapter 1, where we saw that locatio paths look much like directory paths For example, you might store sectio oe of chapter oe of part oe of a ovel i a directory with this path if you re usig Widows: Uderstadig Locatio Steps ad Paths 63 Usig the XPath Axes 76 Creatig Compoud Locatio Paths 92 I Brief 95 \ovel\part1\sectio1\chapter1 or this path if you re usig Uix: /ovel/part1/sectio1/chapter1 The idea behid XPath locatio paths is very much the same except that, as we ll see i this chapter ad the ext, the XPath sytax ca get much more complex ad detailed tha directory paths Like directory paths, you build locatio paths out of idividual steps, called locatio steps, separated by / or // You use these steps to specify the data you wat, just as you use successive directories i a file path to get to the locatio of a file For example, i the XPath locatio path /library/book/title[2]/text(), we begi with a /, which matches the root ode of the documet, followed by, i order: The locatio step library, which matches the child <library> elemet of the root ode The locatio step book, which matches the child <book> elemet of the <library> elemet

2 64 CHAPTER 3 Locatio Steps ad Paths The locatio step title[2], which matches the secod <title> elemet of the <book> elemet text(), which matches the text i the <title> elemet I fact, the XPath locatio path /library/book/title[2]/text() uses abbreviated XPath sytax, which we re goig to see i this chapter Here s the full versio of this XPath locatio path, where the child elemet ature of each successive locatio step is spelled out: /child::library/child::book/child::title[positio()=2]/child::text Okay ow let s get to the details The Parts of a Locatio Step Each locatio step is made up of a axis, a ode test, ad zero or more predicates, like this (where the * symbol meas zero or more of ): axis :: ode-test [predicate]* For example, i the locatio step child::ame[positio() = 2], child is the ame of the axis (which you follow with ::), ame is the ode test ad [positio() = 2] is the predicate I this case, the child axis selects child odes of the ode you start at, which is the cotext ode We re goig to take a look at axes, ode tests, ad predicates i detail i this chapter This locatio step ca also be abbreviated, usig the abbreviated sytax we ll see i this chapter, as ame[2] (this works because the child axis is the default axis, ad whe you use positio predicates like [positio() = 2], XPath lets you abbreviate them as simply [2]) Locatio paths ca be made up of oe or more locatio steps, such as child::ame[positio() = 2]/child::firstName, which selects all the <firstname> elemets that are childre of the secod <ame> child elemet of the cotext ode This locatio path ca also be abbreviated as ame[2]/firstname Whe you start the locatio path (ot a locatio step) with / or //, the locatio path is called a absolute locatio path because you re specifyig the path from the root ode of the XML documet (just as startig a file path with / i Uix starts the path from the root directory ad makes the path a absolute oe) Otherwise, the locatio path is relative, startig with the cotext ode For example, take a look at this ode tree agai: root elemet: <library>

3 65 Uderstadig Locatio Steps ad Paths elemet: <book> elemet: <title> elemet: <title> text: I Love XPath text: XPath is the BEST Begiig a locatio path with / (or //, as we ll see) makes that path start with the documet s root ode, makig this a absolute locatio path ad makig the root ode the cotext ode for the first locatio step i the path To move to the child <library> elemet, you add the locatio step library like this: /library (usig uabbreviated sytax, that would be /child::library) That makes the cotext ode for the ext locatio step the <library> elemet To move to the <book> elemet startig from the <library> cotext ode, you add book (or child::book) to the locatio path like this: /library/book ad so o, all the way dow to the text i the secod <title> elemet, which you reach with /library/book/title[2]/text() These are all absolute locatio paths, startig from the root ode O the other had, if you ve got a cotext ode already set some XPath software lets you specify cotext odes your locatio paths ca be relative For example, if you ve set the cotext ode to the <library> elemet, the relative locatio path book/title[2]/text() will locate the text i the secod <title> elemet i the documet Now it s time to get systematic about our study of locatio steps, which we re goig to do by takig a look at what kid of axes, ode tests, ad predicates XPath are available XPath Axes We re goig to take a look at all 13 XPath 10 axes i this chapter For example, i the locatio step child::plaet, which refers to all <plaet> elemets that are childre of the cotext ode, child is the axis (ad as you ow kow, you ca also abbreviate this locatio step as plaet, because child is the default axis) Here are all the XPath 10 axes: The acestor axis holds the acestors of the cotext ode; the acestors of the cotext ode are the paret of cotext ode ad the paret s paret ad so forth, back to ad icludig the root ode The acestor-or-self axis holds the cotext ode ad the acestors of the cotext ode The attribute axis holds the attributes of the cotext ode The child axis holds the childre of the cotext ode The descedat axis holds the descedats of the cotext ode A descedat is a child or a child of a child ad so o

4 66 CHAPTER 3 Locatio Steps ad Paths The descedat-or-self axis cotais the cotext ode ad the descedats of the cotext ode The followig axis holds all odes i the same documet as the cotext ode that come after the cotext ode The followig-siblig axis holds all the followig sibligs of the cotext ode A siblig is a ode o the same level as the cotext ode The amespace axis holds the amespace odes of the cotext ode The paret axis holds the paret of the cotext ode The precedig axis cotais all odes that come before the cotext ode The precedig-siblig axis cotais all the precedig sibligs of the cotext ode A siblig is a ode o the same level as the cotext ode The self axis cotais the cotext ode Each XPath locatio step must specify a axis (or use the default child axis), as i this locatio path we ve already see: /child::library/child::book/child::title[2]/child::text You ca also see the various XPath axes listed i Table 31, which lists the support for these axes by XML processors i Iteret Explorer The XML processor i Iteret Explorer is called MSXML; MSXML 20 was the versio i Iteret Explorer 50, early versios of Iteret Explorer 60 used MSXML3, ad the curret versio is MSXML4 If you re usig the NET platform, your versio of MSXML is MSXMLNET TABLE 31 The XPath Axes AXIS ABBREVIATION MSXML2 MSXML3 MSXML4 MSXMLNET acestor x x x acestor-or-self x x x x x x child (default) x x x x descedat // x x x x descedat-or-self x x x x followig x x x followig-siblig x x x amespace x x x paret x x x x precedig x x x precedig-siblig x x x self x x x x

5 67 Uderstadig Locatio Steps ad Paths XPath Node Tests Whe you use a axis i a locatio step, you re tellig XPath where to look ad idetifyig a set of odes A ode test tells XPath which of the odes i that set you re iterested i There are a umber of ways to create ode tests You ca use ames of odes as ode tests, or the wildcard * to select elemet or attribute odes (ote especially that * matches oly elemets ad attributes, ot just ay kid of ode) For example, the locatio step child::*/child::ame selects all <ame> elemets that are gradchildre of the cotext ode To match attributes, you d use the attribute axis like this: attribute::* Besides ode ames ad the wildcard character, you ca also use these ode tests i XPath 10: The * wildcard character matches ay elemet or attribute ame A ame matches a ode with that ame (for example, plaet will match a <plaet> elemet) The commet() ode test selects commet odes The ode() ode test selects ay type of ode The processig-istructio() ode test selects a processig istructio ode You ca specify the ame of the processig istructio to select i the paretheses The text() ode test selects a text ode You ca see the XPath 10 ode tests i Table 32, alog with the XML processor versio that supports them i the Iteret Explorer TABLE 32 The XPath Node Tests AXIS MSXML2 MSXML3 MSXML4 MSXMLNET * x x x x ame x x x x commet() x x x x ode() x x x x processig-istructio() x x x x text() x x x x The ode test lets you specify what odes you wat to work with i a XPath locatio step For example, take a look at our sample ode tree: root elemet: <library>

6 68 CHAPTER 3 Locatio Steps ad Paths elemet: <book> elemet: <title> elemet: <title> text: I Love XPath text: XPath is the BEST You ca start at the root ode with /, ad the use the child axis ad the ode test library to move to the <library> elemet givig you the locatio path /child::library You ca see this at work i the XPath Visualiser i Figure 31 FIGURE 31 Usig the XPath locatio step /child::library Ad you ca move to the <book> elemet uder the <library> elemet with aother locatio step ivolvig this child axis ad a ode test like this: /child:library/child:book You ca see what this looks like i the XPath Visualiser i Figure 32 FIGURE 32 Usig the XPath locatio step /child::library/child::book

7 69 Uderstadig Locatio Steps ad Paths The ext level dow i the ode tree holds two <title> elemets, however What if we oly wat to work with the secod oe? If we used the locatio path /child::library/child::book/child::title, we d match both <title> elemets, so we eed more tha a ode test here we eed to use a predicate XPath Predicates The ext part of a locatio step, which follows the ode text, is the predicate A locatio step does t eed a predicate, but if you use a predicate, you ca specify eve more about the ode or odes you wat to match You ofte use oe of the built-i XPath fuctios i predicates For example, take a look at the locatio step child::plaet[positio() = 2] I this case, the predicate, which is always eclosed betwee [ ad ], is positio() = 2 This meas that the value the built-i XPath fuctio positio() returs must idicate that this is the secod <plaet> child i order for the locatio step to match (this locatio step ca also be abbreviated as plaet[2]) I this way, this predicate arrows dow the search from the ode-set of all <plaet> childre of the cotext ode dow to the secod <plaet> child Now we re i a positio to select the secod <title> elemet i our XML documet that has this ode tree: root elemet: <library> elemet: <book> elemet: <title> elemet: <title> text: I Love XPath text: XPath is the BEST To move to the secod <title> elemet, we ca use the locatio path /child::library/child::book/child::title[2], as you see i the XPath Visualiser i Figure 33 (this locatio path ca also be abbreviated as /library/book/title[2]) As you ca see, expressios i predicates ca let you arrow dow the search from a whole ode-set to just the odes you re lookig for Here s aother ode-test example to select the <title> elemet that cotais the text I Love XPath, you ca use this XPath locatio path with the text() ode test: /child::library/child::book/child::title[text()= I Love XPath ], as you see i Figure 34

8 70 CHAPTER 3 Locatio Steps ad Paths FIGURE 33 Usig the locatio step /child::library/child::book/child::title[2] FIGURE 34 Selectig a <title> elemet Now we re able to costruct XPath locatio paths like /child::library/child::book/ child::title[2] usig axes, ode tests, ad predicates Each part of a locatio step, the axis, ode test, ad predicate, arrows dow the set of odes you re workig with You ca also build up XPath expressios much as you ca locatio paths For example, the text() ode test will retur the text i a ode, so if you wat to extract the text of the <title> elemet, you ca use the XPath expressio /child::library/child::book/child::title[2]/text(), which evaluates ot to a ode-set, but to a text strig, XPath is the BEST, as you ca see i Figure 35 You ca use multiple predicates i the same locatio step for example, say that we added a laguage attribute to each <plaet> elemet i our plaetary data XML documet, as you see i ch03_01xml (see Listig 31)

9 71 Uderstadig Locatio Steps ad Paths FIGURE 35 Usig /child::library/child::book/child::title[2]/text() LISTING 31 Addig a Laguage Attribute (ch03_01xml) <?xml versio= 10 ecodig= utf-8?> <plaets> <plaet laguage= Eglish > <ame>mercury</ame> <mass uits= (Earth = 1) >0553</mass> <day uits= days >5865</day> <radius uits= miles >1516</radius> <desity uits= (Earth = 1) >983</desity> <distace uits= millio miles >434</distace><!--At perihelio--> </plaet> <plaet laguage= Eglish > <ame>veus</ame> <mass uits= (Earth = 1) >815</mass> <day uits= days >11675</day> <radius uits= miles >3716</radius> <desity uits= (Earth = 1) >943</desity> <distace uits= millio miles >668</distace><!--At perihelio--> </plaet> <plaet laguage= Eglish > <ame>earth</ame> <mass uits= (Earth = 1) >1</mass> <day uits= days >1</day>

10 72 CHAPTER 3 Locatio Steps ad Paths LISTING 31 Cotiued <radius uits= miles >2107</radius> <desity uits= (Earth = 1) >1</desity> <distace uits= millio miles >1284</distace><!--At perihelio--> </plaet> </plaets> What if we wated to reach the secod <plaet> elemet that has a laguage attribute set to Eglish? We could do that with a locatio path like this: /plaets/plaet[attribute::laguage = Eglish ][positio() = 2], as you see i Figure 36 I this way, you ca hadle multiple coditios with multiple predicates FIGURE 36 Usig /plaets/plaet[attribute::laguage = Eglish ][positio() = 2] Some Examples of XPath Locatio Paths There s othig like seeig all this at work to uderstad what s goig o, so here are a umber of locatio path examples: child::plaet Returs the <plaet> elemet childre of the cotext ode child::* Returs all elemet childre (* oly matches elemets, or attributes if you use it with the attribute axis) of the cotext ode child::text() Returs all text ode childre of the cotext ode

11 73 Uderstadig Locatio Steps ad Paths child::ode() Returs all the childre of the cotext ode, o matter what their ode type is attribute::uits Returs the uits attribute of the cotext ode descedat::plaet Returs the <plaet> elemet descedats of the cotext ode acestor::plaet Returs all <plaet> acestors of the cotext ode acestor-or-self::plaet Returs the <plaet> acestors of the cotext ode If the cotext ode is a <plaet> as well, also returs the cotext ode descedat-or-self::plaet Returs the <plaet> elemet descedats of the cotext ode If the cotext ode is a <plaet> as well, also returs the cotext ode self::plaet Returs the cotext ode if it is a <plaet> elemet child::ame/descedat::plaet Returs the <plaet> elemet descedats of the child <ame> elemets of the cotext ode child::*/child::plaet Returs all <plaet> gradchildre of the cotext ode / Returs the root ode (that is, the paret of the documet elemet) /descedat::plaet Returs all the <plaet> elemets i the documet /descedat::plaet/child::ame Returs all the <ame> elemets that have a <plaet> paret child::plaet[positio() = 3] Returs the third <plaet> child of the cotext ode child::plaet[positio() = last()] Returs the last <plaet> child of the cotext ode /descedat::plaet[positio() = 3] Returs the third <plaet> elemet i the documet child::plaets/child::plaet[positio() = 4 ]/child::ame[positio() = 3] Returs the third <ame> elemet of the fourth <plaet> elemet of the <plaets> elemet child::plaet[positio() > 3] Returs last() locatio path> last()> all the <plaet> childre of the cotext ode after the first three precedig-siblig::ame[positio() = 2] Returs the secod previous <ame> siblig elemet of the cotext ode child::plaet[attribute::color = RED ] Returs all <plaet> childre of the cotext ode that have a color attribute with value of RED

12 74 CHAPTER 3 Locatio Steps ad Paths child::plaet[attribute::color = RED ][positio() = 3] Returs the third <plaet> child of the cotext ode that has a color attribute with value of RED child::plaet[positio() = 3][attribute::color= RED ] Returs the third <plaet> child of the cotext ode, oly if that child has a color attribute with value of RED child::plaet[child::ame] Returs the <plaet> childre of the cotext ode that have <ame> childre As you ca see, some of this sytax is pretty ivolved, ad a little legthy to type However, there is a abbreviated form of XPath sytax, ad we ll look at that ext Usig XPath Abbreviated Sytax There are a umber of abbreviatios you ca take advatage of i XPath sytax Here are the rules: self::ode() ca be abbreviated as paret::ode() ca be abbreviated as child::odeame ca be abbreviated as odeame attribute::odeame ca be abbreviated /descedat-or-self::ode()/ ca be abbreviated as // You ca also abbreviate predicate expressios like [positio() = 3] as [3] Usig the abbreviated sytax makes XPath expressios a lot easier to write For example, attribute::uits ca be abbreviated you ca refer to the cotext ode itself as simply, ad you ca refer to the curret ode ad ay descedats as // The // sytax i particular is useful ad importat Take a look at ch03_01xml, for example, the XML documet where we re storig plaetary data I that XML documet, we have three <plaet> elemets as childre of the mai <plaets> elemet: <plaets> <plaet laguage= Eglish > <ame>mercury</ame> <mass uits= (Earth = 1) >0553</mass> <day uits= days >5865</day>

13 75 Uderstadig Locatio Steps ad Paths <plaet laguage= Eglish > <ame>veus</ame> <mass uits= (Earth = 1) >815</mass> <day uits= days >11675</day> <plaet laguage= Eglish > <ame>earth</ame> <mass uits= (Earth = 1) >1</mass> <day uits= days >1</day> To select all three <plaet> elemets, you ca use the absolute XPath expressio /plaets/plaet, which starts at the XML documet s root ode, fids the <plaets> elemet, ad the matches the three <plaet> child elemets That s fie if you kow exactly where i the XML documet the elemets you wat are ad so ca specify a direct path to them But you ca also use //plaet to select all three <plaet> elemets, because //plaet will fid the <plaet> elemets by checkig the root ode ad all descedats for <plaet> elemets That s the power of // whe you wat to search for odes that may be aywhere i a documet, use // How about some examples of locatio paths usig abbreviated sytax? Here are a umber of examples: plaet Returs the <plaet> elemet childre of the cotext ode * Returs all elemet childre of the cotext ode text() Returs all text ode childre of the cotext Returs the uits attribute of the cotext Returs all the attributes of the cotext ode plaet[3] Returs the third <plaet> child of the cotext ode plaet[first()] Returs the first <plaet> child of the cotext ode */plaet Returs all <plaet> gradchildre of the cotext ode /plaets/plaet[3]/ame[2] Returs the secod <ame> elemet of the third <plaet> elemet of the <plaets> elemet

14 76 CHAPTER 3 Locatio Steps ad Paths //plaet Returs all the <plaet> descedats of the root ode plaets//plaet Returs the <plaet> elemet descedats of the <plaets> elemet childre of the cotext ode //plaet/ame Returs all the <ame> elemets that have a <plaet> paret Returs the cotext ode itself //plaet Returs the <plaet> elemet descedats of the cotext ode Returs the paret of the cotext ode /@uits Returs the uits attribute of the paret of the cotext ode plaet[ame] Returs the <plaet> childre of the cotext ode that have <ame> childre plaet[ame= Veus ] Returs the <plaet> childre of the cotext ode that have <ame> childre with text equal to Veus Usig the XPath Axes There are 13 axes to master, ad we ll take a look at them here, complete with examples To uderstad how somethig like XPath works, there s o better way tha seeig it at work as much as possible We ll take a look at various examples usig XPath Visualiser, ad we ll also take a look at some examples usig the XPath axes with XSLT You do t really have to uderstad the XSLT at this poit you ca just pick out the XPath expressio iside the example But XSLT is importat whe workig with XPath, as we re goig to see i Chapter 5, ad here it will help us out whe XPath Visualiser ca t (as with the amespace axis, which XPath Visualiser does t display visually) We re already familiar with the child ad attribute axes, so we wo t itroduce them here, but we will itroduce all the other axes ow, begiig with the acestor axis Usig the acestor Axis The acestor axis cotais all the acestors of the cotext ode, icludig its parets, gradparets, great-gradparets, ad so o This axis always cotais the root ode (uless the cotext ode is the root ode) Here s a example usig XPath Visualiser I this case, we ll use the locatio path //plaet/day to select the <day> elemets i our plaetary data example, ch03_01xml The we ll work backward with the acestor axis to fid the <plaet> acestor of each <day> elemet like this: //plaet/day/acestor::plaet You ca see the results i Figure 37 (ote that we re oly searchig for <plaet> acestors with this locatio path, so oly <plaet> acestors are selected)

15 77 Usig the XPath Axes FIGURE 37 Usig the acestor axis Here s a example doig the same thig usig XSLT As discussed i Chapter 1, i XSLT you create a template with a <xsl:template> elemet to match odes I this case, we wat to match <day> elemets: <xsl:template match= day > Now we ll use a <xsl:for-each> elemet to loop over all acestors of the <day> elemet, usig the XPath acestor axis: <xsl:template match= day > <xsl:for-each select= acestor::* > </xsl:for-each> To display the ame of the acestor elemet, we ca use the XSLT <xsl:value-of> elemet We ca extract the ame of the curret plaet with the XPath expressio /ame, where selects the cotext ode Here s what that looks like i XSLT: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 11 xmls:xsl= > <xsl:output method= xml />

16 78 CHAPTER 3 Locatio Steps ad Paths <xsl:template match= day > <xsl:for-each select= acestor::* > <xsl:value-of select= /ame /> </xsl:for-each> <xsl:template match= plaet > <xsl:apply-templates select= day /> </xsl:stylesheet> Ad here s the result whe you use this stylesheet o ch03_01xml as you ca see, we ve bee able to pick out the ames of the acestors of the <day> elemets i our documet: <?xml versio= 10 ecodig= utf-8?> Mercury Veus Earth Usig the acestor-or-self Axis The acestor-or-self axis cotais all the acestors of the cotext ode, ad the cotext ode itself That meas, amog other thigs, that this axis always cotais the root ode Here s a example usig XPath Visualiser I this case, we ll use this axis to select all acestors of <day> elemets, as well as the <day> elemet itself this way: /plaet/day/acestoror-self::* You ca see the results i Figure 38 FIGURE 38 Usig the acestor-or-self axis

17 79 Usig the XPath Axes Here s a example usig XSLT ad the acestor-or-self axis I this case, we re goig to add author attributes set to Thaddeus throughout our documet like this: <?xml versio= 10 ecodig= utf-8?> <?xml-stylesheet type= text/xml href= plaetsxsl?> <plaets author= Thaddeus > <plaet author= Thaddeus laguage= Eglish > <ame>mercury</ame> <mass uits= (Earth = 1) >0553</mass> <day author= Thaddeus uits= days >5865</day> <radius uits= miles >1516</radius> <desity uits= (Earth = 1) >983</desity> <distace uits= millio miles >434</distace><!--At perihelio--> </plaet> <plaet author= Thaddeus laguage= Eglish > <ame>veus</ame> <mass uits= (Earth = 1) >815</mass> <day uits= days >11675</day> <radius uits= miles >3716</radius> <desity uits= (Earth = 1) >943</desity> <distace uits= millio miles >668</distace><!--At perihelio--> </plaet> <plaet laguage= Eglish > <ame>earth</ame> <mass uits= (Earth = 1) >1</mass> <day uits= days >1</day> <radius uits= miles >2107</radius> <desity uits= (Earth = 1) >1</desity> <distace uits= millio miles >1284</distace><!--At perihelio--> </plaet> </plaets> Now say that you wat to list by ame all acestors of <day> elemets that have a author attribute as well as the curret <day> elemet if it has a author attribute To do that, you ca use the XPath locatio path acestor-or-self::*[@author], which matches all odes ad acestors that have a author attribute Here s what it looks like i XSLT: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 11 xmls:xsl= > <xsl:output method= xml />

18 80 CHAPTER 3 Locatio Steps ad Paths <xsl:template match= day > <xsl:for-each select= acestor-or-self::*[@author] > <xsl:value-of select= local-ame() /> <xsl:text> </xsl:text> </xsl:for-each> <xsl:template match= plaet > <xsl:apply-templates select= day /> </xsl:stylesheet> Here s the result, showig the matchig acestors of all three <day> elemets that have author attributes, icludig the <day> elemet itself, which has a author attribute: <?xml versio= 10 ecodig= UTF-8?> plaets plaet day plaets plaet plaets Usig the descedat Axis The descedat axis cotais all the descedats of the cotext ode Note that this does ot iclude ay attributes or amespace odes Here s a example usig XPath Visualiser I this case, we ll select all descedats of <plaet> elemets with the locatio path //plaet/descedat::*, as you see i Figure 39 FIGURE 39 Usig the descedat axis

19 81 Usig the XPath Axes Here s a example usig XSLT I this case, we ll check a documet to see if it icludes a <plaet> elemet for Mercury, ad if so, we ll iclude this elemet i the result: <ifo>sorry, Mercury caot be foud at this time</ifo> To match Mercury s <plaet> elemet, all you have to do is to check whether ay text ode descedat of a <plaet> elemet holds the strig Mercury this way: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 10 xmls:xsl= > <xsl:output method= xml /> <xsl:template match= plaet[descedat::text()= Mercury ] > <ifo>sorry, Mercury caot be foud at this time</ifo> <xsl:template match= * > <xsl:apply-templates select= * /> </xsl:stylesheet> That s all it takes Here s the result, showig the <ifo> elemet: <?xml versio= 10 ecodig= utf-8?> <ifo>sorry, Mercury caot be foud</ifo> Usig the descedat-or-self Axis The descedat-or-self axis cotais all the descedats of the cotext ode, ad the cotext ode itself Note, however, that it does ot cotai ay attributes or amespace odes You ca see a example i Figure 310, where we re selectig all <plaet> elemets ad their descedats with the XPath locatio path //plaet/descedat-or-self::* Here s a example doig the same thig usig XSLT I this case, we ll use a XSLT template to match all <plaet> elemets ad the loop over all odes i the ode-set retured by usig the descedat-or-self axis, displayig each ode s ame: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 10 xmls:xsl= > <xsl:output method= xml />

20 82 CHAPTER 3 Locatio Steps ad Paths <xsl:template match= plaet > <xsl:for-each select= descedat-or-self::* > <xsl:value-of select= local-ame() /> <xsl:text> </xsl:text> </xsl:for-each> </xsl:stylesheet> FIGURE 310 Usig the descedat-or-self axis That s all it takes Here s the result, where we ve bee able to list the ame of all the descedats of <plaet> elemets, as well as the <plaet> elemets themselves, usig the descedat-or-self axis: <?xml versio= 10 ecodig= UTF-8?> plaet ame mass day radius desity distace plaet ame mass day radius desity distace plaet ame mass day radius desity distace Usig the followig Axis The followig axis cotais all odes that come after the cotext ode i documet order, excludig ay of the cotext ode s descedats ad also excludig attribute odes ad amespace odes You ca see a example i the XPath Visualiser i Figure 311, where we re usig this axis to select the followig elemets after the <mass> elemet i the first <plaet> elemet, usig the XPath locatio path /plaets/plaet[1]/mass/followig::*

21 83 Usig the XPath Axes FIGURE 311 Usig the followig axis to extract data Here s a example usig XSLT to do the same thig I this case, we re matchig the first <plaet> elemet i a XSLT template ad displayig the ames of the followig elemets: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 11 xmls:xsl= > <xsl:output method= xml /> <xsl:template match= plaet[1] > <xsl:for-each select= mass/followig::* > <xsl:value-of select= local-ame() /> <xsl:text> </xsl:text> </xsl:for-each> <xsl:template match= * > <xsl:apply-templates select= * /> </xsl:stylesheet> Here s what the result looks like Note that we ve bee able to get all the elemets followig the <mass> elemet i the first <plaet> elemet, ad the all the followig elemets i the rest of the documet:

22 84 CHAPTER 3 Locatio Steps ad Paths <?xml versio= 10 ecodig= UTF-8?> day radius desity distace plaet ame mass day radius desity distace plaet ame mass day radius desity distace Usig the followig-siblig Axis The followig-siblig axis cotais all the followig sibligs of the cotext ode You ca see a example i the XPath Visualiser i Figure 312, where we re usig the XPath locatio path /plaets/plaet[1]/mass/followig-siblig::* to select all followig siblig odes of the <mass> elemet i the first <plaet> elemet FIGURE 312 Usig the followig-siblig axis Here s how this example works i XSLT; i this case, we re also matchig the first <plaet> elemet s <mass> elemet ad the gettig its followig siblig elemets: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 11 xmls:xsl= > <xsl:output method= xml /> <xsl:template match= plaet[1] > <xsl:for-each select= mass/followig-siblig::* > <xsl:value-of select= local-ame() /> <xsl:text> </xsl:text> </xsl:for-each>

23 85 Usig the XPath Axes <xsl:template match= * > <xsl:apply-templates select= * /> </xsl:stylesheet> Here s the result as you ca see, we ve caught all the sibligs followig the <mass> elemet i the first <plaet> elemet: <?xml versio= 10 ecodig= UTF-8?> day radius desity distace Usig the amespace Axis The amespace axis cotais the amespace odes of the cotext ode ote that the axis will be empty uless the cotext ode is a elemet A elemet will have a amespace ode for Every attribute of the elemet whose ame starts with xmls: Every attribute of a acestor elemet whose ame starts xmls: (uless, of course, the elemet itself or a earer acestor redeclares the amespace) A xmls attribute, if the elemet, or some acestor, has a xmls attribute XPath Visualiser does t hadle this axis visually, so we ll rely o XSLT here Here, we ll add a XML amespace declaratio to the <plaets> elemet, usig the amespace like this: <?xml versio= 10 ecodig= utf-8?> <?xml-stylesheet type= text/xml href= plaetsxsl?> <plaets xmls= > <plaet> <ame>mercury</ame> <mass uits= (Earth = 1) >0553</mass> <day uits= days >5865</day> <radius uits= miles >1516</radius> <desity uits= (Earth = 1) >983</desity> <distace uits= millio miles >434</distace><!--At perihelio--> </plaet>

24 86 CHAPTER 3 Locatio Steps ad Paths I XSLT, we ca check the amespaces used i the <plaets> elemet like this: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 11 xmls:xsl= > <xsl:output method= xml /> <xsl:template match= plaets > <xsl:value-of select= amespace::* /> </xsl:stylesheet> Ad here s the result, showig that we ca ideed pick out the amespace: <?xml versio= 10 ecodig= UTF-8?> Usig the paret Axis The paret axis cotais the paret (ad oly the paret) of the cotext ode, if there is oe You ca see a example i XPath Visualiser i Figure 313 Here, we re pickig out the paret elemets of all <day> elemets with the XPath locatio path //day/paret::* FIGURE 313 Usig the paret axis to extract data

25 87 Usig the XPath Axes Ad here s the same example i XPath I this case, we ll match all <day> elemets ad get the ames of their paret elemets Here s what it looks like: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 11 xmls:xsl= > <xsl:output method= xml /> <xsl:template match= //day > <xsl:for-each select= paret::* > <xsl:value-of select= local-ame() /> <xsl:text> </xsl:text> </xsl:for-each> <xsl:template match= * > <xsl:apply-templates select= * /> </xsl:stylesheet> Ad here s the result: <?xml versio= 10 ecodig= UTF-8?> plaet plaet plaet USING THE ABBREVIATION Remember that you ca also use the abbreviatio to stad for the paret of the cotext ode Usig the precedig Axis The precedig axis cotais all odes that are before the cotext ode i documet order, excludig ay acestors of the cotext ode, ad also excludig attribute odes ad amespace odes Here s a example usig XPath Visualiser I this case, we ll select all elemets precedig the <desity> elemet i the first plaet elemet with the XPath locatio path //plaet[1]/desity/precedig::*, as you ca see i Figure 314 Let s give this axis a try i XSLT I this case, say that we wat to set the cotet of the <distace> elemet to the text This plaet is farther tha Mercury from the su if the curret plaet is ideed farther from the su tha Mercury Oe way to do that is to see if Mercury comes before the curret plaet i documet order, usig the precedig axis: <?xml versio= 10 ecodig= utf-8?> <xsl:stylesheet versio= 11 xmls:xsl= > <xsl:output method= xml />

26 88 CHAPTER 3 Locatio Steps ad Paths <xsl:template match= distace[precedig::*/ame= Mercury ] > <distace>this plaet is farther tha Mercury from the su</distace> <xsl:template ode() > <xsl:copy> <xsl:apply-templates ode() /> </xsl:copy> </xsl:stylesheet> FIGURE 314 Usig the precedig axis to select elemets If the curret plaet does come after Mercury, this example iserts the message i its <distace> elemet, as you see i this result: <?xml versio= 10 ecodig= utf-8?> <?xml-stylesheet type= text/xml href= plaetsxsl?> <plaets> <plaet> <ame>mercury</ame> <mass uits= (Earth = 1) >0553</mass> <day uits= days >5865</day> <radius uits= miles >1516</radius> <desity uits= (Earth = 1) >983</desity> <distace uits= millio miles >434</distace> <!--At perihelio--> </plaet>

27 89 Usig the XPath Axes <plaet> <ame>veus</ame> <mass uits= (Earth = 1) >815</mass> <day uits= days >11675</day> <radius uits= miles >3716</radius> <desity uits= (Earth = 1) >943</desity> <distace>this plaet is farther tha Mercury from the su</distace> <!--At perihelio--> </plaet> <plaet> <ame>earth</ame> <mass uits= (Earth = 1) >1</mass> <day uits= days >1</day> <radius uits= miles >2107</radius> <desity uits= (Earth = 1) >1</desity> <distace>this plaet is farther tha Mercury from the su</distace> <!--At perihelio--> </plaet> </plaets> Usig the precedig-siblig Axis The precedig-siblig axis cotais all the precedig sibligs of the cotext ode Note that if the cotext ode is a attribute ode or amespace ode, the precedig-siblig axis wo t hold aythig You ca see a example i the XPath Visualiser i Figure 315, where we re usig the XPath locatio path //plaet[2]/precedig-siblig::* to select all precedig sibligs of the secod <plaet> elemet Note that just the first <plaet> elemet is selected O the other had, if we had used //plaet[2]/precedig::*, ot oly would the first <plaet> elemet be selected, but all that elemet s child elemets would be selected as well Here s a more advaced example usig XSLT I this case, we ll replace the <distace> elemet i Mercury s <plaet> elemet with <distace>this plaet is the closest to the su</distace> If we re matchig <distace> elemets, how ca we make sure that we ve got Mercury s <distace> elemet? We ca check the curret <distace> elemet s precedig sibligs ad look for the text Mercury Here s what it looks like i XSLT: <?xml versio= 10?> <xsl:stylesheet versio= 10 xmls:xsl= > <xsl:output method= xml />

28 90 CHAPTER 3 Locatio Steps ad Paths <xsl:template match= distace[precedig-siblig::*= Mercury ] > <distace>this plaet is the closest to the su</distace> <xsl:template ode() > <xsl:copy> <xsl:apply-templates ode() /> </xsl:copy> </xsl:stylesheet> FIGURE 315 Usig the precedig-siblig axis to extract data Ad here s the result: <?xml versio= 10 ecodig= utf-8?> <?xml-stylesheet type= text/xml href= plaetsxsl?> <plaets> <plaet laguage= Eglish > <ame>mercury</ame> <mass uits= (Earth = 1) >0553</mass> <day uits= days >5865</day> <radius uits= miles >1516</radius> <desity uits= (Earth = 1) >983</desity> <distace>this plaet is the closest to the su</distace> <!--At perihelio--> </plaet>

29 91 Usig the XPath Axes <plaet laguage= Eglish > <ame>veus</ame> <mass uits= (Earth = 1) >815</mass> <day uits= days >11675</day> <radius uits= miles >3716</radius> <desity uits= (Earth = 1) >943</desity> <distace uits= millio miles >668</distace><!--At perihelio--> </plaet> <plaet laguage= Eglish > <ame>earth</ame> <mass uits= (Earth = 1) >1</mass> <day uits= days >1</day> <radius uits= miles >2107</radius> <desity uits= (Earth = 1) >1</desity> <distace uits= millio miles >1284</distace><!--At perihelio--> </plaet> </plaets> Usig the self Axis The self axis cotais just the cotext ode, ad you ca abbreviate self::ode() as This is a useful axis to kow about, because as you kow, if you omit the axis, the default is child::, but sometimes you wat to refer to the curret ode istead For example, [self::plaet] is true oly if the cotext ode is a <plaet> elemet You ca see a example usig this axis i XPath Visualiser i Figure 316, where we re usig the XPath locatio path //*[self::radius] to select <radius> elemets i ch03_01xml (this locatio path is equivalet to //radius) Here s a example usig XSLT I this case, we ll use oe template to match both <ame> ad <day> elemets i the same template We ca do that by matchig ame day i a template like this (more o how this works i the ext sectio): <xsl:template match= ame day > At this poit, we ve matched both <ame> ad <day> elemets but suppose that i the body of the template we actually wat to treat these elemets differetly To do that, we have to check if we re dealig with a <ame> elemet or a <day> elemet, which we ca do with the

30 92 CHAPTER 3 Locatio Steps ad Paths XSLT elemet <xsl:if>, where you assig the coditio to test to this elemet s test attribute Here s what it looks like i XSLT: <xsl:template match= ame day > <xsl:if test= self::ame > <xsl:value-of select= /> </xsl:if> <xsl:if test= self::day > <xsl:value-of select= /> <xsl:text> </xsl:text> <xsl:value-of /> </xsl:if> FIGURE 316 Usig the self axis to select <radius> elemets So ow we ve take a look at all 13 axes, from the acestor axis to the self axis Note that you ca combie locatio paths with the operator we ll take a closer look at that ow Creatig Compoud Locatio Paths I XPath, you ca combie locatio paths with the, or pipe character We ve already see that at work like this:

31 93 Creatig Compoud Locatio Paths <xsl:template match= ame day > You ca use ay kid of locatio paths with the pipe character, like this: <xsl:template match= ame/firstname day/author/lastname > Whe you use a compoud locatio path, each path is evaluated separately that is, the cotext ode for the first path does t affect the cotext ode for the other path Ad you re ot restricted to two paths; you ca coect as may as you like with pipes: <xsl:template match= ame/firstname day/author/lastname distace mass/kilograms > Whe it comes to predicates, however, the situatio is differet I XPath, you combie coditios i a predicate with the ad ad or operators For example, if you wated to match all <distace> elemets that have uits attributes set to millio miles ad laguage attributes set to Eglish, you could use the ad operator like this: <xsl:template match= distace[@uits= millio miles Eglish ] > <distace>this is the plaet Mercury, closest to the Su</distace> USING QUOTATION MARKS Notice the quotatio marks here to avoid cofusig the XSLT processor, we re usig sigle quotes to surroud the attribute values here, because the whole XPath expressio is surrouded i double quotes You could also use the or operator if you wated to match <distace> elemets that have uits attributes set to millio miles or laguage attributes set to Eglish, like this: <xsl:template match= distace[@uits= mil lio miles Eglish ] > <distace>this is the plaet Mercury, closest to the Su</distace>

32 94 CHAPTER 3 Locatio Steps ad Paths Here s aother example: child::*[self::ame or self::mass], which returs both the <ame> ad <mass> childre of the cotext ode You ca coect as may coditios i a predicate as you wat usig ad ad or Ad if it gets cofusig, you ca use paretheses like this: <xsl:template match= author[(@firstname= Cary ) ad (@lastname= Grat)] > <distace>this is the plaet Mercury, closest to the Su</distace> Note also that compoud locatio paths ca also have predicates, of course, icludig compoud predicates Nestig Predicates It s also legal to est predicates Here s how you might select all <project> elemets that have <ame> descedats that i tur have a precedig siblig <active> elemet: //project[descedat::ame[precedig-siblig::active]] You ca also est predicates whe usig compoud locatio paths ad eve compoud predicates Usig Predicates Without Operators The predicates we ve used so far usually use operators, as i the locatio step author[positio()=4], where we re usig the = operator (we ll see all the available operators i the ext chapter) However, you do t eed to use operators at all i predicates if you just wat to test for the existece of a ode For example, if you wat to fid all <otatio> elemets that cotai at least oe <author> elemet, you ca use this locatio path: //otatio[descedat::author] That s it for this chapter o locatio steps ad locatio paths We saw how XPath works with the data model itroduced i Chapter 2 by usig locatio paths, which are made up of locatio steps Each locatio step, i tur, is made up of a axis, a ode test, ad a predicate I Chapter 4, we re goig to get more details o creatig locatio paths as we see the operators ad fuctios you ca use i XPath predicates

33 95 I Brief I Brief Each locatio step is made up of a axis, a ode test, ad zero or more predicates A axis idicates how to search for odes Here are the XPath 10 axes: The child axis The attribute axis The acestor axis The acestor-or-self axis The descedat axis The descedat-or-self axis The followig axis The followig-siblig axis The amespace axis The paret axis The precedig axis The precedig-siblig axis The self axis You ca use these ode tests i XPath 10: The * wildcard character matches ay elemet or attribute ame A ame matches a ode with that ame (for example, plaet will match a <plaet> elemet) The commet() ode test selects commet odes The ode() ode test selects ay type of ode The processig-istructio() ode test selects a processig istructio ode The text() ode test selects a text ode Predicates are eclosed i [ ad ] ad may cotai ay valid XPath 10 expressio

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis Overview Chapter 6 Writig a Program Bjare Stroustrup Some thoughts o software developmet The idea of a calculator Usig a grammar Expressio evaluatio Program orgaizatio www.stroustrup.com/programmig 3 Buildig

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming Lecture Notes 6 Itroductio to algorithm aalysis CSS 501 Data Structures ad Object-Orieted Programmig Readig for this lecture: Carrao, Chapter 10 To be covered i this lecture: Itroductio to algorithm aalysis

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

CS 111: Program Design I Lecture 20: Web crawling, HTML, Copyright

CS 111: Program Design I Lecture 20: Web crawling, HTML, Copyright CS 111: Program Desig I Lecture 20: Web crawlig, HTML, Copyright Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago November 8, 2016 WEB CRAWLER AGAIN Two bits of useful Pytho sytax Do't eed

More information

1.2 Binomial Coefficients and Subsets

1.2 Binomial Coefficients and Subsets 1.2. BINOMIAL COEFFICIENTS AND SUBSETS 13 1.2 Biomial Coefficiets ad Subsets 1.2-1 The loop below is part of a program to determie the umber of triagles formed by poits i the plae. for i =1 to for j =

More information

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:

More information

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence _9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to

More information

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions:

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions: CS 604 Data Structures Midterm Sprig, 00 VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Istructios: Prit your ame i the space provided below. This examiatio is closed book ad closed

More information

CS 111: Program Design I Lecture 19: Networks, the Web, and getting text from the Web in Python

CS 111: Program Design I Lecture 19: Networks, the Web, and getting text from the Web in Python CS 111: Program Desig I Lecture 19: Networks, the Web, ad gettig text from the Web i Pytho Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago April 3, 2018 Goals Lear about Iteret Lear about

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists

More information

Computers and Scientific Thinking

Computers and Scientific Thinking Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput

More information

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 10 Defiig Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio,

More information

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 4 Procedural Abstractio ad Fuctios That Retur a Value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 4.1 Top-Dow Desig 4.2 Predefied Fuctios 4.3 Programmer-Defied Fuctios 4.4

More information

15-859E: Advanced Algorithms CMU, Spring 2015 Lecture #2: Randomized MST and MST Verification January 14, 2015

15-859E: Advanced Algorithms CMU, Spring 2015 Lecture #2: Randomized MST and MST Verification January 14, 2015 15-859E: Advaced Algorithms CMU, Sprig 2015 Lecture #2: Radomized MST ad MST Verificatio Jauary 14, 2015 Lecturer: Aupam Gupta Scribe: Yu Zhao 1 Prelimiaries I this lecture we are talkig about two cotets:

More information

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS)

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS) CSC165H1, Witer 018 Learig Objectives By the ed of this worksheet, you will: Aalyse the ruig time of fuctios cotaiig ested loops. 1. Nested loop variatios. Each of the followig fuctios takes as iput a

More information

Recursive Procedures. How can you model the relationship between consecutive terms of a sequence?

Recursive Procedures. How can you model the relationship between consecutive terms of a sequence? 6. Recursive Procedures I Sectio 6.1, you used fuctio otatio to write a explicit formula to determie the value of ay term i a Sometimes it is easier to calculate oe term i a sequece usig the previous terms.

More information

Module 8-7: Pascal s Triangle and the Binomial Theorem

Module 8-7: Pascal s Triangle and the Binomial Theorem Module 8-7: Pascal s Triagle ad the Biomial Theorem Gregory V. Bard April 5, 017 A Note about Notatio Just to recall, all of the followig mea the same thig: ( 7 7C 4 C4 7 7C4 5 4 ad they are (all proouced

More information

The number n of subintervals times the length h of subintervals gives length of interval (b-a).

The number n of subintervals times the length h of subintervals gives length of interval (b-a). Simulator with MadMath Kit: Riema Sums (Teacher s pages) I your kit: 1. GeoGebra file: Ready-to-use projector sized simulator: RiemaSumMM.ggb 2. RiemaSumMM.pdf (this file) ad RiemaSumMMEd.pdf (educator's

More information

3.1 Overview of MySQL Programs. These programs are discussed further in Chapter 4, Database Administration. Client programs that access the server:

3.1 Overview of MySQL Programs. These programs are discussed further in Chapter 4, Database Administration. Client programs that access the server: 3 Usig MySQL Programs This chapter provides a brief overview of the programs provided by MySQL AB ad discusses how to specify optios whe you ru these programs. Most programs have optios that are specific

More information

The Open University, Walton Hall, Milton Keynes, MK7 6AA First published 2004

The Open University, Walton Hall, Milton Keynes, MK7 6AA First published 2004 8 Programs ad data This publicatio forms part of a Ope Uiversity course M150 Data, Computig ad Iformatio. Details of this ad other Ope Uiversity courses ca be obtaied from the Course Iformatio ad Advice

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to

More information

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June CS 1313 010: Programmig for No-Majors, Summer 2007 Programmig Project #3: Two Little Calculatios Due by 12:00pm (oo) Wedesday Jue 27 2007 This third assigmet will give you experiece writig programs that

More information

Chapter 2. C++ Basics. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 2. C++ Basics. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 2 C++ Basics Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 2.1 Variables ad Assigmets 2.2 Iput ad Output 2.3 Data Types ad Expressios 2.4 Simple Flow of Cotrol 2.5 Program

More information

One advantage that SONAR has over any other music-sequencing product I ve worked

One advantage that SONAR has over any other music-sequencing product I ve worked *gajedra* D:/Thomso_Learig_Projects/Garrigus_163132/z_productio/z_3B2_3D_files/Garrigus_163132_ch17.3d, 14/11/08/16:26:39, 16:26, page: 647 17 CAL 101 Oe advatage that SONAR has over ay other music-sequecig

More information

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions Your computer takes exceptio s s are errors i the logic of a program (ru-time errors). Examples: i thread mai java.io.filenotfoud: studet.txt (The system caot fid the file specified.) i thread mai java.lag.nullpoiter:

More information

Weston Anniversary Fund

Weston Anniversary Fund Westo Olie Applicatio Guide 2018 1 This guide is desiged to help charities applyig to the Westo to use our olie applicatio form. The Westo is ope to applicatios from 5th Jauary 2018 ad closes o 30th Jue

More information

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems

More information

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig

More information

Ones Assignment Method for Solving Traveling Salesman Problem

Ones Assignment Method for Solving Traveling Salesman Problem Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:

More information

CSI 3140 WWW Structures, Techniques and Standards. Cascading Style Sheets (CSS)

CSI 3140 WWW Structures, Techniques and Standards. Cascading Style Sheets (CSS) CSI 3140 WWW Structures, Techiques ad Stadards Cascadig Style Sheets (CSS) Motivatio whtml markup ca be used to represet Sematics: h1 meas that a elemet is a top-level headig Presetatio: h1 elemets look

More information

From last week. Lecture 5. Outline. Principles of programming languages

From last week. Lecture 5. Outline. Principles of programming languages Priciples of programmig laguages From last week Lecture 5 http://few.vu.l/~silvis/ppl/2007 Natalia Silvis-Cividjia e-mail: silvis@few.vu.l ML has o assigmet. Explai how to access a old bidig? Is & for

More information

fgrep - Linux Command

fgrep - Linux Command f - CetOS 5.2 - Liux Users Guide f f - Liux Commad SYNOPSIS [optios] PATTE RN [FI LE...] [ optios ] [ -e -f FILE ] [ FILE...] DESCRIPTION Grep searches the amed iput FILE s (or stadard iput if o files

More information

CS 11 C track: lecture 1

CS 11 C track: lecture 1 CS 11 C track: lecture 1 Prelimiaries Need a CMS cluster accout http://acctreq.cms.caltech.edu/cgi-bi/request.cgi Need to kow UNIX IMSS tutorial liked from track home page Track home page: http://courses.cms.caltech.edu/courses/cs11/material

More information

IMP: Superposer Integrated Morphometrics Package Superposition Tool

IMP: Superposer Integrated Morphometrics Package Superposition Tool IMP: Superposer Itegrated Morphometrics Package Superpositio Tool Programmig by: David Lieber ( 03) Caisius College 200 Mai St. Buffalo, NY 4208 Cocept by: H. David Sheets, Dept. of Physics, Caisius College

More information

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0 Polyomial Fuctios ad Models 1 Learig Objectives 1. Idetify polyomial fuctios ad their degree 2. Graph polyomial fuctios usig trasformatios 3. Idetify the real zeros of a polyomial fuctio ad their multiplicity

More information

Guide to Applying Online

Guide to Applying Online Guide to Applyig Olie Itroductio Respodig to requests for additioal iformatio Reportig: submittig your moitorig or ed of grat Pledges: submittig your Itroductio This guide is to help charities submit their

More information

MOTIF XF Extension Owner s Manual

MOTIF XF Extension Owner s Manual MOTIF XF Extesio Ower s Maual Table of Cotets About MOTIF XF Extesio...2 What Extesio ca do...2 Auto settig of Audio Driver... 2 Auto settigs of Remote Device... 2 Project templates with Iput/ Output Bus

More information

CS 111: Program Design I Lecture 21: Network Analysis. Robert H. Sloan & Richard Warner University of Illinois at Chicago April 10, 2018

CS 111: Program Design I Lecture 21: Network Analysis. Robert H. Sloan & Richard Warner University of Illinois at Chicago April 10, 2018 CS 111: Program Desig I Lecture 21: Network Aalysis Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago April 10, 2018 NETWORK ANALYSIS Which displays a graph i the sese of graph/etwork aalysis?

More information

The isoperimetric problem on the hypercube

The isoperimetric problem on the hypercube The isoperimetric problem o the hypercube Prepared by: Steve Butler November 2, 2005 1 The isoperimetric problem We will cosider the -dimesioal hypercube Q Recall that the hypercube Q is a graph whose

More information

CS 111: Program Design I Lecture 15: Objects, Pandas, Modules. Robert H. Sloan & Richard Warner University of Illinois at Chicago October 13, 2016

CS 111: Program Design I Lecture 15: Objects, Pandas, Modules. Robert H. Sloan & Richard Warner University of Illinois at Chicago October 13, 2016 CS 111: Program Desig I Lecture 15: Objects, Padas, Modules Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago October 13, 2016 OBJECTS AND DOT NOTATION Objects (Implicit i Chapter 2, Variables,

More information

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 5 Fuctios for All Subtasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 5.1 void Fuctios 5.2 Call-By-Referece Parameters 5.3 Usig Procedural Abstractio 5.4 Testig ad Debuggig

More information

The VSS CCD photometry spreadsheet

The VSS CCD photometry spreadsheet The VSS CCD photometry spreadsheet Itroductio This Excel spreadsheet has bee developed ad tested by the BAA VSS for aalysig results files produced by the multi-image CCD photometry procedure i AIP4Wi v2.

More information

Alpha Individual Solutions MAΘ National Convention 2013

Alpha Individual Solutions MAΘ National Convention 2013 Alpha Idividual Solutios MAΘ Natioal Covetio 0 Aswers:. D. A. C 4. D 5. C 6. B 7. A 8. C 9. D 0. B. B. A. D 4. C 5. A 6. C 7. B 8. A 9. A 0. C. E. B. D 4. C 5. A 6. D 7. B 8. C 9. D 0. B TB. 570 TB. 5

More information

Introduction to Sigma Notation

Introduction to Sigma Notation Itroductio to Siga Notatio Steph de Silva //207 What is siga otatio? is the capital Greek letter for the soud s I this case, it s just shorthad for su Siga otatio is what we use whe we have a series of

More information

CS 111: Program Design I Lecture 20: Web crawling, HTML, Copyright

CS 111: Program Design I Lecture 20: Web crawling, HTML, Copyright CS 111: Program Desig I Lecture 20: Web crawlig, HTML, Copyright Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago November 8, 2016 Most importat thig If you have ot yet voted (ad are a US

More information

CIS 121. Introduction to Trees

CIS 121. Introduction to Trees CIS 121 Itroductio to Trees 1 Tree ADT Tree defiitio q A tree is a set of odes which may be empty q If ot empty, the there is a distiguished ode r, called root ad zero or more o-empty subtrees T 1, T 2,

More information

ECE4050 Data Structures and Algorithms. Lecture 6: Searching

ECE4050 Data Structures and Algorithms. Lecture 6: Searching ECE4050 Data Structures ad Algorithms Lecture 6: Searchig 1 Search Give: Distict keys k 1, k 2,, k ad collectio L of records of the form (k 1, I 1 ), (k 2, I 2 ),, (k, I ) where I j is the iformatio associated

More information

! Given the following Structure: ! We can define a pointer to a structure. ! Now studentptr points to the s1 structure.

! Given the following Structure: ! We can define a pointer to a structure. ! Now studentptr points to the s1 structure. Liked Lists Uit 5 Sectios 11.9 & 18.1-2 CS 2308 Fall 2018 Jill Seama 11.9: Poiters to Structures! Give the followig Structure: struct Studet { strig ame; // Studet s ame it idnum; // Studet ID umber it

More information

CS 111 Green: Program Design I Lecture 27: Speed (cont.); parting thoughts

CS 111 Green: Program Design I Lecture 27: Speed (cont.); parting thoughts CS 111 Gree: Program Desig I Lecture 27: Speed (cot.); partig thoughts By Nascarkig - Ow work, CC BY-SA 4.0, https://commos.wikimedia.org/w/idex.php?curid=38671041 Robert H. Sloa (CS) & Rachel Poretsky

More information

Getting Started. Getting Started - 1

Getting Started. Getting Started - 1 Gettig Started Gettig Started - 1 Issue 1 Overview of Gettig Started Overview of Gettig Started This sectio explais the basic operatios of the AUDIX system. It describes how to: Log i ad log out of the

More information

Floristic Quality Assessment (FQA) Calculator for Colorado User s Guide

Floristic Quality Assessment (FQA) Calculator for Colorado User s Guide Floristic Quality Assessmet (FQA) Calculator for Colorado User s Guide Created by the Colorado atural Heritage Program Last Updated April 2012 The FQA Calculator was created by Michelle Fik ad Joaa Lemly

More information

6.851: Advanced Data Structures Spring Lecture 17 April 24

6.851: Advanced Data Structures Spring Lecture 17 April 24 6.851: Advaced Data Structures Sprig 2012 Prof. Erik Demaie Lecture 17 April 24 Scribes: David Bejami(2012), Li Fei(2012), Yuzhi Zheg(2012),Morteza Zadimoghaddam(2010), Aaro Berstei(2007) 1 Overview Up

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

CS 111: Program Design I Lecture 14: Encodings & Files concluded; Pandas, Modules, legal data analytics

CS 111: Program Design I Lecture 14: Encodings & Files concluded; Pandas, Modules, legal data analytics CS 111: Program Desig I Lecture 14: Ecodigs & Files cocluded; Padas, Modules, legal data aalytics Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago October 16, 2018 Recall: ASCII Ecodig characters

More information

Thompson s Group F (p + 1) is not Minimally Almost Convex

Thompson s Group F (p + 1) is not Minimally Almost Convex Thompso s Group F (p + ) is ot Miimally Almost Covex Claire Wladis Thompso s Group F (p + ). A Descriptio of F (p + ) Thompso s group F (p + ) ca be defied as the group of piecewiseliear orietatio-preservig

More information

Lecture 7 7 Refraction and Snell s Law Reading Assignment: Read Kipnis Chapter 4 Refraction of Light, Section III, IV

Lecture 7 7 Refraction and Snell s Law Reading Assignment: Read Kipnis Chapter 4 Refraction of Light, Section III, IV Lecture 7 7 Refractio ad Sell s Law Readig Assigmet: Read Kipis Chapter 4 Refractio of Light, Sectio III, IV 7. History I Eglish-speakig coutries, the law of refractio is kow as Sell s Law, after the Dutch

More information

Reading and Writing RSS Feeds

Reading and Writing RSS Feeds DAY 19: Readig ad Writig RSS Feeds Today you work with Extesible Markup Laguage (XML), a formattig stadard that eables data to be completely portable. You ll explore XML i the followig ways: Represetig

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13 CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis

More information

Numerical Methods Lecture 6 - Curve Fitting Techniques

Numerical Methods Lecture 6 - Curve Fitting Techniques Numerical Methods Lecture 6 - Curve Fittig Techiques Topics motivatio iterpolatio liear regressio higher order polyomial form expoetial form Curve fittig - motivatio For root fidig, we used a give fuctio

More information

It just came to me that I 8.2 GRAPHS AND CONVERGENCE

It just came to me that I 8.2 GRAPHS AND CONVERGENCE 44 Chapter 8 Discrete Mathematics: Fuctios o the Set of Natural Numbers (a) Take several odd, positive itegers for a ad write out eough terms of the 3N sequece to reach a repeatig loop (b) Show that ot

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19 CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.

More information

The Magma Database file formats

The Magma Database file formats The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,

More information

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs CHAPTER IV: GRAPH THEORY Sectio : Itroductio to Graphs Sice this class is called Number-Theoretic ad Discrete Structures, it would be a crime to oly focus o umber theory regardless how woderful those topics

More information

the beginning of the program in order for it to work correctly. Similarly, a Confirm

the beginning of the program in order for it to work correctly. Similarly, a Confirm I our sytax, a Assume statemet will be used to record what must be true at the begiig of the program i order for it to work correctly. Similarly, a Cofirm statemet is used to record what should be true

More information

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup Chapter 18 Vectors ad Arrays Bjare Stroustrup Vector revisited How are they implemeted? Poiters ad free store Destructors Iitializatio Copy ad move Arrays Array ad poiter problems Chagig size Templates

More information

CMPT 125 Assignment 2 Solutions

CMPT 125 Assignment 2 Solutions CMPT 25 Assigmet 2 Solutios Questio (20 marks total) a) Let s cosider a iteger array of size 0. (0 marks, each part is 2 marks) it a[0]; I. How would you assig a poiter, called pa, to store the address

More information

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000. 5-23 The course that gives CM its Zip Memory Maagemet II: Dyamic Storage Allocatio Mar 6, 2000 Topics Segregated lists Buddy system Garbage collectio Mark ad Sweep Copyig eferece coutig Basic allocator

More information

CS 111: Program Design I Lecture 18: Web and getting text from it

CS 111: Program Design I Lecture 18: Web and getting text from it CS 111: Program Desig I Lecture 18: Web ad gettig text from it Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago October 25, 2016 Goals Lear about Iteret ad how to access it directly from

More information

TUTORIAL Create Playlist Helen Doron Course

TUTORIAL Create Playlist Helen Doron Course TUTORIAL Create Playlist Hele Doro Course TUTY Tutorial Create Playlist Hele Doro Course Writte by Serafii Giampiero (INV SRL) Revised by Raffaele Forgioe (INV SRL) Editio EN - 0 Jue 0-0, INV S.r.l. Cotact:

More information

Lecture 28: Data Link Layer

Lecture 28: Data Link Layer Automatic Repeat Request (ARQ) 2. Go ack N ARQ Although the Stop ad Wait ARQ is very simple, you ca easily show that it has very the low efficiecy. The low efficiecy comes from the fact that the trasmittig

More information

27 Refraction, Dispersion, Internal Reflection

27 Refraction, Dispersion, Internal Reflection Chapter 7 Refractio, Dispersio, Iteral Reflectio 7 Refractio, Dispersio, Iteral Reflectio Whe we talked about thi film iterferece, we said that whe light ecouters a smooth iterface betwee two trasparet

More information

Elementary Educational Computer

Elementary Educational Computer Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified

More information

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 8 Strigs ad Vectors Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Slide 8-3 8.1 A Array Type for Strigs A Array Type for Strigs C-strigs ca be used to represet strigs

More information

The Closest Line to a Data Set in the Plane. David Gurney Southeastern Louisiana University Hammond, Louisiana

The Closest Line to a Data Set in the Plane. David Gurney Southeastern Louisiana University Hammond, Louisiana The Closest Lie to a Data Set i the Plae David Gurey Southeaster Louisiaa Uiversity Hammod, Louisiaa ABSTRACT This paper looks at three differet measures of distace betwee a lie ad a data set i the plae:

More information

BST Sequence of Operations

BST Sequence of Operations Splay Trees Problems with BSTs Because the shape of a BST is determied by the order that data is iserted, we ru the risk of trees that are essetially lists 12 21 20 32 24 37 15 40 55 56 77 2 BST Sequece

More information

Chapter 3. More Flow of Control. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 3. More Flow of Control. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 3 More Flow of Cotrol Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 3.1 Usig Boolea Expressios 3.2 Multiway Braches 3.3 More about C++ Loop Statemets 3.4 Desigig Loops Copyright

More information

A Resource for Free-standing Mathematics Qualifications

A Resource for Free-standing Mathematics Qualifications Ope.ls The first sheet is show elow. It is set up to show graphs with equatios of the form = m + c At preset the values of m ad c are oth zero. You ca chage these values usig the scroll ars. Leave the

More information

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of

More information

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4

More information

A Taste of Maya. Character Setup

A Taste of Maya. Character Setup This tutorial goes through the steps to add aimatio cotrols to a previously modeled character. The character i the scee below is wearig clothes made with Cloth ad the sceery has bee created with Pait Effects.

More information

condition w i B i S maximum u i

condition w i B i S maximum u i ecture 10 Dyamic Programmig 10.1 Kapsack Problem November 1, 2004 ecturer: Kamal Jai Notes: Tobias Holgers We are give a set of items U = {a 1, a 2,..., a }. Each item has a weight w i Z + ad a utility

More information

Chapter 6. I/O Streams as an Introduction to Objects and Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 6. I/O Streams as an Introduction to Objects and Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 6 I/O Streams as a Itroductio to Objects ad Classes Overview 6.1 Streams ad Basic File I/O 6.2 Tools for Stream I/O 6.3 Character I/O Slide 6-3 6.1 Streams ad Basic File I/O I/O Streams I/O refers

More information

Homework 1 Solutions MA 522 Fall 2017

Homework 1 Solutions MA 522 Fall 2017 Homework 1 Solutios MA 5 Fall 017 1. Cosider the searchig problem: Iput A sequece of umbers A = [a 1,..., a ] ad a value v. Output A idex i such that v = A[i] or the special value NIL if v does ot appear

More information

Workflow Extensions User Guide. StarTeam 12.0

Workflow Extensions User Guide. StarTeam 12.0 Workflow Extesios User Guide StarTeam 12.0 Micro Focus 575 Ato Blvd., Suite 510 Costa Mesa, CA 92626 Copyright 2011 Micro Focus IP Developmet Limited. All Rights Reserved. StarTeam cotais derivative works

More information

Data Structures Week #5. Trees (Ağaçlar)

Data Structures Week #5. Trees (Ağaçlar) Data Structures Week #5 Trees Ağaçlar) Trees Ağaçlar) Toros Gökarı Avrupa Gökarı October 28, 2014 Boraha Tümer, Ph.D. 2 Trees Ağaçlar) October 28, 2014 Boraha Tümer, Ph.D. 3 Outlie Trees Deiitios Implemetatio

More information

FURTHER INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS)

FURTHER INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS) Mathematics Revisio Guides More Trigoometric ad Log Itegrals Page of 7 MK HOME TUITION Mathematics Revisio Guides Level: AS / A Level AQA : C Edexcel: C OCR: C OCR MEI: C FURTHER INTEGRATION TECHNIQUES

More information

Computer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria.

Computer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria. Computer Sciece Foudatio Exam August, 005 Computer Sciece Sectio A No Calculators! Name: SSN: KEY Solutios ad Gradig Criteria Score: 50 I this sectio of the exam, there are four (4) problems. You must

More information

Pattern Recognition Systems Lab 1 Least Mean Squares

Pattern Recognition Systems Lab 1 Least Mean Squares Patter Recogitio Systems Lab 1 Least Mea Squares 1. Objectives This laboratory work itroduces the OpeCV-based framework used throughout the course. I this assigmet a lie is fitted to a set of poits usig

More information

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 8 Strigs ad Vectors Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Copyright 2015 Pearso Educatio, Ltd..

More information

Workflow model GM AR. Gumpy. Dynagump. At a very high level, this is what gump does. We ll be looking at each of the items described here seperately.

Workflow model GM AR. Gumpy. Dynagump. At a very high level, this is what gump does. We ll be looking at each of the items described here seperately. Workflow model GM AR Gumpy RM Dyagump At a very high level, this is what gump does. We ll be lookig at each of the items described here seperately. User edits project descriptor ad commits s maitai their

More information

Descriptive Statistics Summary Lists

Descriptive Statistics Summary Lists Chapter 209 Descriptive Statistics Summary Lists Itroductio This procedure is used to summarize cotiuous data. Large volumes of such data may be easily summarized i statistical lists of meas, couts, stadard

More information

CS 111: Program Design I Lecture 15: Modules, Pandas again. Robert H. Sloan & Richard Warner University of Illinois at Chicago March 8, 2018

CS 111: Program Design I Lecture 15: Modules, Pandas again. Robert H. Sloan & Richard Warner University of Illinois at Chicago March 8, 2018 CS 111: Program Desig I Lecture 15: Modules, Padas agai Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago March 8, 2018 PYTHON STANDARD LIBRARY & BEYOND: MODULES Extedig Pytho Every moder

More information

MR-2010I %MktBSize Macro 989. %MktBSize Macro

MR-2010I %MktBSize Macro 989. %MktBSize Macro MR-2010I %MktBSize Macro 989 %MktBSize Macro The %MktBSize autocall macro suggests sizes for balaced icomplete block desigs (BIBDs). The sizes that it reports are sizes that meet ecessary but ot sufficiet

More information

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1 CS200: Hash Tables Prichard Ch. 13.2 CS200 - Hash Tables 1 Table Implemetatios: average cases Search Add Remove Sorted array-based Usorted array-based Balaced Search Trees O(log ) O() O() O() O(1) O()

More information

Lecture 18. Optimization in n dimensions

Lecture 18. Optimization in n dimensions Lecture 8 Optimizatio i dimesios Itroductio We ow cosider the problem of miimizig a sigle scalar fuctio of variables, f x, where x=[ x, x,, x ]T. The D case ca be visualized as fidig the lowest poit of

More information

Some non-existence results on Leech trees

Some non-existence results on Leech trees Some o-existece results o Leech trees László A.Székely Hua Wag Yog Zhag Uiversity of South Carolia This paper is dedicated to the memory of Domiique de Cae, who itroduced LAS to Leech trees.. Abstract

More information

Combination Labelings Of Graphs

Combination Labelings Of Graphs Applied Mathematics E-Notes, (0), - c ISSN 0-0 Available free at mirror sites of http://wwwmaththuedutw/ame/ Combiatio Labeligs Of Graphs Pak Chig Li y Received February 0 Abstract Suppose G = (V; E) is

More information

Data diverse software fault tolerance techniques

Data diverse software fault tolerance techniques Data diverse software fault tolerace techiques Complemets desig diversity by compesatig for desig diversity s s limitatios Ivolves obtaiig a related set of poits i the program data space, executig the

More information

Math 3201 Notes Chapter 4: Rational Expressions & Equations

Math 3201 Notes Chapter 4: Rational Expressions & Equations Learig Goals: See p. tet.. Equivalet Ratioal Epressios ( classes) Read Goal p. 6 tet. Math 0 Notes Chapter : Ratioal Epressios & Equatios. Defie ad give a eample of a ratioal epressio. p. 6. Defie o-permissible

More information