Professional Documents
Culture Documents
Dodon Yendri
Mohammad Hafiz Hersyah
Douglas
Douglas Wilhelm
Wilhelm Harder,
Department
Department of
University
University of
Harder, M.Math.
M.Math. LEL
of Electrical
Electrical and
of Waterloo
Waterloo
LEL
and Computer
Computer Engineering
Engineering
Waterloo,
Waterloo, Ontario,
Ontario, Canada
Canada
ece.uwaterloo.ca
ece.uwaterloo.ca
dwharder@alumni.uwaterloo.ca
dwharder@alumni.uwaterloo.ca
©
© 2006-2013
2006-2013 by
by Douglas
Douglas Wilhelm
Wilhelm Harder.
Harder. Some
Some rights
rights reserved.
reserved.
Abstract trees
2
Outline
An abstract tree (or abstract hierarchy) does not restrict the number
of nodes
– In this tree, the degrees vary:
Degree Nodes
0 D, F, G, J, K, L, M
1 C
2 A, B, E, H
3 I
Abstract trees
5
4.2.2 Abstract Trees: Design
parent()->children.erase( this );
parent_node = nullptr;
}
Abstract trees
13
4.2.2.3 Implementation
tree->parent_node = this;
children.push_back( tree );
}
Abstract trees
14
4.2.2.4 Implementation
int tree_size = 1;
return tree_size ;
}
Abstract trees
15
4.2.2.4 Implementation
#include <algorithm>
int tree_height = 0;
return tree_height;
}
Abstract trees
16
4.2.3 Implementation
Summary
References
[1] Donald E. Knuth, The Art of Computer Programming, Volume 1: Fundamental Algorithms, 3rd
Ed., Addison Wesley, 1997, §2.2.1, p.238.