Tree
A Tree is a collection of nodes in a hierarchical tree structure
Last updated
Was this helpful?
A Tree is a collection of nodes in a hierarchical tree structure
Last updated
Was this helpful?
A Tree is a collection of nodes in a hierarchical tree structure. nodes = elements
In a Binary "left or right" Tree, (start with looking at the picture first) the root node connects to a left node and a right node. The left node then connects to a left node and a right node. The right node also connects to a left node and a right node. and etc etc...
If you are a Windows , Mac, or Linux user, think of a File System. A file system is a Tree data structure.
Using """No Code Computer Science""" folder as an example:
Turn on PC, while viewing the desktop
3 more folders appear:
"No Code Computer Science", "Data Structure", "Algorithms"
6 files appear:
"Primitive", "Array", "Dictionary (Hash Map) (Hash Table)", "Linked List", "Tree", "Graph (network)"
The text for the file "Tree" is shown
You Win!
https://github.com/KyleMcClay/no-code-computer-science
Trees are great for searching, every level deeper in the tree results in cutting the possible nodes in half (finds the answer fast).
1000 nodes -> 500 nodes -> 250 nodes -> 125 nodes -> 60 nodes -> 30 nodes -> 16 nodes -> 8 nodes -> 4 nodes -> 2 nodes -> 1 node
A Tree is useful when the data is evenly distributed throughout the tree for quick search. If a tree stored all data only on the right side, then you would have a linked list data structure and not a tree data structure.
Click on the folder "No Code Computer Science"
Click on the folder "Data Structure"
Click on the file "Tree"
View the file structure on Github, not for the faint of hear