- 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++
339 Views
Isomorphism is defined as two trees either having identical or mirror structures. In the case of mirror structure, the left node data will always match the right node. For example, we will take a number nearest to the mirror and see what its reverse would be, that is the real concept of isomorphism. In this article, we are going to check whether two different binary trees are isomorphic or not. Let’s take an example of Isomorphism in N-ary Trees − Note that, L represents as left node whereas R represents as Right node Mirror structure of P and Q ... Read More
201 Views
The sequence of bytes is called a binary string and it holds the binary value. A binary score is normally presented on a range from 0 to 1 where 1 is reserved for the perfect model. In the given binary string, If the element is found to be 1 then it will calculate as the score and increment the count sum. Let’s take an example of a binary score − The given binary string is 1011010. In the above figure, the number 1 is present in the index- 0, 2, 3, and 5. Therefore, the total score is 4 ... Read More
232 Views
In C++, we have predefined function max() that will be used for finding any longest substring that does contain any palindrome. A palindrome string is a group of characters that remains the same even after reversing. Let’s take an example of a palindrome string to make the longest non-palindrome substring. The string malayalam itself is a palindrome but we need to identify the longest non-palindrome substring. When we change the string malayalam( length=9 ) to alayalam then we get the longest non-palindrome substring length i.e, 8. The string synapse is a non-palindrome string and its length is 7. ... Read More
543 Views
In C++ we have an inbuild reverse() function that will be used for reversing the substring to check whether a string can be made lexicographically smaller or not. Lexicographic ordering is the process by which the character of a word is sorted in a dictionary. Let’s take an example of a string to check lexicographically smaller or not. We will compare the two words to check the lexicographically smaller ones and take two strings namely ‘apple’ and ‘army’. Both these strings of the first letter starting with letter ‘a’. When we move to check the second character of both ... Read More
250 Views
This article will help us understand how to replace the consecutive consonant sequence with its length in the given string. Consonants are series of alphabetical letters that are not vowels. Here we need to first identify which letter in the string are consonants. For example, in the word “abcdiopqrsu”, the consonant sequence “bcd” and “pqrs”. Next, we would replace each consonant sequence with its length. So the word “bcd” would replace with “3” because there are three consecutive consonants, and the same with the word “pqrs” replace with “4” as there are four consecutive consonants. Algorithm First, we ... Read More
424 Views
A group of four positive integers (a, b, c, and d) that satisfy the Pythagorean equation are called Pythagorean quadruples. The equation can be written as: a2 + b2 + c2 = d2 , with ‘d’ being the largest value out of the given numbers. In other words, the square of the fourth integer should be equal to the sum obtained by adding the squares of the previous three numbers. (1, 2, 2, 3) is a Pythagorean quadruplet as (12 + 22 + 22) = (1 + 4 + 4) = (9) = (32). Due to the requirement ... Read More
179 Views
A number is considered to be a “Selfie Number” if it can be represented using only its own digits and certain mathematical operations. For example, 936 is a selfie number. $$\mathrm{936\:=\:(\sqrt{9})!^{3} \:+\:6!\:=\:216\:+\:720\:=\:936}$$ Here it can be observed that a series of operations are performed on the digits of the original number and the resultant is equal to the original number. Palindromic Selfie Numbers are a special kind of selfie number. They satisfy the selfie multiplicative rule. Consider a number x. Let the number formed by reversing the digits of x be $\mathrm{x^\prime}$. Let y be a ... Read More
998 Views
In the following article, we discuss two approaches to find the closest numbers from a list of unsorted integers. Let us first understand what is meant by the term ‘closest numbers’. Closest numbers are the pair(s) of numbers which have the least difference between them. Problem Statement Given a list of distinct unsorted integers, we need to find the pair of elements that have the least difference between them. If there are multiple pairs, we need to find all of them. Furthermore, in the article wherever there is a mention of difference, it means absolute difference. Examples Input: [44, 42, ... Read More
836 Views
Linked List A linked list is a linear data structure in which the elements are stored at non-contiguous memory locations. Each element consists of a node. A node is composed of a data field, which holds the value of the element, and an address field, which points to the location of the next node in the series. The first node of the linked list is referred to as the ‘head’ of the list. The last element of the linked list can be defined as the element which points to NULL. A diagrammatic representation of a linked list is shown below. ... Read More
400 Views
Munchhausen Numbers are peculiar numbers which possess a unique property. A number is considered to be munchhausen if the sum of the digits of the number, raised to their own power, is equal to the original number. These numbers are uncommon and not many of them are known. If the definition 00 = 0 is used, then 0 can also be considered a munchhausen number. The following article provides a method to determine whether a number is munchhausen or not while keeping in mind these characteristics of munchhausen numbers. Problem Statement The task at hand is to check whether a ... Read More