Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose we have a collection of n different subsets of the set { 1, 2, ..., n }

ID: 3793935 • Letter: S

Question

Suppose we have a collection of n different subsets of the set { 1, 2, ..., n } and they are in some arbitrary order, that is, we have subsets S1, S2, ..., Sn, but how many and which elements are in each of these subsets is entirely arbitrary. Suppose also that we have another subset S' of { 1, 2, ..., n }.

a) Express a brute-force algorithm that determines whether S' equal to one of the subsets in the collection.

b) Give a big-O worst case estimate as a function of n for the time complexity of your algorithm. To receive full credit, you must explain how you obtained your answer.

Explanation / Answer

So we've got subsets S1, S2, ..., tin and set S'.

So 1st conclusion is worst case of determinant whether or not S' adequate to one among the subsets within the assortment, can occur once the length of every of those subsets is most. thus most length of every these subsets is O.

Now we've got to match S' with every of S1, S2, ..., Sn.

Lets say we tend to compare S' with S1. Our strategy to seek out weather S' is adequate to S1 is kind S' and S1 in O(nlogn) time and compare parts at every index in O time.

thus this may take O(logn) + O = O(nlogn) time.

So, we are going to repeat this with all n subsets.

Hence overall time = n*O(nlogn) = O(n^2 * logn)