XML and Databases. Lecture 3 XML into RDBMS. Sebastian Maneth NICTA and UNSW

Size: px
Start display at page:

Download "XML and Databases. Lecture 3 XML into RDBMS. Sebastian Maneth NICTA and UNSW"

Transcription

1 XML and Databases Leture 3 XML into RDBMS Sebastian Maneth NICTA and UNSW CSE@UNSW -- Semester 1, 2010

2 2 Leture 3 XML Into RDBMS

3 Memory Representations 3 Fats DOM is easy to use, but memory heavy. in-memory size usually 5-10 times larger than size of original file. SAX is very flexible. Using arrays or binary trees wo bakward pointers, in-memory size is approx. same as size of original file. Can be further improved using DAGs/sharing-Graphs & oding/ompression for data values.

4 Memory Representations 4 Fats DOM is easy to use, but memory heavy. in-memory size usually 5-10 times larger than size of original file. SAX is very flexible. Using arrays or binary trees wo bakward pointers, in-memory size is approx. same as size of original file. Can be further improved using DAGs/sharing-Graphs & oding/ompression for data values. TODAY How an we map XML into a relational DB?

5 Memory Representations 5 Fats DOM is easy to use, but memory heavy. in-memory size usually 5-10 times larger than size of original file. SAX is very flexible. Using arrays or binary trees wo bakward pointers, in-memory size is approx. same as size of original file. Can be further improved using DAGs/sharing-Graphs & oding/ompression for data values. TODAY How an we map XML into a relational DB? but first: Memory effiient tree traversals using e.g. DOM?

6 Traversals and Pre/Post-Enoding 6 1. Pre-Order Traversal (reursively) 2. Post-Order 3. Pre-Order (iteratively) 4. Into RDBMS with Pre/Post-enoding TODAY How an we map XML into a relational DB? but first: Memory effiient tree traversals using e.g. DOM?

7 Tree Traversals Start at root node; want to visit every node. 7 root firstchild a lastchild [ ] hildnodes b a b d b

8 Tree Traversals Start at root node; want to visit every node. 8 (1) reursively root firstchild a lastchild [ ] hildnodes b a b d b

9 Tree Traversals Start at root node; want to visit every node. 9 (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) root firstchild a lastchild [ ] hildnodes b a b d b

10 Tree Traversals Start at root node; want to visit every node. Tr(1) pr(1) Tr(2) pr(2) 10 (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) root firstchild 1 a lastchild 2 [ ] hildnodes b a b d b

11 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) Tr(1) pr(1) Tr(2) pr(2) Tr(3) pr(3) Tr(4) pr(4) 11 root 1 a firstchild lastchild 2 3 b a b [ ] hildnodes 4 d b

12 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) root Tr(1) pr(1) Tr(2) pr(2) Tr(3) pr(3) Tr(4) pr(4) Tr(5) pr(5) Tr(6) pr(6) 12 1 a firstchild lastchild 2 3 b a b [ ] hildnodes 4 5 d b 6

13 firstchild Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) b a b a root reursion depth = 4 lastchild Tr(1) pr(1) Tr(2) pr(2) Tr(3) pr(3) Tr(4) pr(4) Tr(5) pr(5) Tr(6) pr(6) [ ] hildnodes d b 6

14 firstchild Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) b a b 4 5 d 1 a root b lastchild [ ] hildnodes 8 11 reursion depth = 4 12 Tr(1) pr(1) Tr(2) pr(2) Tr(3) pr(3) Tr(4) pr(4) Tr(5) pr(5) Tr(6) pr(6) Tr(7) pr(7) Tr(8) pr(8) Tr(9) pr(9) Tr(10) END pr(10) Tr(11) pr(11) Tr(12) pr(12)

15 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) Memory need proportional to the height of the XML do tree. 15 Should be fine. Usually height (XML do) is small. ( 15)

16 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) Memory need proportional to the height of the XML do tree. 16 Should be fine. Usually height (XML do) is small. ( 15) Problemati 2nd reursion on hildren TR(n:Node){ print(n); if(m=firstchild(n))!=nil then Tr(m); if(m=nextsibling(n))!=nil then Tr(m)

17 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) Memory need proportional to the height of the XML do tree. 17 Should be fine. Usually height (XML do) is small. ( 15) Problemati 2nd reursion on hildren TR(n:Node){ print(n); if(m=firstchild(n))!=nil then Tr(m); if(m=nextsibling(n))!=nil then Tr(m)

18 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) Memory need proportional to the height of the XML do tree. 18 Should be fine. Usually height (XML do) is small. ( 15) Problemati 2nd reursion on hildren A B C D E F TR(n:Node){ print(n); if(m=firstchild(n))!=nil then TR(m); if(m=nextsibling(n))!=nil then TR(m) TR(1);pr(1) TR(2);pr(2) TR(3);pr(3) TR(A);pr(A) TR(B);pr(B)

19 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) Memory need proportional to the height of the XML do tree. 19 Should be fine. Usually height (XML do) is small. ( 15) Problemati 2nd reursion on hildren TR(n:Node){ print(n); if(m=firstchild(n))!=nil then Tr(m); if(m=nextsibling(n))!=nil then Tr(m) A B C D E F TR(1);pr(1) TR(2);pr(2) TR(3);pr(3) TR(A);pr(A) TR(B);pr(B) Memory need proportional to max. length of (firstchild nextsibling)*-path

20 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) Memory need proportional to the height of the XML do tree. 20 Should be fine. Usually height (XML do) is small. ( 15) Problemati 2nd reursion on hildren A B C D E F Tr(n:Node){ print(n); if(m=firstchild(n))!=nil then Tr(m); if(m=nextsibling(n))!=nil then Tr(m) TR(1);pr(1) TR(2);pr(2) TR(3);pr(3) TR(A);pr(A) TR(B);pr(B) Can be HUGE!!! =size(tree) Memory need proportional to max. length of (firstchild nextsibling)*-path

21 root 21 firstchild a lastchild [ ] hildnodes b a b d b Question What is the max reursion depth on this tree? Tr(n:Node){ print(n); if(m=firstchild(n))!=nil then Tr(m); if(m=nextsibling(n))!=nil then Tr(m) Can be HUGE!!! =size(tree) Memory need proportional to max. length of (firstchild nextsibling)*-path

22 Tree Traversals Start at root node; want to visit every node. (1) reursively Traverse(n:Node){ print(n); For m in hildnodes(n) Traverse(m) Memory need proportional to the height of the XML tree. 22 Should be fine. Usually height (XML do) is small. ( 15) Problemati 2nd reursion on hildren Reall binary tree (firstchild/nextsibling) enoding. Question In the binary tree, what orresponds to this number? A B C D E F TR(1);pr(1) TR(2);pr(2) TR(3);pr(3) TR(A);pr(A) TR(B);pr(B) max. length of (firstchild nextsibling)*-path

23 Binary Tree Enoding 23 Reall firstchild/nextsibling enoding. The firstchild The nextsibling beomes the left pointer beomes the right pointer per Node 2 pointers/ids + label info 1 a firstchild 2 b a b d b ID f:ns:lab (2:-:a) 2 (-:3:b) 3 (4:9:a) 4 (-:5:) 5 (6:8:d) 6 (-:7:) 7 (-:-:) 8 (-:-:b) 9 (-:10:b) 10 (-,-:)

24 Tree Traversals 24 both, Traverse and TR an be exeuted on the f/ns-binary tree enoding. 1 a firstchild 2 b a b d b 8 6 7

25 Tree Traversals 25 both, Traverse and Tr an be exeuted on the f/ns-binary tree enoding. For m in hildnodes(n) Traverse(n) if(m=n->left)!=nil { while(m=n->right)!=nil Traverse(m) 1 a firstchild 2 b a b if(m=firstchild(n))!=nil then TR(m); if(m=nextsibling(n))!=nil then TR(m) if(m=n->left)!=nil then TR(m) if(m=n->right)!=nil then TR(m) 4 5 d b 8 7

26 Tree Traversals 26 both, Traverse and Tr an be exeuted on the f/ns-binary tree enoding. For m in hildnodes(n) Traverse(n) if(m=n->left)!=nil { while(m=n->right)!=nil Traverse(m) 1 a firstchild 2 b a b if(m=firstchild(n))!=nil then Tr(m); if(m=nextsibling(n))!=nil then Tr(m) if(m=n->left)!=nil then TR(m) if(m=n->right)!=nil then TR(m) 4 5 d b 7 8 Reursion takes are of the fat that we do not have parent pointers. (true for both, unranked & binary tree)

27 Other Traversals We disussed the Pre-order of the tree. (or, in XML-jargon: doument-order). Realized by Traverse & TR Post-order of a tree = 1. Traverse left subtree in post-order 2. Traverse right subtree in post-order 3. Visit the root Reverse Polish Notation In-order Breadth-First 4 1 (left-to-right) 2 6 level-order Binary Searh Tree (inreasing) q.enq(root); while(not q.empty){ Visit(q.deq); If(q->Left!=NIL) q.enq(q->left) If(q->Right!=NIL) q.enq(q->right)

28 Other Traversals We disussed the Pre-order of the tree. (or, in XML-jargon: doument-order). Realized by Traverse & TR Post-order of a tree = 1. Traverse left subtree in post-order 2. Traverse right subtree in post-order 3. Visit the root Reverse Polish Notation Breadth-First (left-to-right) level-order Memory need proportional to max. #nodes on one level q.enq(root); while(not q.empty){ Visit(q.deq); If(q->Left!=NIL) q.enq(q->left) If(q->Right!=NIL) q.enq(q->right)

29 Other Traversals We disussed the Pre-order of the tree. (or, in XML-jargon: doument-order). Realized by Traverse & TR Post-order of a tree = 1. Traverse left subtree in post-order 2. Traverse right subtree in post-order 3. Visit the root Reverse Polish Notation Can be HUGE!!! Memory need proportional to max. #nodes on one level Breadth-First (left-to-right) level-order q.enq(root); while(not q.empty){ Visit(q.deq); If(q->Left!=NIL) q.enq(q->left) If(q->Right!=NIL) q.enq(q->right);

30 Pre-Order 30 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) 1 a 2 b 3 a 8 b d 9 b 6 7

31 Pre-Order 31 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) b a b a How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; d b

32 Pre-Order 32 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(1) b a b a How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; d b

33 Pre-Order 33 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) pre(1) b a b a How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; d b

34 Pre-Order 34 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) b a b pre(1) d a b How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n;

35 Pre-Order 35 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) b a b pre(1) pre(3) d a b How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n;

36 Pre-Order 36 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) b a b pre(4) pre(1) pre(3) d a b How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n;

37 Pre-Order 37 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) b a b pre(4) pre(5) pre(1) pre(3) d a b How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n;

38 Pre-Order 38 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) b a b pre(4) pre(5) pre(1) pre(3) d a b How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6)

39 Pre-Order 39 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) b a b pre(4) pre(5) pre(1) pre(3) d a b How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6) pre(7)

40 Pre-Order 40 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) b a b pre(4) pre(5) pre(1) pre(3) d a b pre(8) How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6) pre(7)

41 Pre-Order 41 We saw how to ompute Pre-order (and Post and In) (1) reursively memory need: O(max_height) pre(2) b a b pre(4) pre(5) pre(1) pre(3) d a b pre(9) pre(8) pre(10) How to ompute Pre-order (2) iteratively Memory need? i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6) pre(7) if(n=nil)then break;

42 Pre-Order 42 How to ompute Pre-order (2) iteratively Memory need? pre(1) pre(2) pre(3) a pre(10) b a b pre(4) pre(9) d b pre(5) pre(8) No reursion! Needs onstant memory! (only one pointer) i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6) pre(7) if(n=nil)then break;

43 Pre-Order 43 Question Given a binary tree, (top-down, no parent) how muh memory do you need to ompute pre? No reursion! Needs onstant memory! (only one pointer) pre(1) pre(2) pre(3) a pre(10) b a b pre(4) pre(9) d b pre(5) pre(8) i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6) pre(7) if(n=nil)then break;

44 Pre-Order 44 Question Given a binary tree, (top-down, no parent) how muh memory do you need to ompute pre? Can you do it w. onstant memory? pre(2) b a b pre(4) pre(5) pre(1) pre(3) d a b pre(9) pre(8) pre(10) No reursion! Needs onstant memory! (only one pointer) i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6) pre(7) if(n=nil)then break;

45 Pre-Order 45 Question Fun (MS ji) How muh memory you need to hek for yles, in a single-linked (pointer) list? pre(2) b a b pre(4) pre(5) pre(1) pre(3) d a b pre(9) pre(8) pre(10) No reursion! Needs onstant memory! (only one pointer) i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6) pre(7) if(n=nil)then break;

46 Pre-Order 46 Question Do you see how to do Post- and In-oder iteratively? No reursion! Needs onstant memory! (only one pointer) pre(1) pre(2) pre(3) a pre(10) b a b pre(4) pre(9) d b pre(5) pre(8) i=1; n=root; pre(i)=n; repeat { while(firstchild(n)!=nil) { n=firstchild(n); pre(++i)=n; while(nextsibling(n)=nil) { n=parent(n); n=nextsibling(n); pre(++i)=n; pre(6) pre(7) if(n=nil)then break;

47 Pre-Order 47 From pre( ) we an ompute PreFollowing( n ) = { nodes m with pre(m) > n PrePreeding( n ) = { nodes m with pre(m) < n 1 a 2 b 3 a 9 b d 8 b 6 7 pre

48 From pre( ) Pre-Order What is this? 48 we an ompute PreFollowing( n ) = { nodes m with pre(m) > n PrePreeding( n ) = { nodes m with pre(m) < n 1 a 2 b 3 a 9 b d 8 b 6 7 pre

49 From pre( ) Pre-Order What is this? 49 we an ompute PreFollowing( n ) = { nodes m with pre(m) > n PrePreeding( n ) = { nodes m with pre(m) < n 1 a 2 b 3 a 9 b d 8 b 6 7 pre foll pre

50 From pre( ) Pre-Order useful?? 50 we an ompute PreFollowing( n ) = { nodes m with pre(m) > n PrePreeding( n ) = { nodes m with pre(m) < n Not tree (navigation) omplete hild? ns? 1 a 2 b 3 a 8 b d 9 b 6 7 pre

51 XML to RDBMS Enoding 51

52 52

53 53

54 54

55 XML to RDBMS Enoding 55 pre( ) is not enough Other possibilities: (1) large (unparsed) text blok (2) Shema-based enoding (3) Adjaeny-based enoding Dead Ends No good Questions Why is (1) a dead end?

56 56

57 57

58 58

59 59

60 Pre/Post Enoding 60 Add POST order 10 1 a b 3 a 9 b d 8 b PRE POST lab a 2 1 b 3 6 a d b 9 8 b 10 9 CREATE VIEW desendant AS SELECT r1.pre,r2.pre FROM R r1, R r2 WHERE r1.pre<r2.pre AND r1.post>r2.post

61 Pre/Post Enoding 61 Add POST order 10 1 a b 3 a 9 b d 8 b PRE POST lab a 2 1 b 3 6 a d b 9 8 b 10 9 CREATE VIEW desendant AS SELECT r1.pre,r2.pre FROM R r1, R r2 WHERE r1.pre<r2.pre AND r1.post>r2.post strutural join

62 62

63 63

64 Pre/Post Enoding 64 Straightforward how to ompute, for a given node, desendants anestors following preeding Questions How to do lastchild parent hildnodes Can you find orresponding SQL queries?

65 65 END Leture 3

Data Structures in Java

Data Structures in Java Data Strutures in Java Leture 8: Trees and Tree Traversals. 10/5/2015 Daniel Bauer 1 Trees in Computer Siene A lot of data omes in a hierarhial/nested struture. Mathematial expressions. Program struture.

More information

XML and Databases. Lecture 10 XPath Evaluation using RDBMS. Sebastian Maneth NICTA and UNSW

XML and Databases. Lecture 10 XPath Evaluation using RDBMS. Sebastian Maneth NICTA and UNSW XML and Databases Lecture 10 XPath Evaluation using RDBMS Sebastian Maneth NICTA and UNSW CSE@UNSW -- Semester 1, 2009 Outline 1. Recall pre / post encoding 2. XPath with //, ancestor, @, and text() 3.

More information

XML and Databases. Outline. Outline - Lectures. Outline - Assignments. from Lecture 3 : XPath. Sebastian Maneth NICTA and UNSW

XML and Databases. Outline. Outline - Lectures. Outline - Assignments. from Lecture 3 : XPath. Sebastian Maneth NICTA and UNSW Outline XML and Databases Lecture 10 XPath Evaluation using RDBMS 1. Recall / encoding 2. XPath with //,, @, and text() 3. XPath with / and -sibling: use / size / level encoding Sebastian Maneth NICTA

More information

Algorithms for External Memory Lecture 6 Graph Algorithms - Weighted List Ranking

Algorithms for External Memory Lecture 6 Graph Algorithms - Weighted List Ranking Algorithms for External Memory Leture 6 Graph Algorithms - Weighted List Ranking Leturer: Nodari Sithinava Sribe: Andi Hellmund, Simon Ohsenreither 1 Introdution & Motivation After talking about I/O-effiient

More information

Trees. CSE 373 Data Structures

Trees. CSE 373 Data Structures Trees CSE 373 Data Structures Readings Reading Chapter 7 Trees 2 Why Do We Need Trees? Lists, Stacks, and Queues are linear relationships Information often contains hierarchical relationships File directories

More information

Tree. A path is a connected sequence of edges. A tree topology is acyclic there is no loop.

Tree. A path is a connected sequence of edges. A tree topology is acyclic there is no loop. Tree A tree consists of a set of nodes and a set of edges connecting pairs of nodes. A tree has the property that there is exactly one path (no more, no less) between any pair of nodes. A path is a connected

More information

Section 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents

Section 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents Section 5.5 Binary Tree A binary tree is a rooted tree in which each vertex has at most two children and each child is designated as being a left child or a right child. Thus, in a binary tree, each vertex

More information

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

CSE 373 APRIL 17 TH TREE BALANCE AND AVL CSE 373 APRIL 17 TH TREE BALANCE AND AVL ASSORTED MINUTIAE HW3 due Wednesday Double check submissions Use binary search for SADict Midterm text Friday Review in Class on Wednesday Testing Advice Empty

More information

Dynamic Programming. Lecture #8 of Algorithms, Data structures and Complexity. Joost-Pieter Katoen Formal Methods and Tools Group

Dynamic Programming. Lecture #8 of Algorithms, Data structures and Complexity. Joost-Pieter Katoen Formal Methods and Tools Group Dynami Programming Leture #8 of Algorithms, Data strutures and Complexity Joost-Pieter Katoen Formal Methods and Tools Group E-mail: katoen@s.utwente.nl Otober 29, 2002 JPK #8: Dynami Programming ADC (214020)

More information

Gray Codes for Reflectable Languages

Gray Codes for Reflectable Languages Gray Codes for Refletable Languages Yue Li Joe Sawada Marh 8, 2008 Abstrat We lassify a type of language alled a refletable language. We then develop a generi algorithm that an be used to list all strings

More information

Uses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010

Uses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010 Uses for About Binary January 31, 2010 Uses for About Binary Uses for Uses for About Basic Idea Implementing Binary Example: Expression Binary Search Uses for Uses for About Binary Uses for Storage Binary

More information

Friday, March 30. Last time we were talking about traversal of a rooted ordered tree, having defined preorder traversal. We will continue from there.

Friday, March 30. Last time we were talking about traversal of a rooted ordered tree, having defined preorder traversal. We will continue from there. Friday, March 30 Last time we were talking about traversal of a rooted ordered tree, having defined preorder traversal. We will continue from there. Postorder traversal (recursive definition) If T consists

More information

7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w

7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w Chapter 7 Trees 7.1 Introduction A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w Tree Terminology Parent Ancestor Child Descendant Siblings

More information

Lecture Notes 16 - Trees CSS 501 Data Structures and Object-Oriented Programming Professor Clark F. Olson

Lecture Notes 16 - Trees CSS 501 Data Structures and Object-Oriented Programming Professor Clark F. Olson Lecture Notes 16 - Trees CSS 501 Data Structures and Object-Oriented Programming Professor Clark F. Olson Reading: Carrano, Chapter 15 Introduction to trees The data structures we have seen so far to implement

More information

Binary Trees

Binary Trees Binary Trees 4-7-2005 Opening Discussion What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment? What is a Tree? You are all familiar with what

More information

Why Do We Need Trees?

Why Do We Need Trees? CSE 373 Lecture 6: Trees Today s agenda: Trees: Definition and terminology Traversing trees Binary search trees Inserting into and deleting from trees Covered in Chapter 4 of the text Why Do We Need Trees?

More information

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree. The Lecture Contains: Index structure Binary search tree (BST) B-tree B+-tree Order file:///c /Documents%20and%20Settings/iitkrana1/My%20Documents/Google%20Talk%20Received%20Files/ist_data/lecture13/13_1.htm[6/14/2012

More information

XML Data Streams. XML Stream Processing. XML Stream Processing. Yanlei Diao. University of Massachusetts Amherst

XML Data Streams. XML Stream Processing. XML Stream Processing. Yanlei Diao. University of Massachusetts Amherst XML Stream Proessing Yanlei Diao University of Massahusetts Amherst XML Data Streams XML is the wire format for data exhanged online. Purhase orders http://www.oasis-open.org/ommittees/t_home.php?wg_abbrev=ubl

More information

1 The Knuth-Morris-Pratt Algorithm

1 The Knuth-Morris-Pratt Algorithm 5-45/65: Design & Analysis of Algorithms September 26, 26 Leture #9: String Mathing last hanged: September 26, 27 There s an entire field dediated to solving problems on strings. The book Algorithms on

More information

Recursion examples: Problem 2. (More) Recursion and Lists. Tail recursion. Recursion examples: Problem 2. Recursion examples: Problem 3

Recursion examples: Problem 2. (More) Recursion and Lists. Tail recursion. Recursion examples: Problem 2. Recursion examples: Problem 3 Reursion eamples: Problem 2 (More) Reursion and s Reursive funtion to reverse a string publi String revstring(string str) { if(str.equals( )) return str; return revstring(str.substring(1, str.length()))

More information

L11 Balanced Trees. Alice E. Fischer. Fall Alice E. Fischer L11 Balanced Trees... 1/34 Fall / 34

L11 Balanced Trees. Alice E. Fischer. Fall Alice E. Fischer L11 Balanced Trees... 1/34 Fall / 34 L11 Balaned Trees Alie E. Fisher Fall 2018 Alie E. Fisher L11 Balaned Trees... 1/34 Fall 2018 1 / 34 Outline 1 AVL Trees 2 Red-Blak Trees Insertion Insertion 3 B-Trees Alie E. Fisher L11 Balaned Trees...

More information

Simple strategy Computes shortest paths from the start note

Simple strategy Computes shortest paths from the start note Leture Notes for I500 Fall 2009 Fundamental Computer Conepts of Informatis by Xiaoqian Zhang (Instrutor: Predrag Radivoja) Last time: dynami programming Today: Elementary graph algorithm (textbook Chapter

More information

Databases and Information Systems 1

Databases and Information Systems 1 Databases and Information Systems 7. XML storage and core XPath implementation 7.. Mapping XML to relational databases and Datalog how to store an XML document in a relation database? how to answer XPath

More information

Databases and Information Systems XML storage in RDBMS and core XPath implementation. Prof. Dr. Stefan Böttcher

Databases and Information Systems XML storage in RDBMS and core XPath implementation. Prof. Dr. Stefan Böttcher Databases and Information Systems 1 8. XML storage in RDBMS and core XPath implementation Prof. Dr. Stefan Böttcher XML storage and core XPath implementation 8.1. XML in commercial DBMS 8.2. Mapping XML

More information

CSCI-401 Examlet #5. Name: Class: Date: True/False Indicate whether the sentence or statement is true or false.

CSCI-401 Examlet #5. Name: Class: Date: True/False Indicate whether the sentence or statement is true or false. Name: Class: Date: CSCI-401 Examlet #5 True/False Indicate whether the sentence or statement is true or false. 1. The root node of the standard binary tree can be drawn anywhere in the tree diagram. 2.

More information

CS 171: Introduction to Computer Science II. Binary Search Trees

CS 171: Introduction to Computer Science II. Binary Search Trees CS 171: Introduction to Computer Science II Binary Search Trees Binary Search Trees Symbol table applications BST definitions and terminologies Search and insert Traversal Ordered operations Delete Symbol

More information

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL MINUTIAE Feedback for P1p1 should have gone out before class Grades on canvas tonight Emails went to the student who submitted the assignment If you did not receive

More information

Tree Awareness for Relational DBMS Kernels: Staircase Join

Tree Awareness for Relational DBMS Kernels: Staircase Join Tree Awareness for Relational DBMS Kernels: Stairase Join Torsten Grust 1 and Maurie van Keulen 2 1 Department of Computer and Information Siene, University of Konstanz, P.O. Box D188, 78457 Konstanz,

More information

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Test I Solutions

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Test I Solutions Department of Eletrial Engineering and Computer iene MAACHUETT INTITUTE OF TECHNOLOGY 6.035 Fall 2016 Test I olutions 1 I Regular Expressions and Finite-tate Automata For Questions 1, 2, and 3, let the

More information

Multi-way Search Trees

Multi-way Search Trees Multi-way Search Trees Kuan-Yu Chen ( 陳冠宇 ) 2018/10/24 @ TR-212, NTUST Review Red-Black Trees Splay Trees Huffman Trees 2 Multi-way Search Trees. Every node in a binary search tree contains one value and

More information

Part XII. Mapping XML to Databases. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321

Part XII. Mapping XML to Databases. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321 Part XII Mapping XML to Databases Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321 Outline of this part 1 Mapping XML to Databases Introduction 2 Relational Tree Encoding Dead Ends

More information

COMP 181. Prelude. Intermediate representations. Today. Types of IRs. High-level IR. Intermediate representations and code generation

COMP 181. Prelude. Intermediate representations. Today. Types of IRs. High-level IR. Intermediate representations and code generation Prelude COMP 181 Intermediate representations and ode generation November, 009 What is this devie? Large Hadron Collider What is a hadron? Subatomi partile made up of quarks bound by the strong fore What

More information

Binary Trees and Binary Search Trees

Binary Trees and Binary Search Trees Binary Trees and Binary Search Trees Learning Goals After this unit, you should be able to... Determine if a given tree is an instance of a particular type (e.g. binary, and later heap, etc.) Describe

More information

Concurrency in XML. Concurrency control is a method used to ensure that database transactions are executed in a safe manner.

Concurrency in XML. Concurrency control is a method used to ensure that database transactions are executed in a safe manner. Concurrency in XML Concurrency occurs when two or more execution flows are able to run simultaneously. Concurrency control is a method used to ensure that database transactions are executed in a safe manner.

More information

Algorithms and Data Structures (INF1) Lecture 8/15 Hua Lu

Algorithms and Data Structures (INF1) Lecture 8/15 Hua Lu Algorithms and Data Structures (INF1) Lecture 8/15 Hua Lu Department of Computer Science Aalborg University Fall 2007 This Lecture Trees Basics Rooted trees Binary trees Binary tree ADT Tree traversal

More information

Chapter 2: Introduction to Maple V

Chapter 2: Introduction to Maple V Chapter 2: Introdution to Maple V 2-1 Working with Maple Worksheets Try It! (p. 15) Start a Maple session with an empty worksheet. The name of the worksheet should be Untitled (1). Use one of the standard

More information

Trees. Eric McCreath

Trees. Eric McCreath Trees Eric McCreath 2 Overview In this lecture we will explore: general trees, binary trees, binary search trees, and AVL and B-Trees. 3 Trees Trees are recursive data structures. They are useful for:

More information

COMP 103 RECAP/TODAY. Recap: General Tree Examples. Recap: Planning. General Trees. Taxonomies e.g. game genres. Tic Tac Toe search tree for moves

COMP 103 RECAP/TODAY. Recap: General Tree Examples. Recap: Planning. General Trees. Taxonomies e.g. game genres. Tic Tac Toe search tree for moves P 103 2017-2 ecture 21 eneral rees arcus rean, indsay roves, Peter ndreae, and homas uehne, VUW indsay roves Sool of ngineering and omputer Science, Victoria University of Wellington 2 PRVIUSY RP/Y inary

More information

INF2220: algorithms and data structures Series 1

INF2220: algorithms and data structures Series 1 Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees Issued: 24. 08. 2016 Exercise

More information

SELF-BALANCING SEARCH TREES. Chapter 11

SELF-BALANCING SEARCH TREES. Chapter 11 SELF-BALANCING SEARCH TREES Chapter 11 Tree Balance and Rotation Section 11.1 Algorithm for Rotation BTNode root = left right = data = 10 BTNode = left right = data = 20 BTNode NULL = left right = NULL

More information

CSE 326: Data Structures Binary Search Trees

CSE 326: Data Structures Binary Search Trees nnouncements (1/3/0) S 36: ata Structures inary Search Trees Steve Seitz Winter 0 HW # due now HW #3 out today, due at beginning of class next riday. Project due next Wed. night. Read hapter 4 1 Ts Seen

More information

Query Evaluation Overview. Query Optimization: Chap. 15. Evaluation Example. Cost Estimation. Query Blocks. Query Blocks

Query Evaluation Overview. Query Optimization: Chap. 15. Evaluation Example. Cost Estimation. Query Blocks. Query Blocks Query Evaluation Overview Query Optimization: Chap. 15 CS634 Leture 12 SQL query first translated to relational algebra (RA) Atually, some additional operators needed for SQL Tree of RA operators, with

More information

CS 127 Fall In our last episode. Yet more fun with binary trees. Tree traversals. Breadth-first traversal

CS 127 Fall In our last episode. Yet more fun with binary trees. Tree traversals. Breadth-first traversal CS 127 Fall 2003 Yet more fun with binary trees In our last episode We looked at the complexity of searching a binary tree average complexity is O(lg n), in most cases We pondered the question, How many

More information

Postfix (and prefix) notation

Postfix (and prefix) notation Postfix (and prefix) notation Also called reverse Polish reversed form of notation devised by mathematician named Jan Łukasiewicz (so really lü-kä-sha-vech notation) Infix notation is: operand operator

More information

Trees and Tree Traversals. Binary Trees. COMP 210: Object-Oriented Programming Lecture Notes 8. Based on notes by Logan Mayfield

Trees and Tree Traversals. Binary Trees. COMP 210: Object-Oriented Programming Lecture Notes 8. Based on notes by Logan Mayfield OMP 210: Object-Oriented Programming Lecture Notes 8 Trees and Tree Traversals ased on notes by Logan Mayfield In these notes we look at inary Trees and how to traverse them. inary Trees Imagine a list.

More information

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs Algorithms in Systems Engineering ISE 172 Lecture 16 Dr. Ted Ralphs ISE 172 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms

More information

CS24 Week 8 Lecture 1

CS24 Week 8 Lecture 1 CS24 Week 8 Lecture 1 Kyle Dewey Overview Tree terminology Tree traversals Implementation (if time) Terminology Node The most basic component of a tree - the squares Edge The connections between nodes

More information

Red-Black Trees 10/19/2009. Red-Black Trees. Example. Red-Black Properties. Black Height. Example

Red-Black Trees 10/19/2009. Red-Black Trees. Example. Red-Black Properties. Black Height. Example lgorithms Red-lak Trees 13-2 Red-lak Trees Red-lak Trees ll binar searh tree operations take O(h) time, here h is the height of the tree Therefore, it is important to `balane the tree so that its height

More information

Optimizing Correlated Path Queries in XML Languages. Technical Report CS November 2002

Optimizing Correlated Path Queries in XML Languages. Technical Report CS November 2002 Optimizing Correlated Path Queries in XML Languages Ning Zhang and M. Tamer Özsu Tehnial Report CS-2002-36 November 2002 Shool Of Computer Siene, University of Waterloo, {nzhang,tozsu}@uwaterloo.a 1 Abstrat

More information

Trees. Trees. CSE 2011 Winter 2007

Trees. Trees. CSE 2011 Winter 2007 Trees CSE 2011 Winter 2007 2/5/2007 10:00 PM 1 Trees Linear access time of linked lists is prohibitive Does there exist any simple data structure for which the running time of most operations (search,

More information

Lecture 14. Recursion

Lecture 14. Recursion Leture 14 Reursion Announements for Today Prelim 1 Tonight at 5:15 OR 7:30 A D (5:15, Uris G01) E-K (5:15, Statler) L P (7:30, Uris G01) Q-Z (7:30, Statler) Graded y noon on Sun Sores will e in CMS In

More information

COMP4317: XML & Database Tutorial 10: Xpath & SQL

COMP4317: XML & Database Tutorial 10: Xpath & SQL COMP4317: XML & Database Tutorial 10: Xpath & SQL Week 11 Thang Bui @ CSE.UNSW XML to Database Create tables CREATE TABLE filename_tbl ( pre INTEGER PRIMARY KEY, post INTEGER, level INTEGER, tag VARCHAR(256),

More information

Physical Level of Databases: B+-Trees

Physical Level of Databases: B+-Trees Physical Level of Databases: B+-Trees Adnan YAZICI Computer Engineering Department METU (Fall 2005) 1 B + -Tree Index Files l Disadvantage of indexed-sequential files: performance degrades as file grows,

More information

Back To LinkedLists 1. 3 public Node left; 4 public Node right; 6 public Node(int data, Node left, Node right) {

Back To LinkedLists 1. 3 public Node left; 4 public Node right; 6 public Node(int data, Node left, Node right) { Adam Blank Leture Autumn 0 CSE 3X Aelerated Computer Programming I/II CSE 3X: Aelerated Computer Programming I/II Binary Trees 0 00 00 00 00 0 000 00 00 0 00 0 000 000 000 0 0 00 0000 00 000 00 00 0 000

More information

HEXA: Compact Data Structures for Faster Packet Processing

HEXA: Compact Data Structures for Faster Packet Processing Washington University in St. Louis Washington University Open Sholarship All Computer Siene and Engineering Researh Computer Siene and Engineering Report Number: 27-26 27 HEXA: Compat Data Strutures for

More information

CS61B Lecture #20. Today: Trees. Readings for Today: Data Structures, Chapter 5. Readings for Next Topic: Data Structures, Chapter 6

CS61B Lecture #20. Today: Trees. Readings for Today: Data Structures, Chapter 5. Readings for Next Topic: Data Structures, Chapter 6 CS61B Lecture #20 Today: Trees Readings for Today: Data Structures, Chapter 5 Readings for Next Topic: Data Structures, Chapter 6 Last modified: Wed Oct 14 03:20:09 2015 CS61B: Lecture #20 1 A Recursive

More information

Trees. Tree Structure Binary Tree Tree Traversals

Trees. Tree Structure Binary Tree Tree Traversals Trees Tree Structure Binary Tree Tree Traversals The Tree Structure Consists of nodes and edges that organize data in a hierarchical fashion. nodes store the data elements. edges connect the nodes. The

More information

Advanced Tree Data Structures

Advanced Tree Data Structures Advanced Tree Data Structures Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park Binary trees Traversal order Balance Rotation Multi-way trees Search Insert Overview

More information

Chapter 13 XML: Extensible Markup Language

Chapter 13 XML: Extensible Markup Language Chapter 13 XML: Extensible Markup Language - Internet applications provide Web interfaces to databases (data sources) - Three-tier architecture Client V Application Programs Webserver V Database Server

More information

ECE 250 Data Structures and Algorithms MID-TERM EXAMINATION /08:30-9:50 RCH 105, RCH 110

ECE 250 Data Structures and Algorithms MID-TERM EXAMINATION /08:30-9:50 RCH 105, RCH 110 ECE 250 Data Structures and Algorithms MID-TERM EXAMINATION 2009-10-29/08:30-9:50 RCH 105, RCH 110 Instructions: There are 70 marks and the examination will be marked out of 65. No aides. Turn off all

More information

Chapter 20: Binary Trees

Chapter 20: Binary Trees Chapter 20: Binary Trees 20.1 Definition and Application of Binary Trees Definition and Application of Binary Trees Binary tree: a nonlinear linked list in which each node may point to 0, 1, or two other

More information

Todays Lecture. Assignment 2 deadline: You have 5 Calendar days to complete.

Todays Lecture. Assignment 2 deadline: You have 5 Calendar days to complete. Trees! Todays Lecture Assignment 2 deadline: 11 pm Monday 2/17 President s day. You have 5 Calendar days to complete. Trees What are trees in computer science? Data Structures for Trees Algorithms useful

More information

Extracting Partition Statistics from Semistructured Data

Extracting Partition Statistics from Semistructured Data Extrating Partition Statistis from Semistrutured Data John N. Wilson Rihard Gourlay Robert Japp Mathias Neumüller Department of Computer and Information Sienes University of Strathlyde, Glasgow, UK {jnw,rsg,rpj,mathias}@is.strath.a.uk

More information

Binary Trees. Recursive definition. Is this a binary tree?

Binary Trees. Recursive definition. Is this a binary tree? Binary Search Trees Binary Trees Recursive definition 1. An empty tree is a binary tree 2. A node with two child subtrees is a binary tree 3. Only what you get from 1 by a finite number of applications

More information

Folding. Hardware Mapped vs. Time multiplexed. Folding by N (N=folding factor) Node A. Unfolding by J A 1 A J-1. Time multiplexed/microcoded

Folding. Hardware Mapped vs. Time multiplexed. Folding by N (N=folding factor) Node A. Unfolding by J A 1 A J-1. Time multiplexed/microcoded Folding is verse of Unfolding Node A A Folding by N (N=folding fator) Folding A Unfolding by J A A J- Hardware Mapped vs. Time multiplexed l Hardware Mapped vs. Time multiplexed/mirooded FI : y x(n) h

More information

F453 Module 7: Programming Techniques. 7.2: Methods for defining syntax

F453 Module 7: Programming Techniques. 7.2: Methods for defining syntax 7.2: Methods for defining syntax 2 What this module is about In this module we discuss: explain how functions, procedures and their related variables may be used to develop a program in a structured way,

More information

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology Trees : Part Section. () (2) Preorder, Postorder and Levelorder Traversals Definition: A tree is a connected graph with no cycles Consequences: Between any two vertices, there is exactly one unique path

More information

12 Abstract Data Types

12 Abstract Data Types 12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define

More information

CS350: Data Structures B-Trees

CS350: Data Structures B-Trees B-Trees James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Introduction All of the data structures that we ve looked at thus far have been memory-based

More information

THE B+ TREE INDEX. CS 564- Spring ACKs: Jignesh Patel, AnHai Doan

THE B+ TREE INDEX. CS 564- Spring ACKs: Jignesh Patel, AnHai Doan THE B+ TREE INDEX CS 564- Spring 2018 ACKs: Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? The B+ tree index Basics Search/Insertion/Deletion Design & Cost 2 INDEX RECAP We have the following query:

More information

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs Computational Optimization ISE 407 Lecture 16 Dr. Ted Ralphs ISE 407 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms in

More information

CPSC 223 Algorithms & Data Abstract Structures

CPSC 223 Algorithms & Data Abstract Structures PS 223 lgorithms & Data bstract Structures Lecture 18: VL Trees (cont.) Today In-place mergesort Midterm overview VL Trees (cont.) [h 12: pp. 681-686] Heapsort exercise 1 Midterm Overview Midterm There

More information

Garbage Collection. Lecture Compilers SS Dr.-Ing. Ina Schaefer. Software Technology Group TU Kaiserslautern. Ina Schaefer Garbage Collection 1

Garbage Collection. Lecture Compilers SS Dr.-Ing. Ina Schaefer. Software Technology Group TU Kaiserslautern. Ina Schaefer Garbage Collection 1 Garbage Collection Lecture Compilers SS 2009 Dr.-Ing. Ina Schaefer Software Technology Group TU Kaiserslautern Ina Schaefer Garbage Collection 1 Content of Lecture 1. Introduction: Overview and Motivation

More information

Binary Search Trees. Analysis of Algorithms

Binary Search Trees. Analysis of Algorithms Binary Search Trees Analysis of Algorithms Binary Search Trees A BST is a binary tree in symmetric order 31 Each node has a key and every node s key is: 19 23 25 35 38 40 larger than all keys in its left

More information

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS DATA STRUCTURES AND ALGORITHMS UNIT 1 - LINEAR DATASTRUCTURES 1. Write down the definition of data structures? A data structure is a mathematical or logical way of organizing data in the memory that consider

More information

LECTURE 11 TREE TRAVERSALS

LECTURE 11 TREE TRAVERSALS DATA STRUCTURES AND ALGORITHMS LECTURE 11 TREE TRAVERSALS IMRAN IHSAN ASSISTANT PROFESSOR AIR UNIVERSITY, ISLAMABAD BACKGROUND All the objects stored in an array or linked list can be accessed sequentially

More information

Frequently asked Data Structures Interview Questions

Frequently asked Data Structures Interview Questions Frequently asked Data Structures Interview Questions Queues Data Structure Interview Questions How is queue different from a stack? The difference between stacks and queues is in removing. In a stack we

More information

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: This exam is CLOSED book and notes. Instructions The exam consists of six questions on 11 pages. Please answer all questions on

More information

Computational Biology 6.095/6.895 Database Search Lecture 5 Prof. Piotr Indyk

Computational Biology 6.095/6.895 Database Search Lecture 5 Prof. Piotr Indyk Computational Biology 6.095/6.895 Database Searh Leture 5 Prof. Piotr Indyk Previous letures Leture -3: Global alignment in O(mn) Dynami programming Leture -2: Loal alignment, variants, in O(mn) Leture

More information

XML Tree Structure Compression

XML Tree Structure Compression XML Tree Structure Compression Sebastian Maneth NICTA & University of NSW Joint work with N. Mihaylov and S. Sakr Melbourne, Nov. 13 th, 2008 Outline -- XML Tree Structure Compression 1. Motivation 2.

More information

Trees. Carlos Moreno uwaterloo.ca EIT https://ece.uwaterloo.ca/~cmoreno/ece250

Trees. Carlos Moreno uwaterloo.ca EIT https://ece.uwaterloo.ca/~cmoreno/ece250 Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 https://ece.uwaterloo.ca/~cmoreno/ece250 Today's class: We'll discuss one possible implementation for trees (the general type of trees) We'll look at tree

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms Trees Sidra Malik sidra.malik@ciitlahore.edu.pk Tree? In computer science, a tree is an abstract model of a hierarchical structure A tree is a finite set of one or more nodes

More information

Binary search trees. Binary search trees are data structures based on binary trees that support operations on dynamic sets.

Binary search trees. Binary search trees are data structures based on binary trees that support operations on dynamic sets. COMP3600/6466 Algorithms 2018 Lecture 12 1 Binary search trees Reading: Cormen et al, Sections 12.1 to 12.3 Binary search trees are data structures based on binary trees that support operations on dynamic

More information

Binary search trees 3. Binary search trees. Binary search trees 2. Reading: Cormen et al, Sections 12.1 to 12.3

Binary search trees 3. Binary search trees. Binary search trees 2. Reading: Cormen et al, Sections 12.1 to 12.3 Binary search trees Reading: Cormen et al, Sections 12.1 to 12.3 Binary search trees 3 Binary search trees are data structures based on binary trees that support operations on dynamic sets. Each element

More information

Upcoming ACM Events Linux Crash Course Date: Time: Location: Weekly Crack the Coding Interview Date:

Upcoming ACM Events Linux Crash Course Date: Time: Location: Weekly Crack the Coding Interview Date: Upcoming ACM Events Linux Crash Course Date: Oct. 2nd and 3rd Time: 1:15 pm - 3:15 pm Location: UW1-210 (10/02) and UW1-221 (10/03) Weekly Crack the Coding Interview Date: Weekly Fridays from Oct. 5th

More information

Divide-and-conquer algorithms 1

Divide-and-conquer algorithms 1 * 1 Multipliation Divide-and-onquer algorithms 1 The mathematiian Gauss one notied that although the produt of two omplex numbers seems to! involve four real-number multipliations it an in fat be done

More information

Section Summary. Introduction to Trees Rooted Trees Trees as Models Properties of Trees

Section Summary. Introduction to Trees Rooted Trees Trees as Models Properties of Trees Chapter 11 Copyright McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education. Chapter Summary Introduction to Trees Applications

More information

Trees. Truong Tuan Anh CSE-HCMUT

Trees. Truong Tuan Anh CSE-HCMUT Trees Truong Tuan Anh CSE-HCMUT Outline Basic concepts Trees Trees A tree consists of a finite set of elements, called nodes, and a finite set of directed lines, called branches, that connect the nodes

More information

Binary Trees, Binary Search Trees

Binary Trees, Binary Search Trees Binary Trees, Binary Search Trees Trees Linear access time of linked lists is prohibitive Does there exist any simple data structure for which the running time of most operations (search, insert, delete)

More information

CSIT5300: Advanced Database Systems

CSIT5300: Advanced Database Systems CSIT5300: Advanced Database Systems L08: B + -trees and Dynamic Hashing Dr. Kenneth LEUNG Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong SAR,

More information

What is a Multi-way tree?

What is a Multi-way tree? B-Tree Motivation for studying Multi-way and B-trees A disk access is very expensive compared to a typical computer instruction (mechanical limitations) -One disk access is worth about 200,000 instructions.

More information

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap DATA STRUCTURES AND ALGORITHMS Hierarchical data structures: AVL tree, Bayer tree, Heap Summary of the previous lecture TREE is hierarchical (non linear) data structure Binary trees Definitions Full tree,

More information

Objectives. In this session, you will learn to:

Objectives. In this session, you will learn to: TRS Objectives n this session, you will learn to: Store data in a tree istinguish types of inary tree Traverse a inary Tree norder PreOrder PostOrder onstruct a inary Tree onstruct an expression inary

More information

TREES. Trees - Introduction

TREES. Trees - Introduction TREES Chapter 6 Trees - Introduction All previous data organizations we've studied are linear each element can have only one predecessor and successor Accessing all elements in a linear sequence is O(n)

More information

XML and Databases. Lecture 9 Properties of XPath. Sebastian Maneth NICTA and UNSW

XML and Databases. Lecture 9 Properties of XPath. Sebastian Maneth NICTA and UNSW XML and Databases Lecture 9 Properties of XPath Sebastian Maneth NICTA and UNSW CSE@UNSW -- Semester 1, 2009 Outline 1. XPath Equivalence 2. No Looking Back: How to Remove Backward Axes 3. Containment

More information

Here is a recursive algorithm that solves this problem, given a pointer to the root of T : MaxWtSubtree [r]

Here is a recursive algorithm that solves this problem, given a pointer to the root of T : MaxWtSubtree [r] CSE 101 Final Exam Topics: Order, Recurrence Relations, Analyzing Programs, Divide-and-Conquer, Back-tracking, Dynamic Programming, Greedy Algorithms and Correctness Proofs, Data Structures (Heap, Binary

More information

Learning Convention Propagation in BeerAdvocate Reviews from a etwork Perspective. Abstract

Learning Convention Propagation in BeerAdvocate Reviews from a etwork Perspective. Abstract CS 9 Projet Final Report: Learning Convention Propagation in BeerAdvoate Reviews from a etwork Perspetive Abstrat We look at the way onventions propagate between reviews on the BeerAdvoate dataset, and

More information

Binary Search Tree (2A) Young Won Lim 5/17/18

Binary Search Tree (2A) Young Won Lim 5/17/18 Binary Search Tree (2A) Copyright (c) 2015-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

Trees. A tree is a directed graph with the property

Trees. A tree is a directed graph with the property 2: Trees Trees A tree is a directed graph with the property There is one node (the root) from which all other nodes can be reached by exactly one path. Seen lots of examples. Parse Trees Decision Trees

More information

Outline. CS38 Introduction to Algorithms. Administrative Stuff. Administrative Stuff. Motivation/Overview. Administrative Stuff

Outline. CS38 Introduction to Algorithms. Administrative Stuff. Administrative Stuff. Motivation/Overview. Administrative Stuff Outline CS38 Introdution to Algorithms Leture 1 April 1, 2014 administrative stuff motivation and overview of the ourse stale mathings example graphs, representing graphs graph traversals (BFS, DFS) onnetivity,

More information