<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/12/644d57efdd9d2acc90b0e089df817412"
  from="Jean-Baptiste Rouquier &lt;jean-baptiste.rouquier@e...&gt;"
  author="Jean-Baptiste Rouquier"
  date="2003-12-10T21:47:02"
  subject="Re: [Caml-list] how to calculate a &quot;xor&quot;"
  prev="2003/12/1e676f8fcefbaa708f890932f7547f19"
  next="2003/12/562803867fd4a377b41a8e3a465f43b7"
  prev-in-thread="2003/12/5f70e25ab8bd63188579edc825ec4041"
  prev-thread="2003/12/89c86bc0dc75f477b32fd1c1d1f8d712"
  next-thread="2003/12/6645b76fdaaac896907eba3358f17de9"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] how to calculate a &quot;xor&quot;">
<msg 
  url="2003/12/15aed9cdaa87e3077ca1de4ee1e768ca"
  from="Damien &lt;Damien.Pous@e...&gt;"
  author="Damien"
  date="2003-12-05T19:11:04"
  subject="[Caml-list] how to calculate a &quot;xor&quot;">
<msg 
  url="2003/12/5f70e25ab8bd63188579edc825ec4041"
  from="Alan Post &lt;apost@r...&gt;"
  author="Alan Post"
  date="2003-12-06T05:08:08"
  subject="[Caml-list] Re: how to calculate a &quot;xor&quot;">
</msg>
<msg 
  url="2003/12/644d57efdd9d2acc90b0e089df817412"
  from="Jean-Baptiste Rouquier &lt;jean-baptiste.rouquier@e...&gt;"
  author="Jean-Baptiste Rouquier"
  date="2003-12-10T21:47:02"
  subject="Re: [Caml-list] how to calculate a &quot;xor&quot;">
</msg>
</msg>
</thread>

<contents>
Damien wrote:

&gt; Hi algorithmers,
&gt;
&gt; Given two sets A and B, I want to calculate A\B _and_ B\A.
&gt; The sets are represented by lists.

Consider the case A = [a_1; a_3; a_5; ...] and B = [a_2; a_4; a_6; ...] 
where a_i &lt; a__{i+1}.
I think it's a worst case for any algorithm.

&gt; without using an order to sort the lists,

that is, if the only allowed comparison is "="

&gt; is there something better than (...) (O(n2)) ?

In my example, any algorithm has to test if a_{2i} = a_{2j+1}. So the 
worst case is O(n2).


&gt; with an order, is there something better than (O(n*ln n)) ?

Consider the case where an algorithm M hasn't sorted B. So there are 2 
consecutive elements, say a_4 and a_6, that hasn't been compared 
(directly or with transitivity). a_5 can't have been compared to both 
a_4 and a_6, let's consider a_5 hasn't been compared to a_4. Then M 
can't decide whether a_4 = a_5 or not, even using transitivity.

This proove that any algorithm has to sort both A and B in my example, 
so the worst case is
O(n ln n).

See you soon,
Jean-Baptiste.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

