4.2.5 - FoDS (Tree) Flashcards
(12 cards)
What is a tree
A connected, undirected graph with no cycles
True or False:
A tree must have a root
False
What is a cycle
A sequence of vertices and edges that can start and end on the same vertex
What are 2 examples of trees
- Rooted trees
- Binary trees
- Binary search trees
What is a rooted tree
A tree in which one vertex has been designated as a root, creating parent-child relationships between nodes
What is a binary tree
A rooted tree in which each node has at most 2 children
What is a common application of a binary tree
A binary search tree
What is a root
A node with no parents
What is a leaf
A node with no children
What is a branch
An edge connecting nodes
Explain the structure of binary trees
- Each node has a left and right pointer and data
- A left/right pointer is a reference to the location of the left/right child
- A pointer with no value means there is no child in either the left or the right direction
What is the advantage of binary trees
Efficient sorting, searching and retrieval of data