# What's the difference between the greedy and Hamiltonian methods?

Given T={CTAGC, GAGCG, AGCGG, CGGAG}, using a greedy algorithm, the superstring S will be CTAGCGGAGCG.

From `S`, the combination of triplets will be given as s = {CTA, TAG, AGC, GCG, CGG, GGA, GAG, AGC, GCG}.

Both GCG and AGC are repeated.

If using s to retrieve the superstring by using Hamiltonian method, would the repeated words will be used or omitted?

If the repeated word is omitted, then CTA, TAG, AGC, GCG, CGG, GGA, and GAG constructed back will become GTAGCGGAGC.

So, in the end, both the greedy method and Hamiltonian method will provide different results in the superstring.

Why are they different? In my research, all the examples I found showed that there are no repeated words in the combination, so if I reconstruct the superstring using the Hamiltonian method, the result of the greedy and Hamiltonian methods will be the same. But what about the repeated words?

• Conceptual algorithm questions are on-topic here: I just cleaned up your question a little bit. – user8 Oct 11 '11 at 15:14
• @MarkTrapp - surely there's a GreedyVsHamiltonian.stackexchange.com site by now. – Joel Etherton Oct 11 '11 at 15:21

## 1 Answer

I didn't quite know the exact algorithm that expresses Super string `S` from the set `T` However here is a short answer to your question.

Basically, greedy optimization (or search) algorithm returns after they find first minimum. Thus, they are fairly dependent on the starting point and the nature of the function. On the other hand, Global optimization algorithms tend to search the entire possible space to find the minima across the space. When the search space is minimum, or convex by nature the result of both the type of algorithm is same because there is only 1 minimum. However, if there are many local minima then the global optimization algorithm will search the correct one, whereas the greedy algorithm may produce a sub-optimal result.