|
What is a tree? | ||
|
What is the relationship between parent node and child nodes? | ||
|
What are a key and a value? | ||
|
What is a root node? | ||
|
What is the purpose of a left child node and a right child node? | ||
|
What is a leaf node? | ||
|
What is the depth of a tree? | ||
|
What is the size of a tree? | ||
|
How do you calculate the size of a tree? | ||
|
Can a tree have a duplicate key? |
Answers
|
A tree is a data structure where data is stored in nodes. Nodes are arranged in branches where each node can expand into 0, 1, or 2 other nodes. |
|
|
A parent node is a node that branches into one or two other nodes, which are called child nodes. |
|
|
A key is a component of a node that identifies the node. An application searches keys to locate a desired node. A value is also a component of a node that is used to store data. |
|
|
A root node is another term for a parent node. |
|
|
The left child node has a key that is less than the key of its parent node. The right child node has a key that is greater than the key of its parent node. |
|
|
A leaf node is the last node on a branch and does not have any child nodes. |
|
|
The depth of a tree is the number of levels of a tree. |
|
|
The size of a tree is the number of nodes on the tree. |
|
|
You calculate the size of a tree by using the following formula:
If the depth is 5 levels, then the size is 32, as shown here:
|
|
|
No, a tree cannot have a duplicate key. |