<s>
The	O
Euler	B-Operating_System
tour	I-Operating_System
technique	I-Operating_System
(	O
ETT	O
)	O
,	O
named	O
after	O
Leonhard	O
Euler	O
,	O
is	O
a	O
method	O
in	O
graph	O
theory	O
for	O
representing	O
trees	O
.	O
</s>
<s>
The	O
ETT	O
allows	O
for	O
efficient	O
,	O
parallel	B-Operating_System
computation	I-Operating_System
of	O
solutions	O
to	O
common	O
problems	O
in	O
algorithmic	O
graph	O
theory	O
.	O
</s>
<s>
All	O
of	O
the	O
following	O
problems	O
can	O
be	O
solved	O
in	O
O( Prefix	O
sum(n )	O
)	O
(	O
the	O
time	O
it	O
takes	O
to	O
solve	O
the	O
prefix	B-Application
sum	I-Application
problem	O
in	O
parallel	O
for	O
a	O
list	O
of	O
n	O
items	O
)	O
:	O
</s>
<s>
Determine	O
the	O
level	O
of	O
each	O
node	O
:	O
Do	O
a	O
prefix	B-Application
sum	I-Application
on	O
the	O
ETR	O
,	O
where	O
every	O
advance	O
edge	O
counts	O
as	O
1	O
,	O
and	O
every	O
retreat	O
edge	O
counts	O
as	O
−1	O
.	O
</s>
<s>
Number	O
of	O
nodes	O
in	O
a	O
subtree	O
rooted	O
at	O
v	O
:	O
assume	O
the	O
parent	O
of	O
v	O
is	O
u	O
,	O
determine	O
advance	O
edge	O
(	O
u	O
,	O
v	O
)	O
,	O
and	O
the	O
retreat	O
edge	O
(	O
v	O
,	O
u	O
)	O
in	O
parallel	O
,	O
and	O
then	O
count	O
the	O
number	O
of	O
advance	O
edges	O
between	O
(	O
u	O
,	O
v	O
)	O
and	O
(	O
v	O
,	O
u	O
)	O
using	O
prefix	B-Application
sum	I-Application
.	O
</s>
<s>
The	O
depth-first	B-Algorithm
search	I-Algorithm
index	O
of	O
a	O
node	O
v	O
:	O
count	O
the	O
number	O
of	O
advance	O
edges	O
up	O
to	O
and	O
including	O
(	O
u	O
,	O
v	O
)	O
.	O
</s>
<s>
Henzinger	O
and	O
King	O
suggest	O
to	O
represent	O
a	O
given	O
tree	O
by	O
keeping	O
its	O
Euler	O
tour	O
in	O
a	O
balanced	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
,	O
keyed	O
by	O
the	O
index	O
in	O
the	O
tour	O
.	O
</s>
<s>
So	O
for	O
example	O
,	O
the	O
unbalanced	O
tree	O
in	O
the	O
example	O
above	O
,	O
having	O
7	O
nodes	O
,	O
will	O
be	O
represented	O
by	O
a	O
balanced	B-Data_Structure
binary	I-Data_Structure
tree	I-Data_Structure
with	O
14	O
nodes	O
,	O
one	O
for	O
each	O
time	O
each	O
node	O
appears	O
on	O
the	O
tour	O
.	O
</s>
<s>
We	O
can	O
represent	O
a	O
forest	O
(	O
an	O
acyclic	O
graph	O
)	O
using	O
a	O
collection	O
of	O
ET	B-Operating_System
trees	I-Operating_System
-	O
one	O
ET	B-Operating_System
tree	I-Operating_System
for	O
one	O
forest	O
tree	O
.	O
</s>
<s>
by	O
just	O
moving	O
to	O
the	O
first	O
node	O
of	O
the	O
ET	B-Operating_System
tree	I-Operating_System
(	O
since	O
nodes	O
in	O
the	O
ET	B-Operating_System
tree	I-Operating_System
are	O
keyed	O
by	O
their	O
location	O
in	O
the	O
Euler	O
tour	O
,	O
and	O
the	O
root	O
is	O
the	O
first	O
and	O
last	O
node	O
in	O
the	O
tour	O
)	O
.	O
</s>
<s>
Link/cut	B-Data_Structure
trees	I-Data_Structure
have	O
similar	O
performance	O
guarantees	O
.	O
</s>
<s>
While	O
LC	O
trees	O
are	O
good	O
for	O
maintaining	O
aggregates	O
on	O
paths	O
of	O
a	O
tree	O
(	O
making	O
it	O
a	O
good	O
choice	O
data	O
structure	O
in	O
network	O
flow	O
algorithms	O
)	O
,	O
ET	B-Operating_System
trees	I-Operating_System
are	O
better	O
at	O
keeping	O
aggregate	O
information	O
on	O
subtrees	O
.	O
</s>
