1 / 8

Assignment #1 Due: Oct. 14, 2013

3. 5. 5. 4. 6. 1. 3. Assignment #1 Due: Oct. 14, 2013 3. Apply the following algorithm to the B+-tree shown in Fig. 4 to store it in a data file. Trace the computation process. Algorithm:. push(root, -1, -1); while (S is not empty) do { x := pop( ); store x.data in file F;

doli
Télécharger la présentation

Assignment #1 Due: Oct. 14, 2013

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3 5 5 4 6 1 3 • Assignment #1 • Due: Oct. 14, 2013 • 3. Apply the following algorithm to the B+-tree shown in Fig. 4 to store it in a data file. Trace the computation process. Algorithm: push(root, -1, -1); while (S is not empty) do { x := pop( ); store x.data in file F; assume that the address of x in F is ad; if x.address-of-parent  -1 then { y := x.address-of-parent; z := x.position; write ad in page y at position z in F; } let x1, …, xk be the children of v; for (i = k to 1) {push(xi, ad, i)}; } Fig. 4 ACS-7102 Yangjun Chen

  2. 3, 5 -1 -1 B+-tree file 0 3 5 1, 3 0 1 S: B+-tree file 4 0 2 0 13 5 6 0 3 1 1 3 4 0 2 6 0 3 S: S: data address-of- parent position key values ACS-7102 Yangjun Chen

  3. S: B+-tree file 0 132 5 1 1 3 2 4 6 0 3 S: data address-of- parent position key values S: B+-tree file 0 132 5 3 1 1 3 empty 2 4 3 6 ACS-7102 Yangjun Chen

  4. / a / b [ / / c “ M a l i b “ a n d … • 4. Write an algorithm to transform a simplified XPath expression (in which the subexpressions in any condition can be connected only with , e.g., /StarMovieData/Star[//City = “Malibu” and //Street = “123 Maple St.”]/Name) to a tree structure. /StarMovieData/Star[//City = “Malibu”]/Name /a/b[.//c[…]/e = “Malibu” and .//d = 5]/e Assume that an XPath is stored in a character array A: When we scan A, we will meet the following different cases: ‘/’ followed by a character, ‘//’, ‘[’ Comparison symbols: ‘=’, ‘<’, ‘>’, ‘<>’, ‘≠’ ACS-7102 Yangjun Chen

  5. Before we scan A, a virtual root r is created. Algorithm tree-generation(A): Scan array A; If A[i] is ‘/’ followed by a character, create a node P labeled with the string A[i+1..j]such that A[j+1] is ‘/’,‘[‘, or a comparison symbol. i := j + 1. Make p a /-child ofr. r := p. If A[i..i+1] = ‘//’, create a node P labeled with the string A[i+2..j] such that A[j+1] is ‘/’,‘[‘, or a comparison symbol. i := j + 1. Make p a //-child ofr. r := p. ACS-7102 Yangjun Chen

  6. If A[I ] is a comparison symbol, create a node p for the value. Make p a child of r. Label the edge with the symbol. If A[i] = ‘[’, recognize the conditions C between the ‘[‘ and the matching ‘]’ following A[i]. Assume that it is A[j]. Let C = path1 and path2 and … and pathk. Do the following: for a = 1 to k do { call tree-generation(patha); assume that Tabe the subtree created by the recursive call; make it a subtree of r; } i := j + 1. If i = n + 1, remove the virtual node and return the tree. ACS-7102 Yangjun Chen

  7. root book author author writing writing cf mh sw authorOf authorOf city address name name publisher address street year title ad1 ad2 Mark Hamill Carrie Fisher Oak B’wood Star War The MIT Press 1977 city street city street Maple H’wood Locust Malibu • 5. Represent the following graph as an XML document. ACS-7102 Yangjun Chen

  8. <? Xml version = “1.0” encoding = “utf-8” standalone = “yes” ?> <StarMovieData> <Star starID = “cf” starredIn = “sw”> <Name>Carrie Fishes</Name> <Address> <Street>123 Maple St.</Street><City>Hollywood</City> </Address> <Address> <Street>5 Locust Ln.</Street><City>Malibu</City> <Address> </Star> <Star starID = “mh” starredIn = “sw”> <Name>Mark Hamill</Name><Street>456 Oak Rd.</Street> <City>Brentwood</City> </Star> <Movie movieID = “sw” starOf = “cf mh”> <Title>Star Wars</title><Year>1977</Year> </Movie> </StarMovieData> ACS-7102 Yangjun Chen

More Related