Arnab Chakraborty has Published 3734 Articles

Program to check whether list can be split into sublists of k increasing elements in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:31:20

181 Views

Suppose we have a list of numbers called nums, and another number k, we have to check whether the list can be split into lists where each list contains k values and the values are consecutively increasing.So, if the input is like nums = [4, 3, 2, 4, 5, 6], ... Read More

Program to create linked list to binary search tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:24:02

1K+ Views

Suppose we have a sorted linked list node of size n, we have to create a binary search tree by Taking the value of the k = floor of (n / 2) the smallest setting it as the root. Then recursively constructing the left subtree using the linked list left ... Read More

Program to find tree level that has minimum sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:18:23

327 Views

Suppose we have a binary tree, the level of its root is 1, the level of its children is 2, and so on.We have to find the smallest level X such that the sum of all the values of nodes at level X is minimum. So if the tree is ... Read More

Program to perform level order traversal of binary tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:10:22

303 Views

Suppose we have a binary tree. We have to traverse this tree using level order traversal fashion. So if the tree is likeThe traversal sequence will be like: [1, 2, 3, 5, 4]To solve this, we will follow these steps −define queue que to store nodesinsert root into the que.while ... Read More

Program to convert level order binary tree traversal to linked list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:02:09

450 Views

Suppose we have a binary search tree, we have to convert it to a singly linked list using levelorder traversal.So, if the input is likethen the output will be [5, 4, 10, 2, 7, 15, ]To solve this, we will follow these steps −head := a new linked list nodecurrNode ... Read More

Program to traverse binary tree level wise in alternating way in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 10:54:23

172 Views

Suppose we have binary tree, we have to show the values of each level by alternating from going left-to-right and right-to-left.So, if the input is likethen the output will be [5, -10, 4, -2, -7, 15]To solve this, we will follow these steps −if root is null, thenreturn a new ... Read More

Program to find length of longest balanced subsequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 10:47:50

428 Views

Suppose we have a string s containing brackets parenthesis "(" and ")", we have to find the length of the longest subsequence of balanced brackets.So, if the input is like s = "())(()(", then the output will be 4, as we can take the subsequence like "()()"To solve this, we ... Read More

Program to find the left side view of a binary tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 10:43:56

141 Views

Suppose we have a binary tree, if we see the tree from left side, then we can see some elements of it. we have to display those elements. So if the tree is like −The output will be [1, 2, 5]To solve this, we will follow these steps −Define an ... Read More

Program to find leftmost deepest node of a tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 10:34:00

419 Views

Suppose we have a binary tree; we have to find the value of the deepest node. If there are more than one deepest node, then return the leftmost deepest node.So, if the input is likethen the output will be 4 as 4 and 7 are deepest but 4 is left ... Read More

Program to check whether we can fill square where each row and column will hold distinct elements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 15:39:48

138 Views

Suppose we have one n × n matrix containing values from 0 to n. Here 0 represents an unfilled square, we have to check whether we can fill empty squares such that in each row and each column every number from 1 to n appears exactly once.So, if the input ... Read More

Advertisements