ch5-tree-01 - Trees CAU data structure 2011 Spring 1 Nature...

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

View Full Document Right Arrow Icon
Trees 1 CAU data structure 2011 Spring
Image of page 1

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

View Full Document Right Arrow Icon
Nature Lover’s View Of A Tree root branches leaves 2 CAU data structure 2011 Spring
Image of page 2
Computer Scientist’s View branches leaves root nodes 3 CAU data structure 2011 Spring
Image of page 3

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

View Full Document Right Arrow Icon
Linear Lists And Trees Linear lists are useful for serially ordered data. (e 0 , e 1 , e 2 , …, e n-1 ) Days of week. Months in a year. Students in this class. Trees are useful for hierarchically ordered data. Employees of a corporation. President, vice presidents, managers, and so on. 4 CAU data structure 2011 Spring
Image of page 4
Hierarchical Data And Trees The element at the top of the hierarchy is the root . Elements next in the hierarchy are the children of the root. Elements next in the hierarchy are the grandchildren of the root, and so on. Elements that have no children are leaves . 5 CAU data structure 2011 Spring
Image of page 5

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

View Full Document Right Arrow Icon
great grand child of root grand children of root children of root Example Tree President VP1 VP2 VP3 Manager1 Manager2 Manager Manager Worker Bee root 6 CAU data structure 2011 Spring
Image of page 6
Definition A tree t is a finite nonempty set of elements. One of these elements is called the root. The remaining elements, if any, are partitioned into trees, which are called the subtrees of t . 7 CAU data structure 2011 Spring
Image of page 7

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

View Full Document Right Arrow Icon
Subtrees President VP1 VP2 VP3 Manager1 Manager2 Manager Manager Worker Bee root 8 CAU data structure 2011 Spring
Image of page 8
Leaves President VP1 VP2 VP3 Manager1 Manager2 Manager Manager Worker Bee 9 CAU data structure 2011 Spring
Image of page 9

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

View Full Document Right Arrow Icon
Parent, Grandparent, Siblings, Ancestors, Descendants President VP1 VP2 VP3 Manager2 Manager Manager Worker Bee Manager1 10 CAU data structure 2011 Spring
Image of page 10
Level 4 Level 3 Level 2 Levels President VP1 VP2 VP3 Manager1 Manager2 Manager Manager Worker Bee Level 1 11 CAU data structure 2011 Spring
Image of page 11

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

View Full Document Right Arrow Icon
Caution Some texts start level numbers at 0 rather than at 1 .
Image of page 12
Image of page 13
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