Found 1862 Articles for Data Structure

Program to print Fibonacci Triangle

Thanweera Nourin A V
Updated on 23-Aug-2023 21:38:39

2K+ Views

A Fibonacci series is found in every row of the Fibonacci triangle. What is a fibonacci series? In the Fibonacci series, each digit equals the sum of the two integers before it. This series' first two digits are 1 and 1. The next elements in the series are computed as the sum of two numbers previous to it. The Fibonacci series is produced as 1+1=2, 2+3=5, 3+5=8, 8+13=21, 13+21=34 and so on. Likewise, the Fibonacci triangle series goes like 1, 1, 2, 3, 5, 8, 13, 21, 34, 55… Problem Statement Implement a program to ... Read More

Decrease and Conquer

Thanweera Nourin A V
Updated on 23-Aug-2023 21:37:34

2K+ Views

Imagine yourself in a situation where you are having trouble coming up with a solution to your initial issue. What if I told you that a small part of the problem is simpler to solve and that you can use this answer to find the answer to the larger one? Interesting? The decrease and conquer strategy achieves just this. A problem-solving strategy known as "Decrease and Conquer" involves slicing the size of the input at every stage of the solution procedure. Identical to divide-and-conquer as it breaks the problem down into smaller sub-problems, decrease-and-conquer reduces the size of the ... Read More

Decimal Representation of given Binary String is Divisible by 20 or Not

Thanweera Nourin A V
Updated on 23-Aug-2023 21:36:19

52 Views

In this article, we take the challenge to determine whether or not the given binary number's decimal form can be divided by 20. The base-2 numeral system, often known as the binary numeral system, is a way of expressing numbers in mathematics that employs just two symbols, commonly "0" (zero) and "1." (one). For instance, the decimal number 4 is represented as 100 in binary form. The binary form of the decimal number 6 is 110. The binary representation is 11100 for the decimal number 28. Now think how the decimal number 1, 23, 45, 687 can be represented as ... Read More

Stella Octangula Number

Eva Sharma
Updated on 24-Aug-2023 18:19:51

80 Views

In mathematics, a Stella Octangula number is a figurate number based on the Stella Octangula, of the form n(2n2 − 1). Stella Octangula numbers which are perfect squares are 1 and 9653449. Problem Statement Given a number n, check whether it is the Stella Octangula number or not. The sequence of Stella Octangula numbers is 0, 1, 14, 51, 124, 245, 426, 679, 1016, 1449, 1990 Example1 Input x = 14 Output Yes Explanation $$\mathrm{For\: n = 2, expression \:n\lgroup 2n^2 – 1\rgroup is\: 14}$$ Example2 Input n = 22 Output No Explanation $$\mathrm{There \:is\: no\: ... Read More

Nicomachus’ Theorem

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

167 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

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

Swapping four Variables without a Temporary Variable

Simran Kumari
Updated on 23-Aug-2023 10:43:22

465 Views

By the title "Swapping four variables without a temporary variable, " What do you understand? Let's decode. Here the question is asking us to swap the values of four variables without creating any additional temporary variables. Using a temporary variable to hold one of the values temporarily in various programming languages makes shifting the values of two variables simple. The use of temporary variables, however, becomes ineffective and time−consuming when swapping the values of more than two variables. Explanation Suppose we have four variables a, b, c, and d with the following values: a = 5 (101) b = 9 ... Read More

Sum of Bitwise AND of all Possible Subsets of given Set

Simran Kumari
Updated on 23-Aug-2023 10:41:45

108 Views

What do you understand by the problem `Sum of bitwise AND of all possible subsets of given set`? Let’s decode. The problem is asking to find the sum of the bitwise AND of all possible subsets of a given set. Let’s try to understand the problem with an example. Suppose we have a set {1, 2, 3}. What are the possible subsets for this set? The possible subsets are {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, and {1, 2, 3}. Now lets calculate the bitwise AND for each subset. The bitwise AND of these subsets can be calculated ... Read More

Squares of Numbers with Repeated Single Digits

Simran Kumari
Updated on 23-Aug-2023 10:40:22

69 Views

What is the question `Square of numbers with repeated single digits` asking us to do? Let’s decode! The problem "Squares of numbers with repeated single digits" aims to find the square of numbers like 33, 44, 555, etc which contains repeated single digits. Approach 1: Naive Approach We can use the naive approach to calculate the square of numbers, which includes the following steps: Take the numbers as input Use the multiplication operator to calculate the square i.e square_of_number= number * number then print the result Implementation in C++ Here is the implementation of above approach Example #include ... Read More

Advertisements