Approximation algorithms and heuristics for some combinatorial problems with applications in pattern matching and distributed systems