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.
Regular trees are great for storing hierarchical data, but their power can be really heightened when you start messing around with HOW the data is actually stored within them. What are the two R’s for HOW data can be stored in a Tree?
Rules and Restrictions
What is a Binary Search Tree?
A tree where theres is natural ordered to how the data is stored which allows us to search through them in Logarithmic Time. O(log n)
What are the three restrictions of a Binary Search Tree?
- Each vertice can have at most two children.
- For any given parent node, the child to the left has a value less than itself, and the child to the right has a value greater than itself.
- No two nodes can contain the same value.
When are Binary Search Trees most useful?
When storing large quantities of data that need to be quickly searched.
When are Binary Search Trees most useful?
When storing large quantities of data that need to be quickly searched.
A Tree’s base structure is incredibly useful and it can be modified in so many ways to add to its functionality which leads to many different … for varying use cases.
implementations (hundreds)
A Trie is an implementation of a Tree. What is a Trie’s definition.
A Trie is a tree-like data structure whose nodes store letters of an alphabet in the form of characters.
What are two other names for a Trie?
- Digital Trees
- Prefix Trees
A Trie is an implementation of a Tree. What is a Trie’s definition.
A Trie is a tree-like data structure whose nodes store letters of an alphabet in the form of characters.
Root | | d h | | | | de do ha he | hen