Tree Data Structure: Definition, Components, and Terminology, Summaries of Data Structures and Algorithms

An introduction to the tree data structure, covering its definition, components, and related terminology. The tree data structure is a rooted tree that stores information in nodes, with each node having zero or more children. Nodes are classified as internal or leaf, ordered or unordered, and the concepts of parents, children, siblings, paths, depth, height, ancestors, descendants, and subtrees are discussed. The document also includes examples using XHTML and CSS.

Typology: Summaries

2020/2021

Uploaded on 12/22/2021

mrjy
mrjy 🇮🇷

1 document

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The Tree Data StructureThe Tree Data Structure
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Tree Data Structure: Definition, Components, and Terminology and more Summaries Data Structures and Algorithms in PDF only on Docsity!

The Tree Data StructureThe Tree Data Structure

2

Outline

In this topic, we will cover:

  • Definition of a tree data structure and its components
  • Concepts of:
    • Root, internal, and leaf nodes
    • Parents, children, and siblings
    • Paths, path length, height, and depth
    • Ancestors and descendants
    • Ordered and unordered trees
    • Subtrees
  • Examples
    • XHTML and CSS

4

Terminology

All nodes will have zero or more child nodes or children

  • I has three children: J, K and L For all nodes other than the root node, there is one parent node
  • H is the parent I 4.1.1.

5

Terminology

The degree of a node is defined as the number of its children: deg(I) = 3 Nodes with the same parent are siblings

  • J, K, and L are siblings 4.1.1.

7

Terminology

Leaf nodes: 4.1.1.

8

Terminology

Internal nodes: 4.1.1.

10

Terminology

The shape of a rooted tree gives a natural flow from the root node, or just root 4.1.1.

11

Terminology

A path is a sequence of nodes (a 0 , a 1 , ..., an) where ak + 1 is a child of ak is The length of this path is n E.g., the path (B, E, G) has length 2 4.1.1.

13

Terminology

For each node in a tree, there exists a unique path from the root node to that node The length of this path is the depth of the node, e.g.,

  • E has depth 2
  • L has depth 3 4.1.1.

14

Terminology

Nodes of depth up to 17 9 14 17

4.1.1.

16

Terminology

The height of this tree is 17 17 4.1.1.

17

Terminology

If a path exists from node a to node b:

  • a is an ancestor of b
  • b is a descendent of a Thus, a node is both an ancestor and a descendant of itself
  • We can add the adjective strict to exclude equality: a is a strict descendent of b if a is a descendant of b but a ≠ b The root node is an ancestor of all nodes 4.1.1.

19

Terminology

All descendants (including itself) of the indicated node 4.1.1.

20

Terminology

All ancestors (including itself) of the indicated node 4.1.1.