- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7347 Articles for C++
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
1K+ Views
Here we shall discuss a C++ Program to implement Trie. It is a tree based data structure, used for efficient retrieval of a key in a large data-set of strings.Functions and pseudocodesBegin function insert() : If key not present, inserts key into trie. If the key is prefix of trie node, just mark leaf node. End Begin function deleteNode() If tree is empty then return null. If last character of the key is being processed, then that node will be no more end of string after deleting it. If given key ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
139 Views
Here we shall discuss a C++ Program to find number of ways to Partition a word in such a way that each word is a Palindrome.AlgorithmsBegin Take the word as input. Function partitionadd(vector &u, string &s, vector &tmp, int index): if (index == 0) tmp.clear() for i = index to length-1 st = st + s[i] if (checkPalin(st)) tmp.push_back(st) if (i+1 < length) partitionadd(u, s, tmp, i+1) else ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
444 Views
Here we shall discuss a C++ program to find the Longest Subsequence Common to All Sequences in a Set of Sequences.AlgorithmsBegin Take the array of strings as input. function matchedPrefixtill(): find the matched prefix between string s1 and s2 : n1 = store length of string s1. n2 = store length of string s2. for i = 0, j = 0 to i
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
111 Views
Here we shall discuss a C++ Program to find the Shortest Supersequence that contains two or more Sequences as Subsequences.AlgorithmBegin function ShortestSubSeq() returns supersequence of A and B: 1) Declare an array ss[i][j] which contains length of shortest supersequence for A[0 .. i-1] and B[0 .. j-1]. 2) Find the length of the possible supersequence in bottom up manner using recursion. 3) Declare an array ss[i][j] which stores length of shortest supersequence for A[0 .. i-1] and B[0 .. j-1] in index. 4) Declare a string s to store the shortest subsequence. 5) Initialize ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
114 Views
Here we shall discuss a C++ program to find the Longest Subsequence Common to All Sequences in a Set of Sequences.AlgorithmsBegin Take the array of strings as input. function matchedPrefixtill(): find the matched prefix between string s1 and s2 : n1 = store length of string s1. n2 = store length of string s2. for i = 0, j = 0 to i
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
1K+ Views
Kadane’s algorithm is used to find out the maximum subarray sum from an array of integers. Here we shall discuss a C++ program to implement this algorithm.AlgorithmBegin Function kadanes(int array[], int length): Initialize highestMax = 0 currentElementMax = 0 for i = 0 to length-1 currentElementMax = max(array[i], currentElementMax + array[i]) highestMax = max(highestMax, currentElementMax) return highestMax EndExample#include using namespace std; int kadanes(int array[], int length) { int highestMax = 0; int currentElementMax = 0; for(int i = 0; i < length; i++){ ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
2K+ Views
In the Affine cipher, each letter in an alphabet is mapped to its numeric equivalent, is a type of monoalphabetic substitution cipher. Encryption is done using a simple mathematical function and converted back to a letter.The letters of an alphabet of size m are first mapped to the integers in the range 0 … m-1, in the Affine cipher, The ‘key’ for the Affine cipher consists of 2 numbers, a and b. a should be chosen to be relatively prime to m.EncryptionTo transform the integer, it uses modular arithmetic that each plaintext letter corresponds to into another integer that correspond ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
6K+ Views
Vigenere Cipher is a kind of polyalphabetic substitution method of encrypting alphabetic text.Vigenere Cipher Table is used in which alphabets from A to Z are written in 26 rows, for encryption and decryption in this method.EncryptionKey: WELCOMEMessage: ThisistutorialspointHere we have to obtain a key by repeating the given key till its length becomes equal to original message length.For encryption take first letter of message and key i.e. T and W. Take the alphabet in Vigenere Cipher Table where T row and W column coincides i.e. P.Repeat the same process for all remaining alphabets in message text.Finally, the encrypted message text ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
6K+ Views
Based on linear algebra Hill cipher is a polygraphic substitution cipher in cryptography.To encrypt message: The key string and message string are represented as matrix form. They are multiplied then, against modulo 26. The key matrix should have inverse to decrypt the message.To decrypt message: The encrypted message is multiplied by inverse key matrix used for encryption against modulo 26 to get decrypt message.For exampleKey matrix1 0 1 2 4 0 3 5 6Message string ‘ABC’ in matrix form −0 1 2For encryptionAfter multiplying above two matrices we get, 2 4 17Which will be the encrypted message ‘CER’For decryptionInverse of ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
14K+ Views
RSA is an asymmetric cryptography algorithm which works on two keys-public key and private key.AlgorithmsBegin 1. Choose two prime numbers p and q. 2. Compute n = p*q. 3. Calculate phi = (p-1) * (q-1). 4. Choose an integer e such that 1 < e < phi(n) and gcd(e, phi(n)) = 1; i.e., e and phi(n) are coprime. 5. Calculate d as d ≡ e−1 (mod phi(n)); here, d is the modular multiplicative inverse of e modulo phi(n). 6. For encryption, c = me mod n, where m = original message. 7. For ... Read More