mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 05:14:06 -06:00
1.4 KiB
1.4 KiB
| title | tags | ||
|---|---|---|---|
| tree |
|
not so much a data type. More of a data concept of a way in which data can be organised
The first example we saw was with the chains of representatives in union-find
The type required for the ordered set data type is the binary tree
Trees in general:
- Consists of Nodes
- One node is distinguished and called the root
- Each node, except the root, has a uniquw parent
- Any chain that moves from a mnode to its parent , its grandparent etc, eventually reaches the root.
- The children of a nore arll the nodes of which it is the parent
- Nodes may (and usually do) have additional data associated to them. (does not affect the structure)
- Nodes with no children are leaves
For example:
- cat is the root (root is drawn at the top)
- the parent of dog is cat*,* of rat is emu
- some nodes have two children, one has three (emu ) and some have none.
The only differnce between these two trees is the order of the elements.
We need to specify whether this makes them different or not. In computer science, order usually does mater. These are sometimes calledplane trees.
Sometimes there are fixed slots for the children e.g.,

