Server Side Programming Articles

Page 1402 of 2109

Convert a given Binary tree to a tree that holds Logical AND property on C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 208 Views

In this tutorial, we will be discussing a program to convert a given Binary tree to a tree that holds Logical AND property.For this we will be provided with a binary tree. Our task is to convert it into a tree that holds the logical AND property means that a node has a value of the AND operation of its children nodes. Note that every node can have a value either zero or one.Example#include using namespace std; //node structure of binary tree struct Node{    int data;    struct Node* left;    struct Node* right; }; //creation of a new ...

Read More

Convert a given Binary Tree to Doubly Linked List (Set 1) in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 280 Views

In this tutorial, we will be discussing a program to convert a binary tree to a doubly linked list.For this we will be provided with a binary tree. Our task is to convert it into a doubly linked list such that the left and right pointers become the previous and next pointers. Also the sequential order of the doubly linked list must be equal to the inorder traversal of the binary tree.For this we are having a very straight forward approach. We will be traversing the binary tree in in order way making the nodes of the doubly linked list ...

Read More

Convert a given Binary Tree to Doubly Linked List (Set 2) in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 213 Views

In this tutorial, we will be discussing a program to convert a binary tree to a doubly linked list.For this we will be provided with a binary tree. Our task is to convert it into a doubly linked list such that the left and right pointers become the previous and next pointers. Also the sequential order of the doubly linked list must be equal to the inorder traversal of the binary tree.For this we are having a different approach. We will be traversing the binary tree in reverse inorder way. Along with we will be creating new nodes and moving ...

Read More

Convert a normal BST to Balanced BST in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 303 Views

In this tutorial, we will be discussing a program to convert a normal binary search tree to balanced binary search tree.For this we will be provided with a skewed binary search tree either left or right. Our task is to convert it into a balanced binary search tree following a certain set of rules.Example#include using namespace std; //node structure of tree struct Node{    int data;    Node* left, *right; }; //traversing tree and storing node pointers //in vector nodes void store_nodes(Node* root, vector &nodes){    if (root==NULL)       return;    store_nodes(root->left, nodes);    nodes.push_back(root);    store_nodes(root->right, ...

Read More

Convert a number into negative base representation in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 369 Views

In this tutorial, we will be discussing a program to convert a number into its negative base representation.For this we will be provided with a number and the corresponding negative base. Our task is to convert the given number into its negative base equivalent. We are allowing only values between -2 and -10 for negative base values.Example#include using namespace std; //converting integer into string string convert_str(int n){    string str;    stringstream ss;    ss > str;    return str; } //converting n to negative base string convert_nb(int n, int negBase){    //negative base equivalent for zero is zero ...

Read More

Convert a number m to n using minimum number of given operations in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 874 Views

In this tutorial, we will be discussing a program to convert a number m to n using minimum number of given operations.For this we will be provided with two integers m and n. Our task is to convert the integer m to n using the given operations least times.Allowed operations −Multiply the given number by 2Subtract one from the given numberExample#include using namespace std; //finding minimum number of operations required int convert(int m, int n){    if (m == n)       return 0;    if (m > n)    return m - n;    //can't convert in ...

Read More

Convert a sentence into its equivalent mobile numeric keypad sequence in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 780 Views

In this tutorial, we will be discussing a program to convert a sentence into its equivalent mobile numeric keypad sequence.For this we will be provided with a string of alphabetical characters. Our task is to print the numeric equivalent of the string i.e the numerical sequence of the keys to type that particular string.Example#include using namespace std; //computing the numerical sequence string calc_sequence(string arr[], string input){    string output = "";    //length of input string    int n = input.length();    for (int i=0; i

Read More

Convert a number of length N such that it contains any one digit at least 'K' times in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 170 Views

In this tutorial, we will be discussing a program to convert a number of length N such that it contains any one digit at least ‘K’ times.For this we will be provided with a number of given length N. Our task is to convert the digits in the given number such that any one digit gets repeated at least ‘K’ times. Also, you have to calculate the cost of this operation which is the absolute difference between the two and finally print the minimum cost.Example#include using namespace std; //calculating the minimum value and final number int get_final(int n, int ...

Read More

Convert a String into a square matrix grid of characters in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 448 Views

In this tutorial, we will be discussing a program to convert a string into a square matrix grid of characters.For this we will be provided with a string of characters. Our task is to print that particular string in the format of a matrix grid having a certain number of rows and columns.Example#include using namespace std; //converting the string in grid format void convert_grid(string str){    int l = str.length();    int k = 0, row, column;    row = floor(sqrt(l));    column = ceil(sqrt(l));    if (row * column < l)       row = column;   ...

Read More

Convert a string to hexadecimal ASCII values in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 3K+ Views

In this tutorial, we will be discussing a program to convert a string to hexadecimal ASCII values.For this we will be provided with a string of characters. Our task is to print that particular given string into its hexadecimal equivalent.Example#include #include //converting string to hexadecimal void convert_hexa(char* input, char* output){    int loop=0;    int i=0;    while(input[loop] != '\0'){       sprintf((char*)(output+i), "%02X", input[loop]);       loop+=1;       i+=2;    }    //marking the end of the string    output[i++] = '\0'; } int main(){    char ascii_str[] = "tutorials point";    int ...

Read More
Showing 14011–14020 of 21,090 articles
Advertisements