1 / 10

Rooted Trees

Rooted Trees. More definitions. root. internal vertex. descendants of g. ancestor of d. leaf. parent of d. child of c. subtree. sibling of d.

tamera
Télécharger la présentation

Rooted Trees

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. Rooted Trees

  2. More definitions root internal vertex descendants of g ancestor of d leaf parent of d child of c subtree sibling of d

  3. Definition 2. A rooted tree is called an m-ary tree if every internal vertex has no more than m children. The tree is called a full m-ary tree if every internal vertex has exactly m children. An m-ary tree with m = 2 is called a binary tree. Are these full m-ary trees?

  4. Trees as models

  5. Properties of trees Theorem 2. A tree with n vertices has n - 1 edges • Choose root, r. • Set up one-to-one correspondence between edges and vertices other than r. • There are n – 1 vertices so there are n – 1 edges.

  6. Theorem 3. A full m-ary tree with i internal vertices contains n = mi + 1 vertices • Every vertex (except root) is the child of an internal vertex. • Each of the i internal vertices has m children. • There are mi vertices (other than the root). • Therefore n = mi + 1. i = 4 internal vertices m = 3 n = 3 × 4 + 1 = 13

  7. Theorem 4.A full m-ary tree with • n vertices has i = (n – 1)/m internal vertices and l = [(m – 1)n + 1]/m leaves • i internal vertices has n = mi + 1 vertices and l = (m – 1)i + 1 leaves • l leaves has n = (ml – 1)/(m – 1) vertices and i = (l – 1)/(m – 1) internal vertices

  8. Theorem 5. There are at most mh leaves in an m-ary tree of height h.

  9. Corollary 1. If an m-ary tree of height h has l leaves, then h logml. If the m-ary tree is full and balanced, then h = logml.

  10. Binary Search Trees

More Related