1 / 10

Trees and Traversals: Understanding Data Structures and Operations

Learn about trees and their terminology, and explore basic traversal techniques on trees. Discover various ways to implement a priority queue using a linked list. Record the order of operations for each ADT function.

paolaa
Download Presentation

Trees and Traversals: Understanding Data Structures and Operations

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. CISC220Fall 2009James Atlas Lecture 12: Trees

  2. Objectives for Today • Understand Trees/Terminology • Use basic traversals on trees • Reading - K+W Chap 8

  3. Brainstorm • Come up with several ways to use our LinkedList to implement a Priority Queue • Record the order of operations for each ADT function • front() • dequeue() • queue(x, int)

  4. Trees • Nonlinear data structure

  5. Tree Terminology • root, leaf • parent, child, sibling • subtree • external, internal node • ancestor, descendant • depth, height

  6. Binary Trees • Each node has 0, 1, or 2 children

  7. Binary Tree Application: Huffman Tree

  8. Tree Traversal • process of visiting each node • 4 different standard traversals: • preorder • inorder • postorder • level-order (also called breadth-first) • Interactive example: • http://nova.umuc.edu/~jarc/idsv/lesson1.html

  9. Traversal Exercise Find the: • preorder • inorder • postorder • level-order

  10. Exercise Answers • Preorder traversal sequence: F, B, A, D, C, E, G, I, H (root, left, right) • Inorder traversal sequence: A, B, C, D, E, F, G, H, I (left, root, right) • Postorder traversal sequence: A, C, E, D, B, H, I, G, F (left, right, root) • Level-order traversal sequence: F, B, G, A, D, I, C, E, H

More Related