Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 112 - Fall 2012, Lab 08 Haohan Zhu. Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 2 4/17/2015 Tree - Data Structure  Basic.

Similar presentations


Presentation on theme: "CS 112 - Fall 2012, Lab 08 Haohan Zhu. Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 2 4/17/2015 Tree - Data Structure  Basic."— Presentation transcript:

1 CS 112 - Fall 2012, Lab 08 Haohan Zhu

2 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 2 4/17/2015 Tree - Data Structure  Basic Concept:  Root  Leaf  Parent (Ancestor)  Child  Siblings  Height / Depth

3 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 3 4/17/2015 Several Trees  Binary Tree  Binary Search Tree  Binary Expression Tree  B-tree  Huffman Tree (Information Theory)  Red-black Tree  BSP tree, R-tree, k-d tree(Space Partition)  …

4 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 4 4/17/2015 Tree Traversal  Depth-first traversal  preorder  inorder  postorder  Breadth-first traversal  level-order

5 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 5 4/17/2015 Tree Traversal  Preorder preorder(node) if node == null then return visit(node) preorder(node.children)

6 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 6 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

7 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 7 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

8 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 8 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

9 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 9 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

10 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 10 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

11 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 11 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

12 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 12 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

13 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 13 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

14 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 14 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

15 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 15 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

16 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 16 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Preorder

17 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 17 4/17/2015 Tree Traversal  Postorder postorder(node) if node == null then return postorder(node.children) visit(node)

18 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 18 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

19 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 19 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

20 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 20 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

21 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 21 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

22 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 22 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

23 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 23 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

24 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 24 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

25 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 25 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

26 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 26 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

27 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 27 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

28 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 28 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Postorder

29 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 29 4/17/2015 Tree Traversal  Inorder inorder(node) if node == null then return inorder(node.first_child or node.left) visit(node) inorder(node.other_children or node.right)

30 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 30 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

31 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 31 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

32 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 32 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

33 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 33 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

34 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 34 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

35 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 35 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

36 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 36 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

37 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 37 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

38 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 38 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

39 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 39 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

40 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 40 4/17/2015 Tree Traversal R ABC a1a2a3b1b2 Inorder

41 Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 41 4/17/2015 Practice  Write Inorder traversing algorithm


Download ppt "CS 112 - Fall 2012, Lab 08 Haohan Zhu. Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 08 2 4/17/2015 Tree - Data Structure  Basic."

Similar presentations


Ads by Google