The maximum coverage problem is that given an integer k and a list of n finite s
ID: 3835466 • Letter: T
Question
The maximum coverage problem is that given an integer k and a list of n finite sets S 1, S2, Sn, select k sets from the n sets to have maximum size of union. This is one of the classical NP-hard problems. 1. Write a program to implement the greedy algorithm: Mark all n sets Sl, S2, Sn as unselected. Repeat k times Select one set that has the maximum number of elements not in the union the already selected sets. 2. Write a randomized implementation for the greedy algorithm. Let m be a parameter that controls the number of random samples. Mark all n sets Si, S2, ...., Sn as "unselected". The maximum coverage problem is that given an integer k and a list of n finite sets S 1, S2, Sn, select k sets from the n sets to have maximum size of union. This is one of the classical NP-hard problems. 1. Write a program to implement the greedy algorithm: Mark all n sets Sl, S2, Sn as unselected. Repeat k times Select one set that has the maximum number of elements not in the union the already selected sets. 2. Write a randomized implementation for the greedy algorithm. Let m be a parameter that controls the number of random samples. Mark all n sets Si, S2, ...., Sn as "unselected". The maximum coverage problem is that given an integer k and a list of n finite sets S 1, S2, Sn, select k sets from the n sets to have maximum size of union. This is one of the classical NP-hard problems. 1. Write a program to implement the greedy algorithm: Mark all n sets Sl, S2, Sn as unselected. Repeat k times Select one set that has the maximum number of elements not in the union the already selected sets. 2. Write a randomized implementation for the greedy algorithm. Let m be a parameter that controls the number of random samples. Mark all n sets Si, S2, ...., Sn as "unselected".Explanation / Answer
2)
1. If low >= high, then EXIT.
2. as pivot 'x' is not a middle Pivot.
(i) decide consistently at random a number as of [low..high].
Let the arbitrarily chosen figure number be x.
(ii) Count elements in arr[low..high] that are lesser
than arr[x]. Let this count be sc.
(iii) Count rudiments in arr[low..high] that are greater
than arr[x]. Let this count be gc.
(iv) Let n = (high-low+1). If sc >= n/4 and
gc >= n/4, then x is a middle pivot.
3. Partition arr[low..high] approximately the pivot x.
4. // Recur for lesser elements
randQuickSort(arr, low, sc-1)
5. // Recur for better elements
randQuickSort(arr, high-gc+1, high)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.