Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2186 of 3366
124 Views
In this tutorial, we will be discussing a program to convert a BST to a binary tree such that the sum of all greater keys is added to every key.For this, we will be provided with a Binary Search tree. Our task is to convert that tree into a binary tree with the sum of all greater keys added to the current key. This will be done by the reverse in order of the given BST along with having the sum of all the previous elements and finally adding it to the current element.Example Live Demo#include using namespace std; //node ... Read More
461 Views
In this tutorial, we will be discussing a program to convert a binary tree to a threaded binary tree using a queue data structure.For this, we will be provided with a binary tree. Our task is to convert that particular binary tree into a threaded binary tree by adding additional routes for quicker inorder traversal with the help of a queue data structure.Example Live Demo#include #include using namespace std; //node structure for threaded tree struct Node { int key; Node *left, *right; bool isThreaded; }; //putting the inorder pattern into a queue void convert_queue(Node* root, std::queue* ... Read More
155 Views
In this tutorial, we will be discussing a program to convert a binary tree to a circular doubly linked list.For this, we will be provided with a binary tree. Our task will be to convert the left and right nodes to the left and right elements respectively. And take the inorder of the binary tree to be the sequence order of the circular linked listExample Live Demo#include using namespace std; //node structure of the binary tree struct Node{ struct Node *left, *right; int data; }; //appending rightlist to the end of leftlist Node *concatenate(Node *leftList, Node *rightList){ //if ... Read More
159 Views
In this tutorial, we will be discussing a program to convert a binary tree such that every node stores the sum of all nodes in its right subtree.For this, we will be provided with a binary tree. Our task is to return another tree where every node must be equal to the sum of the node and its right subtree.Example Live Demo#include using namespace std; //node structure of tree struct Node { int data; Node *left, *right; }; //creation of a new node struct Node* createNode(int item){ Node* temp = new Node; temp->data = item; ... Read More
186 Views
In this tutorial, we will be discussing a program to convert a binary tree into its mirror tree.For this, we will be provided with a binary tree. Our task will be to swap the values on the left and the right end creating a mirror tree from the given binary tree.Example Live Demo#include using namespace std; //binary tree node structure struct Node{ int data; struct Node* left; struct Node* right; }; //creation of a new node with no child nodes struct Node* newNode(int data){ struct Node* node = (struct Node*)malloc(sizeof(struct Node)); node->data = data; node->left ... Read More
415 Views
In this tutorial, we will be discussing a program to print the last N lines.For this, we will be provided with a string that consists of the new line character to denote the start of the next line and the number of lines to be printed from the last. Our task is to start from the last and print all the N lines counting from the last.Example#include using namespace std; #define DELIM '' //printing the last N lines void print_last_lines(char *str, int n){ if (n
224 Views
In this tutorial, we will be discussing a program to print the last 10 lines.For this, we will be provided with a string that consists of the new line character to denote the start of the next line. Our task is to start from the last and print all the 10 lines counting from the last.Example#include using namespace std; #define DELIM '' //printing the last 10 lines void print_last_lines(char *str, int n){ if (n
961 Views
In this tutorial, we will be discussing a program to print the given Kite pattern.For this, we will be taking the input as N=5. Our task is to print the given Kite structure with the overall height of 2N+1 = 5. This includes 9 lines for the upper diamond structure and 2 for the lower incomplete diamond structure.Example Live Demo#include #include using namespace std; int main(){ int i, j, k, sp, space = 4; char prt = '$'; //printing the upper half of the first diamond for (i = 1; i = 1; sp--){ cout
409 Views
In this tutorial, we will be discussing a program to print given inverse diamond pattern.For this, we will be provided with the value of N. Our task is to print an inverse the diamond pattern according to the height of 2N-1.Example Live Demo#include using namespace std; //printing the inverse diamond pattern void printDiamond(int n){ cout
270 Views
In this tutorial, we will be discussing a program to print a given interesting pattern.For this, we will be provided with the half-width of the pattern. Our task is to print a similar pattern according to the given width with its left and right portions being mirror images of one another.Example Live Demo#include //printing the given pattern void print_pattern(int n){ int i,j; //printing the upper half for (i=1; i