# Tree Flashcards

All other Data Structures covered so far store their data linearly (even the Map under the hood). How does a Tree/Graph store its data?

Hierarchically.

What is a real-world example of a Hierarchical structure?

A Family Tree.

Each person would be an Element of the family tree and connections aren’t based on a simple linear fashion rather connections are more abstract and can lead to multiple paths or branches. Each generation is ordered on a HIERARCHY. There is no definitive end to a family tree. There may be several children at the bottom but which one of them is the definitive end? None.

A File Structure on a computer.

A folder which contains multiple files and folders which in turn can contain more folders and files.

Tree definition?

An abstract Data Structure which contains a series of linked nodes connected together to form a hierarchical representation of information.

The data for each element is stored in a Node along with its connections to other Nodes. This is similar to which data structure?

Linked List.

In a Tree structure what is another name for a Nodes?

Vertices

In a Tree structure, what are the connections between Node/Vertices called?

Edges

What is the name of the top-most Node of a Tree?

Root Node.

What is the definition of Child Vertices?

A node which has an Edge connecting it to another Node that is one level above itself.

What is a Parent Node?

Any node which has one or more child vertices.

What is a Leaf Node?

A node which does not have any child vertices.

Can a node be categorised as multiple different node types?

Yes. E.g. A Child Node and a Leaf Node.

Is the HEIGHT a property of a Tree or a Node?

Height is a property of a Tree

Is the DEPTH a property of a Tree or a Node?

Depth is a property of a Node

Tree HEIGHT definition?

Number of edges on the longest possible path down towards a leaf. i.e. How many hierarchies in the tree, not including the Parent Node.

Node Depth definition?

Number of edges required to get from that particular node to the root node. Think, depth under water, how far it has to go to get to the surface.