- 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 7346 Articles for C++
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
264 Views
We are given a binary tree, and we need to replace all the elements with the sum of its inorder predecessor and successor. Inorder is a traversed path in a graph that reads in the order of left node – root node – right node. The method adds the elements in left and right nodes of the parent node and replaces the value with the obtained sum. Suppose we have a tree with the following formation and characters − We can find and store the inorder of the tree in an array. After that, we can again do an ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
197 Views
Given two integers N and k, we need to count the number of derangements where k points are fixed at their position. Given constraints on k are between 0 and n as the number of fixed points when there are n points cannot be more than n. int N=4, k=2; res = solve(N, k); Note that at least conditions don’t hold on k. There has to be precisely and strictly k points on their original index. This is a mathematical problem. Not explaining the proof and explanation of mathematics, we as computer science majors can use the results ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
136 Views
Suppose we are given a binary tree and three nodes in that binary. We have to disconnect one node entirely from the tree. Disconnecting that node leaves us with three different trees. Each of the three given nodes lies in one of them, or each of the given three nodes must not exist in the same tree. Disconnecting a node means that we will remove all the edges from this node to all other nodes. Example For example, let's say we have a tree with three nodes 18, 15, and 17 as shown below − If the task ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
4K+ Views
To search an element in a linked list, we must iterate through the complete list, compare each node with the desired data, and keep searching until a match is obtained. Because a Linked List does not provide random access, we must start the search from the first node. We are given a linked list of integers and an integer key. We need to find if this key exists in our linked list or not. We can do a simple linear search in the linked list and find the key. If present, we can return "Yes"; otherwise, "No" Let us look ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
1K+ Views
We are given two integer numerators and a denominator. We need to represent the fraction of these two integers in string format. If a certain decimal is repeating, we need a bracket to show its repeating sequence. Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Determine the integral quotient (absolute part before to the decimal point) before determining the fractional portion. Insert the remainder (numerator % denominator) in a map with the key being the remainder and the value being the index position at which this remainder occurs to see if ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
459 Views
We are given an array of elements. We need to find if it is possible to change the value of any one element to make the array elements consecutive. If not possible, return -1 ; otherwise, the element needs to be changed. Let's suppose we have an array {4, 3, 9, 5, 6} and we have to sort this given array. Then start from the smallest and largest element checking the number of mismatches. If the number of mismatches is more than 1 on both sides of the array, the answer is -1. Otherwise, it is possible to get the ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
763 Views
We are given a sorted array which is rotated about a point. We are also given a key to search in the array. The logic adopted to search for an element in this rotated array is − First, we find the middle element of the array. If the key is present, then we return that the key is present in the array. If the key is not present in the middle, we can see if the left part of the array(left to mid) is sorted or not. If sorted, we can search for the key in the left part ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
195 Views
Given a double circular linked list and key, we have to search the key in the linked list and give a proper message if found. Suppose we have a linked list with the specific characters, and we have to search for an element in it. So let's start with the following linked list − 5 8 9 2 4 We will use 4 as a key to finding the solution to the given problem. A double-linked list has no fixed head, so we will start from any node and then mark that node as ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
257 Views
An ordered collection of data elements, each with a link to its next element (and sometimes its predecessor), Suppose there is a linked list, then we need to find the second smallest element. The below are the following scenarios. Let’s assume some simple input and output scenarios Let’s assume this scenario that we are having a linked list contains elements in it are "8->4->6->2->9, ". Then after iterating entire linked list, the second smallest element will be 8. Input = 8->4->6->2->9 Output = 8 Programing way of implementing the linked list Node* head = new Node(8); head->next = new ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
259 Views
We are given an array of words, and we need to find the word whose frequency is the second largest in the array. Let’s assume some simple input and output scenarios Let’s assume we are having an array which consists of elements like [“point, ” “world, ” “articles, ” “articles, ” “articles, ” “world, ” “world, ” “world, ” “point”]. The frequency of words are − “point”: 2 “world”: 4 “articles”: 3 // This will be the second most repeated word in the array. So the second most repeated word is “articles, ” and our output is “articles.” Let’s ... Read More