User:Realazthat/Notes/Algorithms/Set-intersection

Revision as of 17:32, 6 January 2011 by rosettacode>Realazthat (Created page with "== Intersection Not Empty == <pre> #Intersection Not Empty INE(A,B): if |A| > |B| return true for ( a in A ) if ( a not in B ) return true return fals...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Intersection Not Empty

#Intersection Not Empty
INE(A,B):
  if |A| > |B|
    return true
  
  for ( a in A )
    if ( a not in B )
      return true
  
  return false

#Intersection Not Empty
INE(A,B):
  if |A| > |B|
    return true
  
  for ( b in B )
    remove b from A
    remove b from B
    if |A| > |B|
      return true
  
  return false