Hitting Set Problem with non-minimal Greedy Algorithm

The Hitting Set Problem is defined as having a universal set $ \mathfrak{U}$ , and nonempty sets $ S_i \subseteq \mathfrak{U}$ for $ 1 \leq i \leq n$ , and finding a set $ \mathcal{H} \subset \mathfrak{U}$ such that $ |\mathcal{H} \cap S_i| \geq 1$ for all $ 1 \leq i \leq n$ .

We may ask for the minimal cardinality of $ \mathcal{H}$ , that is, what is the least number of elements needed to “Hit” every $ S_i$ ?

Further, we may use a greedy algorithm to ensure we find a hitting set. In this greedy algorithm, we set $ \mathcal{H} = \emptyset$ , and while we still have sets $ S_i$ that have not been hit, we add to $ \mathcal{H}$ an element whom appears in the most $ S_i$ that have not been hit.

My question is: What is an example of a Universe set $ \mathfrak{U}$ and subsets $ S_i$ , where $ 1 \leq i \leq n$ for some $ n \in \mathbb{N}$ , such that the greedy algorithm above does not find a minimal Hitting Set $ \mathcal{H} \subset \mathfrak{U}$ ?

For a longer (and probably clearer) description, and more info on the Hitting Set problem, see http://theory.stanford.edu/~virgi/cs267/lecture5.pdf, or Prove that Hitting Set is NP-Complete.

Hitting Set Problem with non-minimal Greedy Algorithm

The Hitting Set Problem is defined as having a universal set $ \mathfrak{U}$ , and nonempty sets $ S_i \subseteq \mathfrak{U}$ for $ 1 \leq i \leq n$ , and finding a set $ \mathcal{H} \subset \mathfrak{U}$ such that $ |\mathcal{H} \cap S_i| \geq 1$ for all $ 1 \leq i \leq n$ .

We may ask for the minimal cardinality of $ \mathcal{H}$ , that is, what is the least number of elements needed to “Hit” every $ S_i$ ?

Further, we may use a greedy algorithm to ensure we find a hitting set. In this greedy algorithm, we set $ \mathcal{H} = \emptyset$ , and while we still have sets $ S_i$ that have not been hit, we add to $ \mathcal{H}$ an element whom appears in the most $ S_i$ that have not been hit.

My question is: What is an example of a Universe set $ \mathfrak{U}$ and subsets $ S_i$ , where $ 1 \leq i \leq n$ for some $ n \in \mathbb{N}$ , such that the greedy algorithm above does not find a minimal Hitting Set $ \mathcal{H} \subset \mathfrak{U}$ ?

For a longer (and probably clearer) description, and more info on the Hitting Set problem, see http://theory.stanford.edu/~virgi/cs267/lecture5.pdf, or Prove that Hitting Set is NP-Complete.

HITTING SET Problem

HITTING SET INSTANCE: collection C of subsets of a set S, positive integer K. QUESTION: Does C contain a hitting set for C of size K or less, that is, a subset S’ of S with |S’| <= K and such that S’ contains at least one element from each subset in C

Prove that HITTING SET is NP-Complete problem?

Multiple choice knapsack dynamic problem

Giving a the following:

A list of a store items $ T=\{t_1, t_2,…,t_n\}$ .

A list of prices of each item $ P=\{p_1, p_2,…,p_n\}$ .

A list of quantities of each item $ Q=\{q_1, q_2,…,q_n\}$ respectively.

And total bill $ M$ .

Our goal is to find any possible list of items that its total value is equal to $ M$ using dynamic problem.

My question does 0/1 weighted Knapsack problem help, where $ M$ can be the capacity of the knapsack, and the weight of each item equal to the quantity of the item. If there is any other better approach I would appreciate any references.

Tell Me any website related problem and i’ll try to solve that for free

Hello Members, I'm here to help you. If you have any problem, questions and errors related to your website then feel free to write here and i'll try to solve your issue without taking any penny but before we go ahead you need to trust on me.

Little About me: I'm a programmer who likes to make new apps, Software and websites. I have knowledge of PHP, MySQL, HTML5, CSS3, Bootstrap, JavaScript, jQuery.

time complexity of 2 sum problem using binary search

this is a popular searching problem and the question is :

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2.

Note: Your returned answers (both index1 and index2) are not zero-based. You may assume that each input would have exactly one solution and you may not use the same element twice.

Input: numbers = [2,7,11,15], target = 9 Output: [1,2]

Explanation: The sum of 2 and 7 is 9. Therefore index1 = 1, index2 = 2.

Now i know that it can be solved using 2-pointer method,hashing and binary search.

If i use binary search,it goes like fix the first element A[0] and do binary search on the remaining n-1 elements. If cannot find any element which equals target-A[0], Try A[1]. That is, fix A[1] and do binary search on A[2]~A[n-1]. Continue this process until we have the last two elements A[n-2] and A[n-1].

what will be the time complexity if i use binary search ? is not it O(nlgn)?as in the worst case, we have to go extreme right. Somewhere it is mentioned that the worst case is still o(n) while average case is O(lgn).

Let me know if O(nlgn) is wrong and the reason.

reducing the halting problem to this

enter image description here

I think the first language is decideable, as the input string is of finite length and you can check every character in the string.

However, my intuition says the second language is undecideable. This would be like checking if a TM is equal to a TM that decides L1.

Am I correct? And if so, how should I proceed to reduce the halting problem to L2?

Optimal solution for Weighted points problem

Problem: Given a set of 2d points N: {N1, N2, N3, …., Nn}, find a set of points X: {X1, X2, X3, …., Xk} such that the points in X are D distance apart and Sum( Weight(Xi) ) from i= 1 to k is maximized.

The greedy way to do it would be to sort the points by weight and exclude points which are inside a distance of D from the current point that is being processed. Is there a better way to do it?