Maximum length cycle that can be formed by joining two nodes of a binary tree in C++

Sunidhi Bansal
Published on 03-Aug-2020 13:31:22
We are given a binary tree. The goal is to find the maximum length cycle in the given tree. We will do this by finding the maximum height of the left subtree and right subtree from the root node and will join these maximum length paths to get the longest ... Read More

Construct Tree from given Inorder and Preorder traversals in C++

Sunidhi Bansal
Published on 03-Aug-2020 13:27:37
We are given the Inorder and Preorder traversals of a binary tree. The goal is to construct a tree from given traversals.Inorder traversal − In this type of tree traversal, a left subtree is visited first, followed by the node and right subtree in the end.Inorder (tree root)Traverse left subtree ... Read More

Continuous Tree in C++

Sunidhi Bansal
Published on 03-Aug-2020 13:22:26
A Continuous Tree is defined as a tree with any path from root node to leaf node has value or weight of nodes such that the absolute difference between the parent node and all of its direct children nodes is always 1.If we pick any node on the path from ... Read More

Count Derangements (Permutation such that no element appears in its original position) in C++

Sunidhi Bansal
Published on 03-Aug-2020 13:20:08
Derangement is permutation of N numbers such that no number appears at original position. For example one possible derangement of { 1, 2, 3 } is { 2, 1, 3 }. No element in this is at its original position. The goal here is to count the possible derangements for ... Read More

Content Management Systems An Overview

Sunidhi Bansal
Published on 03-Aug-2020 13:16:40
If we go by the term Content Management System word to word, then it basically means a system of managing the content. It is defined as a collaborative platform with different features and functionalities that allow the creating, designing, publishing and maintaining web content easily and effectivelWhat is a Content ... Read More

Maximum length of balanced string after swapping and removal of characters in C++

Sunidhi Bansal
Published on 03-Aug-2020 13:14:02
We are given a string containing (, ), {, }, [, ] characters only. The goal is to find the maximum length of such string so that it becomes balanced by swapping adjacent characters or removing a character. We will do this by comparing adjacent characters, if they are opposite ... Read More

Maximum litres of water that can be bought with N Rupees in C++

Sunidhi Bansal
Published on 03-Aug-2020 13:11:43
We are given N rupees. The goal is to buy maximum water possible with the money where the rates of water bottles are as follows −Plastic Bottles: A Rupees for 1 litreGlass Bottles: B Rupees for 1 litreGlass Bottles: B Rupees for 1 litreNow the original cost of glass bottles ... Read More

Maximum in an array that can make another array sorted in C++

Sunidhi Bansal
Published on 03-Aug-2020 13:08:56
We are given an array of numbers say Arr1[] and another array Arr2[] of same or different length. The Arr1[] has elements sorted in ascending order, such that a single element is unsorted. We must find the element from the second array Arr2[] such that it can replace the wrongly ... Read More

Construct Turing machine for L = {an bm a(n+m) - n,m≥1} in C++

Sunidhi Bansal
Published on 03-Aug-2020 13:01:06
Turing Machine − A Turing machine is a device used to accept words of a language generated by type 0 grammars. A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which input is given. It consists of a head which ... Read More

Count Magic squares in a grid in C++

Sunidhi Bansal
Published on 03-Aug-2020 12:57:57
We are given with a matrix of numbers. The goal is to find the number of Magic squares present inside the given matrix.A Magic Square, if taken as a matrix, is a 3X3 matrix which contains the elements ranging from 1 to 9 just like a grid in Sudoku. Properties ... Read More
Advertisements