# C Programming Examples on Set & String Problems & Algorithms

## 1. C Programming examples on “Set Cover”

Set covering problem (SCP) is a classical question in combinatorics and complexity theory. This section contains C programs to find the smallest vertices and optimal solution using backtracking. The other programs deals with the implements boolean logic minimization, greedy approach and set cover problems.

C Program to Find the Smallest Set of Vertices that will Cover Each Edge atleast once. C Program to Find an Optimal Solution for Set Cover Problem Using Backtracking C Program to Use Integer Programming Formula to Solve the Set Cover Problem C Program to Solve Set Cover Problem assuming at max 2 Elements in a Subset C Program to Implement Boolean Logic Minimization Using Set Cover Problem C Program to Use Greedy Approach to Solve Set Cover Problem |

## 2. C Programming examples on “Set Packing”

Set packing corresponds to a set of vertices with no edge in common, it is also called as independent set. The C programs in this section deals with the implementation of exhaustive search algorithm and heuristic approach to solve set packing.

C Program to Implement Exhaustive Search Algorithm for Set Packing C Program to Implement Heuristic Approach to Solve Set Packing C Program to Check if a Set Packing is Possible of Size k for a Given Pair of Universe U and a Family S of Subsets of U (U,S) |

## 3. C Programming examples on “String Matching”

String matching algorithms try to find a place where one or several strings are found within a larger string or text. Rabin-Karp Algorithm is a string that uses hashing to find any one of a set of pattern strings in a text. Naive String Matching algorithm is optimized for the cases when all characters of pattern are different. Boyer-Moore Algorithm performs the matching from right to left. Knuth–Morris–Pratt string searching algorithm searches for occurrences of a word within a main text string. The C programs in this section deals with the implementation of string search algorithms for short text sizes, knuth-morris-pratt algorithm, z algorithm, aho-corasick and boyer-moore algorithm for string matching, rabin-karp method, naive, commentz-walter algorithm, zhu–takaoka for string matching.

C Program to Implement the String Search Algorithm for Short Text Sizes C Program to Implement Knuth-Morris-Pratt Algorithm for String Matching C Program to Implement Boyer-Moore Algorithm for String Matching C Program to Repeatedly Search the Same Text (such as Bible by building a Data Structure) C Program to Implement Aho-Corasick Algorithm for String Matching C Program to Implement the Program Used in grep/egrep/fgrep C Program to Implement Rabin-Karp Method for String Matching C Program to Perform Naive String Matching C Program to Perform Finite State Automaton based Search C Program to Implement Bitap Algorithm for String Matching C Program to Implement Commentz-Walter Algorithm C Program to Implement Zhu–Takaoka String Matching Algorithm C Program to Perform String Matching Using String Library C Program to Implement String Matching Using Vectors |

## 4. C Programming examples on “Approximate String Matching”

Levenshtein algorithm calculates the least number of edit operations that are necessary to modify one string to obtain another string. Brute-Force Approach checks whether every single character from the text to match against the pattern. Wagner–Fischer algorithm is a dynamic programming algorithm that measures the Levenshtein distance between two strings of characters. The C programs in this section demonstrates the implementation of algorithms like bit parallel algorithm, hirschberg’s clever recursive, brute-force approach, levenshtein distance computing algorithm, wagner and fisher algorithms for approximate string matching.

C Program to Use Dynamic Programming to Solve Approximate String Matching C Program to Implement Bit Parallel Algorithm for approximate String Matching C Program to Implement Hirschberg’s Clever Recursive Algorithm C Program to Implement Brute-Force Approach for Approximate String Matching C Program to Implement Levenshtein Distance Computing Algorithm C Program to Implement Wagner and Fisher Algorithm for online String Matching |

## 5. C Programming examples on “Cryptography”

Cryptography is a method of storing and transmitting data in a particular form, scrambling plaintext into ciphertext is known as encryption. Caesar Cipher Encryption algorithm is the simplest of all, where every character of the message is replaced by its next 3rd character. One time pad cipher Input is not case sensitive and works only for all characters, White spaces are not ignored but are produced as random characters in the decoded message. MD5 hashing algorithm is a one-way cryptographic function that accepts a message of any length as input and returns as output a fixed-length message. RSA is one of the first practicable public-key cryptosystems and is widely used for secure data transmission. Monoalphabetic cipher uses fixed substitution over the entire message. Hill cipher is a polygraphic substitution cipher based on linear algebra. Vigenere Cipher is a method of encrypting alphabetic text. The C programs in this section demonstrates the implementation of caesar cipher, playfair cipher, one time pad algorithm, md5 algorithm, rsa algorithm, monoalphabetic cypher, hill cypher, vigenere and affine ciphers.

C Program to Implement Caesar Cypher C Program to Enode a Message Using Playfair Cipher C Program to Decode a Message Encoded Using Playfair Cipher C Program to Implement the One Time Pad Algorithm C Program to Implement the MD5 Algorithm C Program to Implement the RSA Algorithm C Program to Implement the Checksum Method for Small String Messages and Detect If the Received message is same as the Transmitted C Program to Implement the Monoalphabetic Cypher C Program to Implement the Hill Cypher C Program to Implement the Vigenere Cypher C Program to Perform Cryptography Using Transposition Technique C Program to Implement Affine Cipher |

## 6. C Programming examples on “Finite State Machine Minimization”

Finite automata is a collection of 5-tuple(Q,∑,∂,q0,F). This section contains C programs on Finite State Machine Minimization, deterministic finite automata, construction of DFA and NFA for a given expressions.

C Program to Minimize the Number of States in a Deterministic Finite Automata C Program to Construct DFA from NFA C Program to Construct NFA for a Given Expression |

## 7. C Programming examples on “Longest Common SubString/SubSequence”

The longest common substring problem is to find the longest substring common to all sequences in a set of sequences. Kadane algorithm is to used to obtain the maximum subarray sum from an array of integers. This section contains C programs to find the longest subsequence, prefix matching and shortest super sequence in sequences.

C Program to Implement Kadane’s Algorithm C Program to Find the Longest Subsequence Common to All Sequences in a Set of Sequences C Program to Find the Longest Increasing Subsequence of a Given Sequence C Program to Find the Shortest Supersequence that Contains Two or more Sequences as Subsequences |

**Here’s the list of 1000 C Algorithms, Problems & Programming Examples.**