4.2.5 Trees Flashcards
(11 cards)
Define Trees.
A data structure that uses a set of linked nodes to form a hierarchical structure starting at a root node.
Each node is a child/sub-node of a parent node.
What describes a tree?
- a connected, undirected graph with no cycles.
- only one possible path between any two nodes
What does connected mean in terms of trees?
It means that there is a path from any node, and there is no node, or set of nodes that is disconnected from the others.
What is a cycle in terms of trees?
A cycle is where a number of vertices (at least 3) are connected in a closed chain.
What is the root node?
The only node in a rooted tree without a parent node.
If the tree has a root, it is a rooted tree.
What are the parts of a tree?
Branch - a path from the root to an end point
Leaf node - a node where no branches are branching from that node. Found at the bottom of the tree.
Edges = nodes - 1
What are the parts of a rooted tree?
A tree with one node that has been designated as the root.
The root is the only node with no parent, and all the other nodes are descendants of the root.
What are some examples of rooted trees?
- stores data that has an inherent hierarchical structure
- an OS may use tree for directories, files and folders in its file management system.
What is a Binary Tree?
A rooted tree where every node has at most 2 child nodes.
How is a binary tree ordered?
In ascending order, left subtree have values lower than the root, nodes of the right subtree have values that are higher than the root.
What are uses of binary trees?
- binary search tree
- used in compilers to build syntax trees
- speed up searching
- express algebraic and Boolean expressions