Found 34494 Articles for Programming

Nicomachus’ Theorem

Eva Sharma
Updated on 24-Aug-2023 18:17:20

168 Views

According to Nicomachus’ Theorem, the sum of the cubes of the first n integers is equal to the square of the nth triangular number. Or, we can also say − The sum of cubes of first n natural numbers is equal to square of sum of first natural numbers. Putting it algebraically, $$\mathrm{\displaystyle\sum\limits_{i=0}^n i^3=\lgroup \frac{n^2+n}{2}\rgroup^2}$$ Theorem $$1^3 = 1$$ $$2^3 = 3 + 5$$ $$3^3 = 7 + 9 + 11$$ $$4^3 = 13 + 15 + 17 + 19\vdots$$ Generalizing $$n^3 =\lgroup n^2−n+1\rgroup+\lgroup n^2−n+3\rgroup+⋯+\lgroup n^2+n−1\rgroup$$ Proof By Induction For all n Ε Natural ... Read More

Equal sum array partition excluding a given element

Eva Sharma
Updated on 24-Aug-2023 18:00:27

87 Views

Problem Statement For an index and an arr[]. Check if the array[] can be partitioned into two disjoint sets, excluding arr[index] such that the sum of both sets has equal value. Example 1 Input arr[] = {4, 3, 1, 2}, Index = 1 Output No Explanation We have to exclude arr[1] = 3 All possible sets are − Set 1: (4), Set 2: (2, 1), sum = 4≠3 Set 1: (4, 1), Set 2: (2), sum = 5≠2 Set 1: (4, 2), Set 2: (1), sum = 6≠1 No combination satisfies the conditions. Example 2Input arr[] ... Read More

Remove Duplicates from a String in O(1) Extra Space

Avinash Gupta
Updated on 23-Aug-2023 17:04:35

209 Views

In this problem, our task is to remove all the duplicate characters present in the string other than the first occurrence of every character. Also, it's required to solve the problem without using any extra space, and the Space complexity must be O(1). Various approaches are used in this article. The Boolean array is defined in one approach to determine the repetition of the characters where the index of Boolean array is mapped to each alphabet. In the second approach, the concept of the Bit manipulation is used to remove the repeated characters from the resultant string. Let's explore ... Read More

Squared Triangular Number (Sum of Cubes)

Eva Sharma
Updated on 24-Aug-2023 17:58:22

59 Views

A square triangular number, also referred to as a triangular square number, is a number that is both a triangular number and a perfect square. Square triangular numbers have an unlimited number of possible values; the first few are − 0, 1, 36, 1225, 41616... A triangular number or triangle number counts objects arranged in an equilateral triangle. The nth triangular number is the number of dots in the triangular arrangement with n dots on each side and is equal to the sum of the n natural numbers from 1 to n. The sequence of triangular numbers, ... Read More

Handling Missing Data in Python Causes and Solutions

Satish Kumar
Updated on 23-Aug-2023 17:17:05

153 Views

Introduction Missing data is a common issue in data analysis and can occur due to various reasons. In Python, missing values are often represented as NaN (Not a Number) or None. Missing data can cause inaccurate analysis results and lead to biased conclusions if not handled properly. Therefore, handling missing data is an essential part of any successful data analysis project. Causes of Missing Data in Python Missing data is a common challenge that data analysts and scientists often encounter in their work. In Python, there are various reasons why data may be missing. Understanding these causes can help analysts ... Read More

Sort Elements on the basis of the Number of Factors

Avinash Gupta
Updated on 23-Aug-2023 16:47:22

357 Views

In this problem, our task is to sort the array of integers based on several factors of numbers present in the array as a priority. The array is the best way to store similar types of elements in java. But if the number of factors becomes equal in any two numbers, then as a second priority, this algorithm sees numerical value. Factors are the numbers by which the given number is divisible entirely without leaving any remainder. This article uses various approaches to sort elements based on several factors. To show you some instances Instance-1 If Array = ... Read More

Allowing resizing window in PyGame

Priya Mishra
Updated on 24-Aug-2023 17:53:40

1K+ Views

Introduction Pygame is the module used for game development in Python; it is considered to be one of the most effective modules for this purpose. The development of video games can not only be profitable in today's market but also serve as a medium for educational and promotional purposes. Creating games requires knowledge of mathematics, logic, physics, artificial intelligence, and a lot of other subjects, yet it can be really enjoyable. We will discuss in detail what is Pygame, how to implement a normal PyGame window and how to allow users to resize the window with a working example. ... Read More

Append data to an empty Pandas DataFrame

Priya Mishra
Updated on 24-Aug-2023 17:48:28

178 Views

Introduction A data structure known as a data frame is a two-dimensional labelled array with columns that might be of various data kinds. You can compare it to a spreadsheet, a SQL table, or even a dict of Series objects to better understand it. It is the panda item that is used the vast majority of the time. In addition to the data itself, you have the option of also passing parameters for the index (row labels) and columns (column labels). If you supply an index and/or columns, you are assuring that those elements will be present in the DataFrame ... Read More

Annoted Heatmaps using Plotpy in Python

Priya Mishra
Updated on 24-Aug-2023 17:40:40

129 Views

Introduction A heat map, is a graphical representation of data in which each value in a matrix is assigned a unique colour. The primary purpose of heat maps is to increase the accuracy of the visualization of the total number of places and events included within a dataset, as well as the accuracy with which they direct viewers' attention to the most important aspects of data visualizations. Heat maps, which rely on colour to communicate values, are most commonly used to offer a more holistic picture of numerical values. This is due to the fact that heat maps rely on ... Read More

Animate image using OpenCV in Python

Priya Mishra
Updated on 24-Aug-2023 12:28:06

771 Views

Introduction Animated pictures are a sequence of static images that are automatically played to display relevant material in a continuous and dynamic manner, and they have the benefit of being smaller than videos. Additionally, many online and mobile applications enable animated images in the same manner that they support static photos, although they do not always permit the upload of movies. In this situation, animated pictures can be really helpful. Clearly, there are several other reasons why animated graphics are preferable. Sometimes, combining similar or unrelated photos is simply for fun. In this article, we would learn the steps to ... Read More

Advertisements