Sunidhi Bansal has Published 1085 Articles

Construct Pushdown automata for L = {0(n+m)1m2n | m, n = 0} in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 07-Jan-2021 05:24:22

503 Views

We are given with a language “L” and the task is to construct a pushdown automata for the given language which explains that the occurrences of 0’s will be the addition of occurrences of 1’s and 2’s and also, occurrence of 1 and 2 will be minimum one which can ... Read More

Count the nodes in the given tree whose weight is a power of two in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 14:58:58

239 Views

Given a binary tree with weights of its nodes. The goal is to find the number of nodes that have weights such that the number is power of two. If weight is 32 then it is 25 so this node will be counted.For ExampleInputThe tree which will be created after ... Read More

Count the nodes whose weight is a perfect square in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 14:57:18

144 Views

Given a binary tree with weights of its nodes. The goal is to find the number of nodes that have weights such that the number is a perfect square. If weight is 36 then it is 62 so this node will be counted.For ExampleInputThe tree which will be created after ... Read More

Count the nodes of the tree whose weighted string contains a vowel in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 14:53:08

171 Views

Given a binary tree with weights of its nodes as strings. The goal is to find the number of nodes that have weights such that the string contains a vowel. If weight is ‘aer’ then it has vowels ‘a’ and ‘e’ so the node will be counted.For ExampleInputThe tree which ... Read More

Count the nodes in the given tree whose sum of digits of weight is odd in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:56:22

246 Views

Given a binary tree with weights of its nodes. The goal is to find the number of nodes that have weights such that the sum of digits in that weights add up to an odd number. If weight is 12 then the digit sum is 3 which is odd so ... Read More

Count subtrees that sum up to a given value x in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:39:31

330 Views

Given a binary tree and a value x as input. The goal is to find all the subtrees of a binary tree that have sum of weights of its nodes equal to x.For ExampleInputx = 14. The tree which will be created after inputting the values is given belowOutputCount of ... Read More

Count subarrays whose product is divisible by k in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:36:48

342 Views

Given an array arr[] and an integer k as input. The goal is to find the number of subarrays of arr[] such that the product of elements of that subarray is divisible by k.For ExampleInputarr[] = {2, 1, 5, 8} k=4OutputCount of sub-arrays whose product is divisible by k are: ... Read More

Count squares with odd side length in Chessboard in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:33:58

833 Views

Given a number size as input as dimension of size*size Chessboard. The goal is to find the number of squares that can be formed inside that board having odd lengths.For ExampleInputsize=3OutputCount of squares with odd side length in Chessboard are: 10ExplanationAll squares will be as shown : and 1 whole ... Read More

Count subsets that satisfy the given condition in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:32:05

403 Views

Given an array of numbers and an integer x as input. The goal is to find all the subsets of arr[] such that individual elements of that set as well as the sum of them fully divisible by x.For ExampleInputarr[] = {1, 2, 3, 4, 5, 6} x=3OutputCount of subsets ... Read More

Count the number of common divisors of the given strings in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 05-Jan-2021 13:30:22

293 Views

Given two strings numo and demo as input. The goal is to find the number of common divisors of both the strings. The divisors of a string are found using following technique: If string str has sub1 as its divisor then we can construct str using sub1 by repeating it ... Read More

Advertisements