Found 33676 Articles for Programming

Finding the shortest path between any two nodes using Floyd Warshall Algorithm

Tapas Kumar Ghosh
Updated on 10-May-2023 12:17:36

1K+ Views

C++ has a macro which is defined as a piece of code or desired value and it will use repetitively again and again whenever the user wants. The Floyd Warshall Algorithm is the process of finding the shortest path between all pairs of vertices in a given weighted graph. This algorithm follows the dynamic programming approach to find the minimal weightage graph. Let us understand what is Floyd Warshall Algorithm with the help of diagrams − Take vertex 1 as the source and vertex 4 as the destination and find the shortest path between them. We have seen that ... Read More

Minimum cost of reducing Array by merging any adjacent element repetitively

Tapas Kumar Ghosh
Updated on 10-May-2023 11:47:41

475 Views

In C++ we have a pop() function to remove the element from the beginning. The top() function returns the reference of the first element of the priority_queue whereas the push() function is used to insert an element on it. A priority queue is a part of the data structure that manages elements based on their values. In this article, we will learn the minimum cost of reducing an array by merging any adjacent element repetitively. Let's take an example from this article − We will draw the array of size 4 and add the adjacent element repetitively. Syntax The ... Read More

String Range Queries to count number of distinct character with updates

Tapas Kumar Ghosh
Updated on 10-May-2023 11:34:14

371 Views

A string range query is the range of characters present in the string where a character starts from the index[0] and the last index[] may be specified according to the length of a given string. In this article, we are going to learn how string range queries count the number of distinct characters with their updates. Let’s take an example of counting the number of distinct characters of a string with its update. string = “tutorialpoint” // original string The given string is the length of 12. So the count is 13(counting always starts from 1). If we ... Read More

Number of times an array can be partitioned repetitively into subarrays with equal sum

Tapas Kumar Ghosh
Updated on 10-May-2023 11:28:56

192 Views

In C++ we have a vector header file that can change the size of an array during runtime. In this article, we are going to learn the concept of the number of times an array can be partitioned repetitively into subarrays with equal sum. Let’s take an example to show an array partition with an equal sum. The given array is {1, 2, 3, 4, 2} and we are subdividing the array into two parts − {1, 2, 3}- The total sum of each index of an array is 6. {4, 2}- The total sum of each index of an ... Read More

Sum of minimum element at each depth of a given non cycle graph

Tapas Kumar Ghosh
Updated on 10-May-2023 11:23:05

163 Views

A graph that does not contain any cycles or loops is called a non-cycle graph. A tree is a non-cycle graph in which every node is joined to another unique node. A non-cycle graph is also known as an acyclic graph. Difference between cycle graph and non-cycle graph − Cycle Graph Non-Cycle graph The graph forms a closed loop. The graph doesn’t form a closed loop. The graph doesn’t contain a depth loop The graph contains each depth. Example 1 let’s take an example of a cycle graph − A Cycle ... Read More

Find the size of a Dictionary in Python

Atharva Shah
Updated on 09-May-2023 15:00:03

7K+ Views

Working with Python dictionaries, a powerful data type, necessitates an understanding of their size and memory requirements. Assuming you're working with word references in Python, you might have to decide their size to allot adequate memory or perform explicit activities. Fortunately, the size of a dictionary can be determined with the help of Python's built-in len() function. A quick and simple way to gauge the dictionary's contents is to use this function, which returns the total number of key-value pairs in the dictionary. Nonetheless, remember that the size of a word reference can differ contingent upon the quantity of sections ... Read More

Find the siblings of tags using BeautifulSoup

Atharva Shah
Updated on 09-May-2023 17:11:13

1K+ Views

Data may be extracted from websites using the useful method known as web scraping and a popular Python package for web scraping is BeautifulSoup which offers a simple method for parsing HTML and XML documents, enabling us to extract certain data from web sites. Finding the siblings of a tag is a frequent task while scraping web pages and it can be defined as a tag's siblings are any additional tags that have the same parent as the primary tag. We will go through using BeautifulSoup to locate tags' siblings in this blog article. Installation and Setup To use ... Read More

Find the roots of the polynomials using NumPy

Atharva Shah
Updated on 09-May-2023 14:58:00

4K+ Views

Finding the roots of polynomials is an essential operation in mathematics, and NumPy provides an easy and efficient way to accomplish this task. NumPy is a powerful library for scientific computing in Python, and its functions for polynomial manipulation are especially useful. Syntax The NumPy library has a function named roots() that can be used to find the roots of a polynomial. numpy.roots(p) where p is the polynomial coefficients represented as a 1D array or sequence. The function returns an array of the roots of the polynomial. Algorithm With NumPy, finding a polynomial's roots is a rather straightforward process ... Read More

Find the profit and loss percent in the given Excel sheet using Pandas

Atharva Shah
Updated on 09-May-2023 14:57:03

468 Views

Profit and loss percent is an important financial metric that helps in analyzing the profitability of a business. It is calculated by finding the difference between the total revenue and total cost, and then dividing that value by the total cost. In this technical blog, we will learn how to find the profit and loss percent in a given Excel sheet using Pandas. We will be using the same Excel sheet that we used in our previous blog post on finding profit and loss. Algorithm Import the Pandas library and read the Excel sheet using the read_excel() function. Apply ... Read More

Find the profit and loss in the given Excel sheet using Pandas

Atharva Shah
Updated on 09-May-2023 14:53:19

567 Views

Pandas is a popular data manipulation and analysis library in Python that is widely used by data scientists and analysts. It provides several functions for working with data in Excel sheets. One of the most common tasks in analyzing financial data is finding the profit and loss in a given Excel sheet. Setup To handle excel files in Python using Python, you need to install the openpyxl dependency. To do this, open your terminal and type the command − pip install openpyxl After successful installation you can proceed with experimenting with Excel files and spreadsheets. To download the Excel ... Read More

Advertisements