User:Realazthat/Notes/Algorithms/Set-intersection: Difference between revisions

From Rosetta Code
Content added Content deleted
(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...")
(No difference)

Revision as of 17:32, 6 January 2011

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