Documente Academic
Documente Profesional
Documente Cultură
Data Structures
& Algorithm Analysis
Rada Mihalcea
http://www.cs.unt.edu/~rada/CSCE3110
Trees Applications
Trees: A Review (again? )
General trees
one parent, N children
Binary tree
ISA General tree
+ max 2 children
Binary search tree
ISA Binary tree
+ left subtree < parent < right subtree
AVL tree
ISA Binary search tree
+ | height left subtree – height right subtree | ≤ 1
Trees: A Review (cont’d)
Multi-way search tree
ISA General tree
+ Each node has K keys and K+1 children
+ All keys in child K < key K < all keys in child K+1
2-4 Tree
ISA Multi-way search tree
+ All nodes have at most 3 keys / 4 children
+ All leaves are at the same level
B-Tree
ISA Multi-way search tree
+ All nodes have at least T keys, at most 2T(+1) keys
+ All leaves are at the same level
Tree Applications
Data Compression
Huffman tree
Automatic Learning
Decision trees
Huffman code
Very often used for text compression
Do you know how gzip or winzip works?
Compression methods
6. Corinne N. 1 1 1 0 1 0 1+
7. Mariyam M. 0 1 0 1 0 0 1+
8. Stephany D. 1 1 1 1 1 1 1+
9. Mary D. 1 1 1 1 1 1 1+
10. Jamie F. 1 1 1 0 0 1 1+
Fields in the Record
A: First name ends in a vowel?
B: Neat handwriting?
C: Middle name listed?
D: Senior?
E: Got extra-extra credit?
F: Google brings up home page?
G: Google brings up reference?
Build a Classification Tree
Internal nodes: features
Leaves: classification
F
0 1
A D
2,3,7 1,4,5,6 10
A
Error: 30% 8,9
Different Search Problem
Given a set of data records with their
classifications, pick a decision tree: search
problem!
Challenges:
Scoring function?
Large space of trees.
C middle name?
0 1
0 E EEC?
1
Google? F B Neat?
0 0
1 1
New1. Mike M. 1 0 1 1 0 0 1 ?
New2. Jerry K. 0 1 0 1 0 0 0 ?
The very last tree for
this class