I could use some help designing this algorithm in psuedocode. Please, and thank
ID: 3818985 • Letter: I
Question
I could use some help designing this algorithm in psuedocode. Please, and thank you!
Problem 2. Given:
-
P= {p_1, p_2, ..., p_m}, the set of products available at a local grocery store;
D= {T_1, T_2, ..., T_N}, the set of transactions that were completed at this store in the past year, where each T_i (i in [1,N]) is a subset of P;
min_freq, a user-specified parameter (e.g., 5%).
-
A product is said to be frequent if it occurs in at least min_freq of the transactions in D. By the same token, a pair of products is said to be frequent if it occurs in at least min_freq of the transactions in D. Also, it's straightforward to prove the following claim: if a product is not frequent, none of the pairs that involve this product will be frequent. Use this claim to design an algorithm to find all the frequent products and frequent product pairs in D. Please describe your algorithm unambiguously using pseudo-code with necessary comments in English.
Explanation / Answer
In each transaction D, find the number of items in it and put in an array T[].
maximum items are max_freq
In array T[] find transactions having maximum items.
1.if(count(max_freq(array[])) > min_freq) {
transfer to the new two-dimensional array A[][] } else { find subsets }
2.Compare every transaction in A[ ][ ] with other transactions.
3.Take variable c as counter and increase it if we found similar itemsets in A[ ][ ].
4.If {c> min_freq} then itemset are the most frequent itemset.
5. if {c<min_freq} then find the subsets of all transactions and store it in an array Sub[ ][ ].
6.max = max-1.
7.Add the transactions from Sub[ ][ ] to A[ ][ ].
8.Repeat from step 1 if we get frequent items or until we get frequent items.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.