<s>
Marzullo	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
,	O
invented	O
by	O
Keith	O
Marzullo	O
for	O
his	O
Ph.D.	O
dissertation	O
in	O
1984	O
,	O
is	O
an	O
agreement	O
algorithm	O
used	O
to	O
select	O
sources	O
for	O
estimating	O
accurate	O
time	O
from	O
a	O
number	O
of	O
noisy	O
time	O
sources	O
.	O
</s>
<s>
A	O
refined	O
version	O
of	O
it	O
,	O
renamed	O
the	O
"	O
intersection	B-Operating_System
algorithm	I-Operating_System
"	O
,	O
forms	O
part	O
of	O
the	O
modern	O
Network	B-Protocol
Time	I-Protocol
Protocol	I-Protocol
.	O
</s>
<s>
Marzullo	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
is	O
also	O
used	O
to	O
compute	O
the	O
relaxed	B-Application
intersection	I-Application
of	O
n	O
boxes	O
(	O
or	O
more	O
generally	O
n	O
subsets	O
of	O
Rn	O
)	O
,	O
as	O
required	O
by	O
several	O
robust	O
set	O
estimation	O
methods	O
.	O
</s>
<s>
Marzullo	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
is	O
efficient	O
in	O
terms	O
of	O
time	O
for	O
producing	O
an	O
optimal	O
value	O
from	O
a	O
set	O
of	O
estimates	O
with	O
confidence	O
intervals	O
where	O
the	O
actual	O
value	O
may	O
be	O
outside	O
the	O
confidence	O
interval	O
for	O
some	O
sources	O
.	O
</s>
<s>
If	O
the	O
desired	O
result	O
is	O
a	O
best	O
value	O
from	O
that	O
interval	O
then	O
a	O
naive	O
approach	O
would	O
be	O
to	O
take	O
the	O
center	O
of	O
the	O
interval	O
as	O
the	O
value	O
,	O
which	O
is	O
what	O
was	O
specified	O
in	O
the	O
original	O
Marzullo	B-Operating_System
algorithm	I-Operating_System
.	O
</s>
<s>
Marzullo	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
begins	O
by	O
preparing	O
a	O
table	O
of	O
the	O
sources	O
,	O
sorting	B-Algorithm
it	O
and	O
then	O
searching	O
(	O
efficiently	O
)	O
for	O
the	O
intersections	O
of	O
intervals	O
.	O
</s>
<s>
For	O
each	O
range	O
the	O
table	O
will	O
have	O
two	O
tuples	B-Application
of	O
the	O
form	O
.	O
</s>
<s>
One	O
tuple	B-Application
will	O
represent	O
the	O
beginning	O
of	O
the	O
range	O
,	O
marked	O
with	O
type	O
1	O
as	O
and	O
the	O
other	O
will	O
represent	O
the	O
end	O
with	O
type	O
+1	O
as	O
.	O
</s>
<s>
The	O
description	O
of	O
the	O
algorithm	O
uses	O
the	O
following	O
variables	O
:	O
best	O
(	O
largest	O
number	O
of	O
overlapping	O
intervals	O
found	O
)	O
,	O
cnt	O
(	O
current	O
number	O
of	O
overlapping	O
intervals	O
)	O
,	O
beststart	O
and	O
bestend	O
(	O
the	O
beginning	O
and	O
end	O
of	O
best	O
interval	O
found	O
so	O
far	O
)	O
,	O
i	O
(	O
an	O
index	O
)	O
,	O
and	O
the	O
table	O
of	O
tuples	B-Application
.	O
</s>
<s>
Build	O
the	O
table	O
of	O
tuples	B-Application
.	O
</s>
<s>
Sort	B-Algorithm
the	O
table	O
by	O
the	O
offset	O
.	O
</s>
<s>
(	O
If	O
two	O
tuples	B-Application
with	O
the	O
same	O
offset	O
but	O
opposite	O
types	O
exist	O
,	O
indicating	O
that	O
one	O
interval	O
ends	O
just	O
as	O
another	O
begins	O
,	O
then	O
a	O
method	O
of	O
deciding	O
which	O
comes	O
first	O
is	O
necessary	O
.	O
</s>
<s>
commentary	O
:	O
the	O
next	O
tuple	B-Application
,	O
at	O
[i+1],	O
will	O
either	O
be	O
an	O
end	O
of	O
an	O
interval	O
(	O
type	O
=	O
+1	O
)	O
in	O
which	O
case	O
it	O
ends	O
this	O
best	O
interval	O
,	O
or	O
it	O
will	O
be	O
a	O
beginning	O
of	O
an	O
interval	O
(	O
type	O
=	O
−1	O
)	O
and	O
in	O
the	O
next	O
step	O
will	O
replace	O
best	O
.	O
</s>
<s>
Marzullo	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
is	O
efficient	O
in	O
both	O
space	O
and	O
time	O
.	O
</s>
<s>
In	O
considering	O
the	O
asymptotic	O
time	O
requirement	O
the	O
algorithm	O
can	O
be	O
considered	O
to	O
consist	O
of	O
building	O
the	O
table	O
,	O
sorting	B-Algorithm
it	O
and	O
searching	O
it	O
.	O
</s>
<s>
Sorting	B-Algorithm
can	O
be	O
done	O
in	O
O(n log n )	O
time	O
,	O
and	O
this	O
dominates	O
the	O
building	O
and	O
searching	O
phases	O
which	O
can	O
be	O
performed	O
in	O
linear	O
time	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
time	O
efficiency	O
of	O
Marzullo	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
is	O
O(n log n )	O
.	O
</s>
