chapter8 - .

Info icon This preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
TREES Chapter 8
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how to use recursion to process trees To understand the different ways of traversing a tree To understand the differences between binary trees, binary search trees, and heaps To learn how to implement binary trees, binary search trees, and heaps using
Image of page 2
Chapter Objectives (cont.) To learn how to use a binary search tree to store information so that it can be retrieved in an efficient manner To learn how to use a Huffman tree to encode characters using fewer bits than ASCII or Unicode, resulting in smaller files and reduced storage requirements
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Trees - Introduction All previous data organizations we've studied are linear—each element can have only one predecessor and one successor Accessing all elements in a linear sequence is O( n ) Trees are nonlinear and hierarchical Tree nodes can have multiple successors (but only one predecessor)
Image of page 4
Trees - Introduction (cont.) Trees can represent hierarchical organizations of information: class hierarchy disk directory and subdirectories family tree
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Trees - Introduction (cont.) Trees are recursive data structures because they can be defined recursively Many methods to process trees are written recursively This chapter focuses on the binary tree In a binary tree each element has two successors Binary trees can be represented by arrays and by linked data structures Searching a binary search tree, generally is more efficient than searching an ordered list—O(log n ) versus O(n)
Image of page 6
Section 8.1 Tree Terminology and Applications
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Tree Terminology dog dog cat cat wolf wolf canin e canin e A tree consists of a collection of elements or nodes, with each node linked to its successors
Image of page 8
Tree Terminology (cont.) dog dog cat cat wolf wolf canin e canin e A tree consists of a collection of elements or nodes, with each node linked to its successors The node at the top of a tree is called its root
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Tree Terminology (cont.) dog dog cat cat wolf wolf canin e canin e A tree consists of a collection of elements or nodes, with each node linked to its successors The links from a node to its successors are called branches
Image of page 10
Tree Terminology (cont.) dog dog cat cat wolf wolf canin e canin e A tree consists of a collection of elements or nodes, with each node linked to its successors The successors of a node are called its children
Image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Tree Terminology (cont.) dog dog cat cat wolf wolf canin e canin e A tree consists of a collection of elements or nodes, with each node linked to its successors The predecessor of a node is called its parent
Image of page 12
Tree Terminology (cont.) dog dog cat cat wolf wolf canin e canin e A tree consists of a collection of elements or nodes, with each node linked to its successors Each node in a tree has exactly one parent except for the root node, which has no parent
Image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Tree Terminology (cont.) dog dog cat cat wolf wolf canin e canin e A tree consists of a collection of elements or nodes, with each node linked to its successors Nodes that have the same parent are siblings
Image of page 14
Tree Terminology (cont.)
Image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern