User:Realazthat/Notes/Algorithms/Set-intersection: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
return false |
return false |
||
</pre> |
</pre> |
||
<pre> |
<pre> |
||
# |
#Set Difference Not Empty |
||
DNE(A,B): |
DNE(A,B): |
||
if |A| > |B| |
if |A| > |B| |
||
Line 29: | Line 28: | ||
return false |
return false |
||
</pre> |
|||
== Set Intersection Not Empty == |
|||
<pre> |
|||
#Set Intersection Not Empty |
|||
INE(A,B): |
|||
C = |A| < |B| ? A : B |
|||
D = |A| < |B| ? B : A |
|||
for ( c in B ) |
|||
if ( c in D ) |
|||
return true |
|||
return false |
|||
</pre> |
</pre> |
Revision as of 17:36, 6 January 2011
Set Difference Not Empty
#Set Difference Not Empty DNE(A,B): if |A| > |B| return true for ( a in A ) if ( a not in B ) return true return false
#Set Difference Not Empty DNE(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
Set Intersection Not Empty
#Set Intersection Not Empty INE(A,B): C = |A| < |B| ? A : B D = |A| < |B| ? B : A for ( c in B ) if ( c in D ) return true return false