Found 7347 Articles for C++

C++ Program to Decode a Message Encoded Using Playfair Cipher

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

386 Views

In this scheme, pairs of letters are encrypted, instead of single letters as in the case of simple substitution cipher.In playfair cipher, initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is omitted from the table as we need only 25 alphabets instead of 26. If the plaintext contains J, then it is replaced by I.The sender and the receiver deicide on a particular key, say ‘tutorials’. In a ... Read More

C++ Program to Encode a Message Using Playfair Cipher

Smita Kapse
Updated on 30-Jul-2019 22:30:26

4K+ Views

In this scheme, pairs of letters are encrypted, instead of single letters as in the case of simple substitution cipher.In playfair cipher, initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is omitted from the table as we need only 25 alphabets instead of 26. If the plaintext contains J, then it is replaced by I.The sender and the receiver deicide on a particular key, say ‘tutorials’. In a ... Read More

C++ Program to Implement Caesar Cypher

Anvi Jain
Updated on 30-Jul-2019 22:30:26

20K+ Views

It is a mono-alphabetic cipher wherein each letter of the plaintext is substituted by another letter to form the ciphertext. It is a simplest form of substitution cipher scheme.This cryptosystem is generally referred to as the Shift Cipher. The concept is to replace each alphabet by another alphabet which is ‘shifted’ by some fixed number between 0 and 25.For this type of scheme, both sender and receiver agree on a ‘secret shift number’ for shifting the alphabet. This number which is between 0 and 25 becomes the key of encryption.The name ‘Caesar Cipher’ is occasionally used to describe the Shift ... Read More

C++ Program to Implement Levenshtein Distance Computing Algorithm

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

3K+ Views

The Levenshtein distance between two strings means the minimum number of edits needed to transform one string into the other, with the edit operations i.e; insertion, deletion, or substitution of a single character.For example: The Levenshtein Distance between cat and mat is 1 −cat mat(substitution of ‘c’ with ‘m’)Here is a C++ Program to implement Levenshtein Distance computing algorithm.AlgorithmsBegin    Take the strings as input and also find their length.    For i = 0 to l1       dist[0][i] = i    For j = 0 to l2       dist[j][0] = j    For j=1 to l1 ... Read More

C++ Program to Perform Finite State Automaton based Search

Smita Kapse
Updated on 30-Jul-2019 22:30:26

615 Views

This is a C++ program to perform finite state automaton based search. An automaton with a finite number of states is called a Finite Automaton. Here, a text is given text[0 … t-1] and a pattern p[0 ... p-1] is also given. We have to find the pattern in the text and print its all occurrences at the respective indices.AlgorithmsBegin    Function void transitiontable():    1) put the entries in first row and filled it up. All entries in first row are always 0 except the entry for p[0] character. Always we need to go to state 1.    for ... Read More

C++ Program to Repeatedly Search the Same Text (such as Bible by building a Data Structure)

Anvi Jain
Updated on 30-Jul-2019 22:30:26

136 Views

This is a C++ program to repeatedly search the same text.AlgorithmsBegin    Take the original string and pattern to be searched as input.    org_len = store the length of original string    pat_len = store the length of pattern    for i = 0 to (org_len - pat_len)       for j = 0 to pat_len - 1          if (org[i + j] != patt[j])             if (j == pat_len)                Increase m.       Print the position at which the pattern is ... Read More

C++ Program to Solve N-Queen Problem

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

10K+ Views

This problem is to find an arrangement of N queens on a chess board, such that no queen can attack any other queens on the board.The chess queens can attack in any direction as horizontal, vertical, horizontal and diagonal way.A binary matrix is used to display the positions of N Queens, where no queens can attack other queens. Here, we solve 8 queens problem.InputThe size of a chess board. it is 8 here as (8 x 8 is the size of a normal chess board).OutputThe matrix that represents in which row and column the N Queens can be placed.If the ... Read More

C++ Program to Check if a Given Set of Three Points Lie on a Single Line or Not

Smita Kapse
Updated on 30-Jul-2019 22:30:26

615 Views

This is a C++ program to check if a given set of three points lie on a single line or not. Three points lie on a single line if the area of the triangle formed by this points is equal to zero.The area of the triangle is −0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)).AlgorithmsBegin    Generate the points randomly.    Calculate the area by using above formula.    If area > 0       Then the points don't lie on the straight line.    else if area ... Read More

C++ Program to Show the Duality Transformation of Line and Point

Anvi Jain
Updated on 30-Jul-2019 22:30:26

153 Views

This is a C++ Program to show the Duality Transformation of Line and Point. So it can have two cases −Case-1: A point (a, b) is transformed to the line (y = ax − b).Case-2: A line D(y = cx + d) is transformed to the point D’(c, −d).Functions and pseudocodesFunction LineTransformation(double c, double d)Print C: (d / c) D: (d * -1)Function PointTransformation(double x, double y)Print a = (-1 * y / x) b = (-1 * y)Example#include #include #include using namespace std; void LineTransformation(double c, double d) {    cout y;       ... Read More

C++ program to Implement Threaded Binary Tree

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

3K+ Views

Threaded binary tree is a binary tree that provides the facility to traverse the tree in a particular order.It makes inorder traversal faster and do it without stack and without recursion. There are two types of threaded binary trees.Single Threaded Each node is threaded towards either left or right means in-order predecessor or successor. Here, all right null pointers will point to inorder successor or all left null pointers will point to inorder predecessor.Double threaded Each node is threaded towards either left and right means in-order predecessor and successor. Here, all right null pointers will point to inorder successor and ... Read More

Advertisements