
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

3K+ Views
To plot a pcolor colorbar in a different subplot in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots wuth two rows and two columns.Make a list of colormaps.Iterate the axes and create a pseudocolor plot with a non-regular rectangular grid.Make colorbars with the same axes of pcolormesh.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, axs = plt.subplots(2, 2) cm = ['plasma', 'copper'] for col ... Read More

4K+ Views
To plot a smooth 2D color plot for z = f(x, y) in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Get z data points using f(x, y).Display the data as an image, i.e., on a 2D regular raster, with z data points.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True def f(x, y): return np.array([i * i + j * j for j in ... Read More

1K+ Views
To display two sympy plots as one Matplotlib plot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Transform strings into instances of :class:'Symbol' class.Plot a function of a single variable as a curve.Use the extend method to add all the series of plot2 (p2) in plot1 (p1).To display the figure, use show() method.Examplefrom sympy import symbols from sympy.plotting import plot from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = symbols('x') p1 = plot(x*x, show=False) p2 = plot(x, show=False) p1.extend(p2) p1.show()OutputRead More

475 Views
We need to find a number of all the pairs that has the maximum sum, In a given array of integers. A pair consists of two numbers, and the sum is simply the result of adding them. We will see multiple solutions to this problem, starting with a naive (brute force) approach and moving to more optimized solutions. Below is the list of approaches we will cover in this article: Brute Force approach using two loops Max Sum Pairs with Sorting ... Read More

233 Views
Given an array, we have to find the number of pairs whose Bitwise OR is an odd number. Let's see the example.Inputarr = [1, 2]Output1 There is only one pair whose Bitwise OR is an odd number. And the pair is (1, 2).AlgorithmInitialise the array with random numbers.Initialise the count to 0.Write two loops to get the pairs of the array.Compute the bitwise OR between every pair.Increment the count if the result is an odd number.Return the count.ImplementationFollowing is the implementation of the above algorithm in C++#include using namespace std; int getOddPairsCount(int arr[], int n) { int count ... Read More

911 Views
Given an array, we have to find the number of pairs whose sum is a power of 2. Let's see the example.Inputarr = [1, 2, 3]Output1 There is only one pair whose sum is a power of 2. And the pair is (1, 3).AlgorithmInitialise array with random numbers.Initialise the count to 0.Write two loops to get all the pairs of the array.Compute the sum of every pair.Check whether the sum is a power of 2 or not using bitwise AND.Increment the count if the count is a power of 2.Return the count.ImplementationFollowing is the implementation of the above algorithm in ... Read More

189 Views
Given numbers N and K, we have to count the number of pairs whose sum is divisible by K. Let's see an example.InputN = 3 K = 2Output1 There is only one pair whose sum is divisible by K. And the pair is (1, 3).AlgorithmInitialise the N and K.Generate the natural numbers till N and store them in an array.Initialise the count to 0.Write two loops to get all pairs from the array.Compute the sum of every pair.If the pair sum is divisible by K, then increment the count.Return the count.ImplementationFollowing is the implementation of the above algorithm in C++#include ... Read More

189 Views
The line equation that should be satisfied is y = mx + c. Given an array, m, and c, we have to find the number of order points satisfying the line equation. Let's see an example.Inputarr = [1, 2, 3] m = 1 c = 1Output2The pairs satisfying the line equation are2 1 3 2AlgorithmInitialise the array, m, and c.Write two loops to get all pairs from the array.Check whether the pair is satisfying the line equation or not.We can check the whether the equation is satisfied or not by substituting the values into the line equation.If the pair satisfies ... Read More

224 Views
In this tutorial, we are going to write a program that finds the number non-negative integral solution of sum equation.The sum equation is x + y + z = n. You are given the number n, you need to find the number of solutions for the equation. Let's see an example.Input2Output6Solutions are0 0 2 0 1 1 0 2 0 1 0 1 1 1 0 2 0 0AlgorithmInitialise the number m.Initialise the count to 0.Write three nested loops to get all the combinations of three numbers.Check the validation of the equation.If the current numbers satisfies the equation, then increment ... Read More

370 Views
Given an n-ary tree and a number, we have to count the number of nodes greater than the given number. Let's see an example.Inputtree = [[4], [1, 2], [3, 5]] n = 2Output3There are 3 nodes with values that are greater than n.AlgorithmInitialise the n-ary tree.Initialise the count to 0.Increment the count by 1 when you find a node whose value is greater than n.Get the children of the current node.Iterate over all the children and recursively call the same function to count nodes.Return the count.ImplementationFollowing is the implementation of the above algorithm in C++#include using namespace std; struct ... Read More