Axiom, 439 bytes
c:=0;s(x,y)==(free c;if x.1=%i and y.2=%i then(x.2<y.1=>return true;x.2>y.1=>return false;c:=1;return false);if x.2=%i and y.1=%i then(x.1<y.2=>return true;x.1>y.2=>return false;c:=1;return false);if x.1=%i and y.1=%i then(x.2<y.2=>return true;x.2>=y.2=>return false);if x.2=%i and y.2=%i then(x.1<y.1=>return true;x.1>=y.1=>return false);false);r(a,b)==(free c;c:=0;m:=[[%i,j] for j in a];n:=[[i,%i] for i in b];r:=merge(m,n);sort(s,r);c)
this convert the first list in a list as [[i,1], [i,2]...] the second list in a list as [[1,i], [0,i]...]
where i is the variable imaginary
than merge the 2 list, and make one sort that would find if there is one element of list 1 in the list 2
so it is at last O(N log N) where N=lenght list 1 + lenght list 2
ungolfed
-- i get [0,0,1,2,3] and [0,4,6,7] and build [[%i,0],[%i,0],[%i,1],[%i,2] [%i,3],[0,%i],..[7,%i]]
c:=0
s(x:List Complex INT,y:List Complex INT):Boolean==
free c -- [%i,n]<[n,%i]
if x.1=%i and y.2=%i then
x.2<y.1=> return true
x.2>y.1=> return false
c:=1
return false
if x.2=%i and y.1=%i then
x.1<y.2=>return true
x.1>y.2=>return false
c:=1
return false
if x.1=%i and y.1=%i then
x.2< y.2=>return true
x.2>=y.2=>return false
if x.2=%i and y.2=%i then
x.1< y.1=>return true
x.1>=y.1=>return false
false
r(a,b)==
free c
c:=0
m:=[[%i, j] for j in a]
n:=[[ i,%i] for i in b]
r:=merge(m,n)
sort(s, r)
c
results
(12) -> r([1,2,3,4,-5], [5,7,6,8]), r([],[0]), r([],[]), r([1,2],[3,3]), r([3,2,1],[-4,3,5,6]), r([2,3],[2,2])
Compiling function r with type (List PositiveInteger,List Integer)
-> NonNegativeInteger
Compiled code for r has been cleared.
Compiled code for s has been cleared.
Compiling function r with type (List PositiveInteger,List
PositiveInteger) -> NonNegativeInteger
Compiled code for r has been cleared.
Compiling function s with type (List Complex Integer,List Complex
Integer) -> Boolean
Compiled code for s has been cleared.
(12) [0,0,0,0,1,1]
Type: Tuple NonNegativeInteger
i dont understand why it "clears" code for r and s...
1Are the integers bound/small like in your example? E.g. is radixsort or a bitmap possible? – Christoph – 2016-11-30T06:46:51.473
2@Pavel The complexity depends very much on the set implementation, as far as I can tell.
O(n log n)
is doable in general, but the clarification about only handling native integers means that in some languages with limited integer ranges a linear solution is possible (e.g. by a 2^64 size lookup table) – Sp3000 – 2016-11-30T08:57:12.437By the way, I think that all hash-based solutions with arbitrary precision ranges should have to demonstrate that no collisions are possible or some other property to guarantee satisfaction of the requirement, because I'm not convinced about some of these answers... (with the current rules) – Sp3000 – 2016-11-30T09:18:22.490
If the first array (N elements) is sorted it is Nlog(N) if for each element of 2 array search using "binary search" in 1 array it would be nlog(N) so the total is Nlog(N)+nlog(N)=(N+n)log(N) that is > to Nlog(N) claimed from the question ... So would remain "ascii tables"? – RosLuP – 2016-11-30T23:31:09.320
@RosLuP NLogN+NLogN is still O(NLogN) – Pavel – 2016-11-30T23:35:41.530
I would not recommend accepting answers so quickly. It's recommended to wait at least for a week before accepting an answer. – Erik the Outgolfer – 2016-12-02T15:37:08.943
@erikthegolfer yeah, who's going to beat a one byte solution? – Pavel – 2016-12-02T16:30:44.473
@Pavel Did you notice that I removed the "The" from my name (I just now saw your reply)? A week is usually considered to be the norm before accepting an answer (although I use 14 days). It's your choice after all, but I think it's good practice to wait before you accept, because, technically, a 0-byte answer is also possible in a programming language that is buried deep on the internet and nobody except its creator knows about it (and in fact fits our definition of a programming language). – Erik the Outgolfer – 2016-12-02T17:23:21.700
@Pavel Personally, I'm concerned about the validity of answers instead, because I'm not convinced most of the hash-based answers are valid (e.g. all the Python ones - see comments on the Actually answer)... – Sp3000 – 2016-12-02T21:01:35.347