Found 34484 Articles for Programming

How Java filter() Method Works in Background?

Shriansh Kumar
Updated on 21-Jul-2023 19:52:32

213 Views

The Java filter() method allows us to strain elements of the stream based on the specified condition. It is a part of higher-order function that is used to apply a certain behavior on stream items. This method takes a predicate as an argument and returns a list of elements that match the predicate. But the question arises here is that how this filter() method works in the background. This article aims to explain this question through some example programs. Working of filter() method in Background Before going deep into the filter() method, let’s familiarize ourselves with I/O Streams. Itis an ... Read More

Replace every character of string by character whose ASCII value is K times more than it

Way2Class
Updated on 21-Jul-2023 17:56:36

441 Views

In the realm of C++ programming, it is possible to replace every character of a specified string with a symbol whose ASCII value is elevated by a factor of K compared to the original character. This can be accomplished through the implementation of a straightforward algorithmic technique. This piece delves into the syntax, the algorithm, and two distinct methods to address the problem, complete with code illustrations in C++. Syntax To substitute every character in a string with a character whose ASCII value is multiplied by K, the syntax is as follows − string replace(string str, int K); Here, ... Read More

Implement Multi Stack (K stacks) using only one Data Structure

Way2Class
Updated on 21-Jul-2023 17:54:03

1K+ Views

A dynamic multi-stack is a remarkable data structure that possesses the capacity to store elements in numerous stacks, with an ever-changing quantity of stacks. It can be a daunting task to implement K stacks utilizing only one data structure. In this instructional guide, we shall investigate two distinct techniques to execute dynamic multi-stack (K stacks) using C++. The initial technique employs an array to stock the elements, along with two additional arrays to monitor the topmost and following indices of the stacks. The secondary technique employs a vector of nodes to stock the elements, along with a vector to keep ... Read More

Percentile Rank of a Column in a Pandas DataFrame

Shriansh Kumar
Updated on 25-Jul-2023 12:19:36

2K+ Views

Finding the percentile rank is a common operation that is used for comparison between data of a single dataset. The end result of this operation shows a certain percentage is greater than or equal to the specified percentile. For instance, suppose a student obtains a score greater than or equal to 80% of all other scores. Then, the percentile rank of that student is 80th. To find the percentile rank of a column in a Pandas DataFrame, we can use the built-in methods named 'rank()' and 'percentile()' provided by Python. Python Program to find Percentile Rank of ... Read More

Highlight Pandas DataFrame's Specific Columns using Apply()

Shriansh Kumar
Updated on 21-Jul-2023 18:19:33

1K+ Views

While presenting or explaining some facts using Pandas DataFrame, we might need to highlight important rows and columns of the given data that help in making them more appealing, explainable and visually stunning. One way of highlighting the Pandas DataFrame's specific columns is by using the built-in method apply(). Python Program to Highlight Pandas DataFrame using apply() Before jumping to the example program directly, it is necessary to discuss the basics of Pandas and apply(). Pandas It is an open-source Python library that is mainly used for data analysis and manipulation. It can handle both relational ... Read More

Hierarchical Data in Pandas

Shriansh Kumar
Updated on 25-Jul-2023 12:21:50

2K+ Views

Hierarchical data is often used to represent multiple levels of nested groups or categories. For example, a company may have a hierarchy of employees, departments, and locations. A product may have a hierarchy of categories and subcategories. One of the challenges of working with hierarchical data is how to represent it in a tabular format which can make it easy to manipulate and analyze. In this article, we are going to present hierarchical data using Pandas' built-in methods like 'set_index()' and 'groupby()'. Python Program to Represent Hierarchical Data using Pandas First, let's briefly discuss Pandas and its ... Read More

Length of Longest Increasing Subsequences (LIS) using Segment Tree

Way2Class
Updated on 21-Jul-2023 17:45:08

285 Views

Segment Tree is a versatile data structure designed for answering range queries and performing updates on arrays in logarithmic time complexity, where each node stores information related to a specific range of elements in the array. In the context of the Longest Increasing Subsequence (LIS) problem, which requires determining the length of the longest subsequence of a given sequence in which the elements are sorted in increasing order, Segment Trees can be utilized to efficiently compute the Length of Longest Increasing Subsequences in an array. This approach significantly reduces the time complexity compared to traditional methods and has ... Read More

Classification of Algorithms with Examples

Way2Class
Updated on 21-Jul-2023 17:39:00

254 Views

Classification of algorithms helps in selecting the most suitable one for a specific task, enabling developers to optimize their code and achieve better performance. In computer science, algorithms are sets of well-defined instructions used to solve problems or perform specific tasks. The efficiency and effectiveness of these algorithms are crucial in determining the overall performance of a program. In this article, we will discuss two common approaches for classifying algorithms, namely, based on their time complexity and based on their design technique. Syntax The syntax of the main function used in the codes for both approaches − int ... Read More

Count K-length subarrays whose average exceeds the median of the given array

Way2Class
Updated on 21-Jul-2023 17:20:50

70 Views

The expression "K-length subarrays" pertains to successive subarrays having precisely K elements. Grasping and working with subarrays is crucial for resolving various issues in fields such as dynamic programming, computational geometry, and data analysis. Another vital concept in array manipulation and statistics is the median. The median of an array represents the middle value when the elements are sorted in ascending order. In the case of an even number of elements, the median is the average of the two central values. The median constitutes a durable measure of central tendency, as it is less vulnerable to extreme values or outliers ... Read More

Plot Multiple lines in Matplotlib

Shriansh Kumar
Updated on 21-Jul-2023 17:51:34

6K+ Views

Python provides a powerful library named Matplotlib that creates visual representations in the form of plots and graphs. One of the many features of this library is the ability to plot multiple lines in a single graph that are useful in comparing data sets or visualizing trends over time. We are going to explore the built-in method named 'plot()' that is used for plotting multiple lines in Python Matplotlib. Python Program to Plot Multiple lines in Matplotlib Before jumping to the program directly, let's familiarize ourselves with some basic concepts of Python that will help us ... Read More

Advertisements