Found 33676 Articles for Programming

Maximum count of pairs such that element at position i is included in a[i] pairs

Satvik Watts
Updated on 01-Nov-2023 12:40:29

154 Views

In this article, we will find the number of the pair of indices, such that an index i can be included in at most a[i] number of pairs. In the approach discussed in this article, we will use a priority queue data structure which will contain the elements of the array. The priority queue data structure will be a maximum heap which will allow us to get the current maximum elements of the array on log(N) time. It will also allow us to modify the elements and insert them back in, in the same amount of time. We will ... Read More

Maximum width of a Binary Tree with null values

Satvik Watts
Updated on 01-Nov-2023 12:34:52

196 Views

A binary tree is defined as a tree data structure where each has at most two children. The width of a binary tree for a level is defined as the number of nodes between the rightmost and leftmost nodes of that level, including the NULL nodes that come in between. The maximum width of a binary tree is defined as the maximum of all the widths at each level of the binary tree. In this first approach, we represent the binary tree as an array representation of the Heap data structure. At each level, the width of that level will ... Read More

Longest subsegment of 1’s formed by changing at most k 0’s (Using Queue)

Satvik Watts
Updated on 01-Nov-2023 12:30:09

152 Views

In this article, we will find the longest subsegment of 1’s which can be formed by changing at most k 0’s to 1’s. We will be using queue data structure to solve this problem. In the approach discussed in this article, we will use a queue data structure to find the longest subarray containing only 1’s, which can be formed by changing at most k 0’s into 1’s. The queue data structure will be used to store the indices of 0 elements that have occurred previously. Whenever we encounter a new 0, we will check the size of the queue. ... Read More

FIFO Push Relabel Algorithm

Satvik Watts
Updated on 01-Nov-2023 12:15:11

298 Views

The FIFO Push Relabel algorithm is an algorithm that is used to solve the maximum flow problem. The maximum flow problem is a problem in graph theory in which we have to find the maximum amount of flow of resources or information that can be sent via an interconnected network of components, like pipes, wires, etc. With constraints on how much capacity a single component can handle. In other words, we have a directed graph on N nodes. We are given a source node and a sink node. We also have M edges in the graph, each edge has a ... Read More

Count of pair of nodes at even distance (Using BFS)

Satvik Watts
Updated on 01-Nov-2023 11:56:06

125 Views

In this article, we will find the number of the pair of nodes, which are at an even distance of each other in a graph. We will be using the breadth first search (BFS) approach to find the total count. In the approach discussed in this article, we will use a queue data structure which will contain pair of integers. The queue data structure will allow us to go through the graph using the breadth first search algorithm (BFS). We will pick a random node and apply the breadth first search from that node. We will use two variables to ... Read More

Divide one Hermite series by another in Python using NumPy

Niharika Aitam
Updated on 02-Nov-2023 12:33:03

120 Views

The Hermite series is one of the mathematical techniques, which is used to represent the infinite series of Hermite polynomials. The Hermite polynomials referred as the sequence of orthogonal polynomials which are the solutions of the Hermite differential equation. Dividing one hermite series by another The Hermite series is given by the following equation. f(x) = Σn=0^∞ cn Hn(x) Where Hn(x) is the nth Hermite polynomial cn is the nth coefficient in the expansion. The coefficient cn can be determined by using the below formula: cn = (1/$\mathrm{\surd}$(2^n n!))$\mathrm{\lmoustache}$ f(x) Hn(x) e^(−x^2/2) dx Example ... Read More

Divide each row by a vector element using NumPy

Niharika Aitam
Updated on 02-Nov-2023 11:51:34

813 Views

We can divide each row of the Numpy array by a vector element. The vector element can be a single element, multiple elements or an array. After dividing the row of an array by a vector to generate the required functionality, we use the divisor (/) operator. The division of the rows can be into 1−d or 2−d or multiple arrays. There are different ways to perform the division of each row by a vector element. Let’s see each way in detail. Using broadcasting using divide() function Using apply_along_axis() function Using broadcasting Broadcasting is the method available ... Read More

Divide a DataFrame in a ratio

Niharika Aitam
Updated on 02-Nov-2023 12:01:30

912 Views

Pandas library is used to manipulate the data and analyze the data. The data will be created using the pandas library in two ways Dataframe and Series. A DataFrame is the two dimensional data structure containing the rows and columns. There different ways to divide the DataFrame data based on the ratio. Let’s see them one by one. Using np.random.rand() Using pandas.DataFrame.sample() Using numpy.split() Using numpy.random.rand() In the following example, we will divide the dataframe data into parts by defining the ratio using the randm.rand() function. If we want to divide the data in the percentage of ... Read More

Digital Low Pass Butterworth Filter in Python

Niharika Aitam
Updated on 02-Nov-2023 12:04:35

2K+ Views

The low pass filter is the electronic filter which passes the frequency of signals lesser than the defined cutoff frequency and the frequency of the signals higher than the cutoff will be attenuated. The High pass Butterworth filter has some specialized features defined as follows. The sampling rate of the given input signal is given as 40 kHz The edge frequency of the pass band is 4 kHz The edge frequency of the stop band is 8 kHz The ripple of the pass band is 0.5 dB The minimum attenuation of the stop band is 40 dB and the ... Read More

Digital High Pass Butterworth Filter in Python

Niharika Aitam
Updated on 02-Nov-2023 12:06:28

1K+ Views

The high pass filter is the electronic filter which passes the frequency of signals greater than the defined cutoff frequency and the frequency of the signals lower than the cutoff will be attenuated. The attenuation of each frequency is based on the filter design. The High pass Butterworth filter has some specialized features defined as follows. The sampling rate of the given input signal is given as 3.5 kHz The edge frequency of the pass band is 1050 Hz The edge frequency of the stop band is 600 Hz The ripple of the pass band is 1 dB The ... Read More

Advertisements