Arnab Chakraborty has Published 4293 Articles

Binary Search (bisect) in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jul-2020 06:15:22

2K+ Views

Here we will see the bisect in Python. The bisect is used for binary search. The binary search technique is used to find elements in sorted list. The bisect is one library function.We will see three different task using bisect in Python.Finding first occurrence of an elementThe bisect.bisect_left(a, x, lo ... Read More

C/C++ Program for Odd-Even Sort (Brick Sort)?

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jul-2020 14:31:25

523 Views

Here we will see how the brick sort works. The Brick sort is one modification of bubble sort. This algorithm is divided into two parts. These parts are odd part and even parts. In the odd part we will use the bubble sort on odd indexed items, and in the ... Read More

Kruskal’s (Minimum Spanning Tree) MST Algorithm

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Jun-2020 19:45:15

1K+ Views

There is a connected graph G(V, E) and the weight or cost for every edge is given. Kruskal’s algorithm will find the minimum spanning tree using the graph and the cost.It is merge tree approach. Initially there are different trees, this algorithm will merge them by taking those edges whose ... Read More

Image Smoother in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Jun-2020 12:21:54

408 Views

Suppose we have a 2D matrix M representing the gray scale of an image, we have to design a smoother to make the gray scale of each pixel becomes the average gray scale (rounding down) of all the 8 surrounding pixels and itself. If a cell has less than 8 ... Read More

Robot Return to Origin in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Jun-2020 12:18:04

339 Views

Suppose there is a robot and its starting position is (0, 0). If we have a sequence of its movements, we have to check whether this robot ends up at (0, 0) after it completes its moves.The move sequence is given as a string, and the character moves[i] represents its ... Read More

Two Sum IV - Input is a BST in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Jun-2020 12:16:29

200 Views

Suppose we have a Binary Search Tree and one target value; we have to check whether there exist two elements in the BST such that their sum is equal to the given target or not.So, if the input is likethen the output will be True.To solve this, we will follow ... Read More

Set Mismatch in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Jun-2020 12:13:29

274 Views

Suppose there is a set S that is originally containing numbers from 1 to n. But unfortunately, due to some error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of one number and loss of another number.Now if we ... Read More

Maximum Average Subarray I in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Jun-2020 12:10:35

185 Views

Suppose we have an array with n elements, we have to find the contiguous subarray of given length k that has the maximum average value. We have to return the maximum average value.So, if the input is like [1, 13, -5, -8, 48, 3] and k = 4, then the ... Read More

Average of Levels in Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Jun-2020 12:09:13

204 Views

Suppose we have a non-empty binary tree; we have to find the average value of the nodes on each level in the return the average values as an array.So, if the input is likethen the output will be [3, 14.5, 11].To solve this, we will follow these steps −Define an ... Read More

Sum of Square Numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Jun-2020 12:05:53

1K+ Views

Suppose we have a non-negative integer c, we have to decide whether there're two integers a and b such that it satisfies a^2 + b^2 = c.So, if the input is like 61, then the output will be True, as 61 = 5^2 + 6^2.To solve this, we will follow ... Read More

Advertisements