Data Structure Articles

Page 7 of 164

Sum of Array maximums after K operations by reducing max element to its half

Satvik Watts
Satvik Watts
Updated on 01-Nov-2023 397 Views

In this article, we will calculate the sum of the array maximums after K operations in which we reduce the maximum value of the array to its half. In the first approach, we will implement the brute force solution to this problem. In each iteration, we will use a for loop to find the maximum element in the array. We will then add this element to our answer, then we will reduce the element to its half. We will do this for K iterations as requested. Then, we will return the answer. In the second approach, we will use a ...

Read More

Sort a given array which is already sorted based on the absolute value of the element

Satvik Watts
Satvik Watts
Updated on 01-Nov-2023 388 Views

In this article, we will sort the given array. The given array is already sorted on the basis of absolute value of the elements, we just need to sort the array based on the true values of the elements. In the first approach, we will use a sorting algorithm, like merge sort, bubble sort, insertion sort, quicksort and so on. In this example, we will use the inbuilt sort function to sort our array. In the second approach, we will use a double ended queue. We will push the positive elements in front of the double ended queue, and we ...

Read More

Shortest path between two points in a Matrix with at most K obstacles

Satvik Watts
Satvik Watts
Updated on 01-Nov-2023 312 Views

In this article, we will find the shortest path between two points in a matrix. The matrix contains two types of cells, empty cells and cells which have obstacles. We are given an integer K, which represents that we can remove at most K obstacles to reach our destination. In the approach discussed in this article, we will do a breadth first search (BFS) on the matrix to find the shortest path. We will use a queue data structure, which will store a vector of integers. The vector will have 3 integers, the x coordinate, the y coordinate and the ...

Read More

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

Satvik Watts
Satvik Watts
Updated on 01-Nov-2023 221 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
Satvik Watts
Updated on 01-Nov-2023 275 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
Satvik Watts
Updated on 01-Nov-2023 222 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
Satvik Watts
Updated on 01-Nov-2023 374 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
Satvik Watts
Updated on 01-Nov-2023 184 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

Minimize count of alternating subsequences to divide a given Binary String with subsequence number

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 31-Oct-2023 330 Views

The aim of this article is to implement a program Minimize count of alternating subsequences to divide a given binary string with subsequence number. Here, you are provided with a binary string as part of the issue. In order to prevent any subsequence from including adjacent zeros and ones, we must reduce the number of subsequences and output the subsequence number that corresponds to each string element. A subsequence represents a sequence which can be created by taking the supplied sequence and eliminating zero or more members while maintaining the initial position of the elements that remain. Input Let ...

Read More

What are the functionalities of data mining?

Ginni
Ginni
Updated on 31-Oct-2023 74K+ Views

Data mining functionalities are used to represent the type of patterns that have to be discovered in data mining tasks. In general, data mining tasks can be classified into two types including descriptive and predictive. Descriptive mining tasks define the common features of the data in the database and the predictive mining tasks act inference on the current information to develop predictions.There are various data mining functionalities which are as follows −Data characterization − It is a summarization of the general characteristics of an object class of data. The data corresponding to the user-specified class is generally collected by a ...

Read More
Showing 61–70 of 1,635 articles
« Prev 1 5 6 7 8 9 164 Next »
Advertisements