Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 2093 of 2109
C++ Program to Implement Levenshtein Distance Computing Algorithm
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 MoreAny datatype in C++ boost library
The boost library has large range of functionalities. The any datatype is one of them. Any datatype is used to store any type of values in variable. Some other languages like javascripts, python, we can get this kind of datatypes. In C++ we can get this feature only using boost library.Example#include "boost/any.hpp" #include using namespace std; main() { boost::any x, y, z, a; //define some variable of any datatype x = 20; //Store x as integer cout >> "x : " >> boost::any_cast(x) >> endl; //display the value of x y = 'A'; //Store y ...
Read MoreC++ Program to Find Second Smallest of n Elements with Given Complexity Constraint
This is a C++ program to find Second Smallest of n elements with given complexity constraint.AlgorithmBegin function SecondSmallest() : /* Arguments to this function are: A pointer array a. Number of elements n */ // Body of the function: A variable s1 is declared as to keep track of smallest number. A variable s2 is declared as to keep track of second smallest number. Initialize both s1 and s2 with INT_MAX. Traverse ...
Read MoreC++ Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers
This is a C++ Program to find k numbers closest to Median of S, where S is a set of n numbers.AlgorithmsBegin function partition() for partitioning the array on the basis of values at high as pivot value: Arguments: a[]=an array. l=low H=high Body of the function: Declare variables pivot, in, i Initialize in = l Set pivot = h For i=l to h-1 if(a[i] < a[pivot]) swap a[i] and a[in]) increment in. ...
Read MoreC++ Program to Find ith Largest Number from a Given List Using Order-Statistic Algorithm
This is a C++ program to find ith largest number from a given list using Order-Statistic Algorithm.AlgorithmsBegin function Insert() to insert nodes into the tree: Arguments: root, d. Body of the function: If tree is completely null then insert new node as root. If d = tmp->data, increase the count of that particular node. If d < tmp->data, move the tmp pointer to the left child. If d > tmp->data, move the tmp pointer to the right child. End Begin ...
Read MoreC++ Program to Find the Mode in a Data Set
This is a C++ program to find the Mode in a data set.AlgorithmsBegin function insertinset() to insert data in the set. Create newnode and temp(t) node. Node to be inserted in the list using newnode. If head is null then assign new node to head and increase the count. During insertion perform insertion sort for sorting data. If the newnode->data is equal to any of the element present in the set, then just increment count. EndExample#include using namespace std; struct set // a structure set to declare ...
Read MoreC++ Program to Generate All Possible Combinations of a Given List of Numbers
This is a C++ program to generate all possible combinations of a given list of numbersAlgorithmsBegin Take the number of elements and the elements as input. function Combi(char a[], int reqLen, int s, int currLen, bool check[], int l) : If currLen>reqLen then Return Else if currLen=reqLen then Then print the new generated sequence. If s=l then Then return no further element is left. For every index there are two option: either proceed with a start as ‘true’ and recursively call Combi() with incremented value of ...
Read MoreC++ Program to Generate All Possible Subsets with Exactly k Elements in Each Subset
This is a C++ program to generate all possible subsets with exactly k elements in each subset.AlgorithmsBegin function PossibleSubSet(char a[], int reqLen, int s, int currLen, bool check[], int l): If currLen > reqLen Return Else if currLen = reqLen Then print the new generated sequence. If s = l Then return no further element is left. For every index there are two options: either proceed with a start as ‘true’ and recursively call PossibleSubSet() with incremented value ...
Read MoreC++ Program to Generate Random Partition out of a Given Set of Numbers or Characters
This is a C++ program to generate Random Partition out of a given set of numbers or characters.AlgorithmBegin Take the integers or characters as input. For choice 1: Take the input of the n integer array. Assign l = 0 to traverse the array. Using rand(), generate random integer partition of n. For each partition i, print next i integer from index value l. For choice is 2: Take the input of a string in ch[]. Calculate the length ...
Read MoreC++ program to Solve Tower of Hanoi Problem using Binary Value
This C++ program displays the solution to the Tower of Hanoi problem using binary value.There is one binary digit for each disk.The most significant bit represents the largest disk. A value of 0 indicates that the largest disk is on the initial peg, while a 1 indicates that it’s on the final peg.The bitstring is read from left to right, and each bit can be used to determine the location of the corresponding disk.The corresponding disk is stacked on top the previous disk on the same peg if a bit has the same value as the previous one.If it is ...
Read More