Prateek Jangid has Published 165 Articles

C++ program to remove row or column wise duplicates from matrix of characters

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 12:18:34

572 Views

We are given a 2D matrix with rows and columns. The matrix consists of elements in char data type. A method is devised to remove the elements which are duplicated in their respective rows or columns. In this method, we check if any element is repeating in its row or ... Read More

Finding the second largest element in BST using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 12:03:40

829 Views

In a binary search tree (BST), the second largest element must be returned. In a binary tree, the second element is the largest element. According to the given BST, 13 is the second largest element. Now we are using the C++ approach to solve this problem. We can traverse ... Read More

C++ program to find the shortest distance between two nodes in BST

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 12:02:23

894 Views

In this article, we are given a BST (binary search tree), and we need to find the shortest distance between 2 given nodes in the BST. Let's have a tree and below are the following scenarios. Let’s assume some simple input and output scenarios Now we have to find ... Read More

C++ program to Replace a Node with Depth in a Binary Tree

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 11:58:31

419 Views

Suppose we have a binary tree and we want to replace the depth of each node with its value. The depth of the node starts from 0 at the root node and increases by 1 for each level we go; for example, we have a binary tree like this; ... Read More

Replace Each Node in Binary Tree With The Sum Of Its Inorder Predecessor And Successor Using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 11:54:27

415 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 ... Read More

Rencontres Number (Counting partial derangements) Using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 11:50:50

382 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; ... Read More

Remove Edges Connected to a Node Such That The Three Given Nodes are in Different Trees Using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 11:48:01

233 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 ... Read More

C++ program to represent the Fraction of Two Numbers in the String Format

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 10:04:34

2K+ 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 ... Read More

C++ program to replace an element makes array elements consecutive

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 10:01:57

657 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, ... Read More

Searching an Element in Doubly Circular Linked List using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:56:26

327 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 ... Read More

Advertisements