def apriori(db: list, min_sup):
    min_sup = ((len(db) * min_sup) // 100)
    levels = list()
    Levels_info = list()
    L1 = find_frequent_1_itemsets(db, min_sup)
    if (bool(L1) == False):
        print('No 1-Itemset Satisfies Given Minimum Support Threshold')
        return None
    _L1 = [[k] for k in L1.keys()]
    _L1 = sorted(_L1)
    levels.append(_L1)
    Levels_info.append({'join': len(_L1), 'prune': len(_L1)})
    while True:
        (info, candidates) = apriori_gen(levels[(- 1)], len(levels[(- 1)][0]))
        trie = Trie(db)
        trie.build_trie(candidates)
        trie.assign_frequency()
        L = list()
        for itemset in candidates:
            if (trie.get_candidate_freq(itemset) >= min_sup):
                L.append(sorted(itemset))
        if (not L):
            break
        levels.append(L)
        Levels_info.append(info)
    return (Levels_info, levels)
def apriori(db: list, min_sup):
    min_sup = ((len(db) * min_sup) // 100)
    levels = list()
    Levels_info = list()
    L1 = find_frequent_1_itemsets(db, min_sup)
    if (bool(L1) == False):
        print('No 1-Itemset Satisfies Given Minimum Support Threshold')
        return None
    _L1 = [[k] for k in L1.keys()]
    _L1 = sorted(_L1)
    levels.append(_L1)
    Levels_info.append({'join': len(_L1), 'prune': len(_L1)})
    while True:
        (info, candidates) = apriori_gen(levels[(- 1)], len(levels[(- 1)][0]))
        trie = Trie(db)
        trie.build_trie(candidates)
        trie.assign_frequency()
        L = list()
        for itemset in candidates:
            if (trie.get_candidate_freq(itemset) >= min_sup):
                L.append(sorted(itemset))
        if (not L):
            break
        levels.append(L)
        Levels_info.append(info)
    return (Levels_info, levels)