You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defaprioriGen(Lk, k): #creates CkretList= []
lenLk=len(Lk)
foriinrange(lenLk):
forjinrange(i+1, lenLk):
L1=list(Lk[i])[:k-2]; L2=list(Lk[j])[:k-2]
L1.sort(); L2.sort()
ifL1==L2: #if first k-2 elements are equalretList.append(Lk[i] |Lk[j]) #set unionreturnretList
I think the L1 and L2 should sort first, then extract the front k-2 items to compare. Take the example:
L1 = [1,2]
L2 = {3, 1}
Though, when a set converted to a list, it's usually sorted.
The text was updated successfully, but these errors were encountered:
In chapter 11
I think the L1 and L2 should sort first, then extract the front k-2 items to compare. Take the example:
L1 = [1,2]
L2 = {3, 1}
Though, when a set converted to a list, it's usually sorted.
The text was updated successfully, but these errors were encountered: