Data Structure Articles

Page 22 of 164

Jacobsthal and Jacobsthal-Lucas Numbers

Divya Sahni
Divya Sahni
Updated on 28-Sep-2023 572 Views

Jacobsthal Numbers Lucas sequence π‘ˆπ‘›(𝑃, 𝑄) where P = 1 and Q = -2 are called Jacobsthal numbers. The recurrence relation for Jacobsthal numbers is, $$\mathrm{𝐽_𝑛 = 0\: π‘“π‘œπ‘Ÿ \: 𝑛 = 0}$$ $$\mathrm{𝐽_𝑛 = 1\: π‘“π‘œπ‘Ÿ \: 𝑛 = 1}$$ $$\mathrm{𝐽_𝑛 = 𝐽_π‘›βˆ’1 + 2𝐽_{π‘›βˆ’2}\: π‘“π‘œπ‘Ÿ \: 𝑛 > 1}$$ Following are the Jacobsthal numbers βˆ’ 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, …. Jacobsthal-Lucas Numbers Complementary Lucas sequence $\mathrm{𝑉_𝑛(𝑃, 𝑄)}$ where P = 1 and Q = -2 are called JacobsthalLucas numbers. The recurrence relation for Jacobsthal-Lucas numbers is, $\mathrm{𝐽_𝑛}$ = ...

Read More

Increment a number by 1 by manipulating the bits

Divya Sahni
Divya Sahni
Updated on 28-Sep-2023 2K+ Views

Bit manipulation applies logical operations on a bit stream using bitwise operators like AND(&), OR(|), NOT(~), XOR(^), Left Shift() to get a required result. Using bitwise operators is beneficial as we can manipulate individual bits and they are faster than other operators. Problem Statement Given a number. Increment or add the number by 1 using bitwise operators only. (Don’t use arithmetic operators like β€˜+’ , β€˜-’, β€˜*’ or’/’ ) Approach 1: Using One’s Complement / NOT Operator Bitwise complement / One’s complement is implemented using the NOT(~) Operator. For a number n, a bitwise complement of n i.e. ~n = ...

Read More

Sum of Fourth Powers of first N natural numbers

Divya Sahni
Divya Sahni
Updated on 28-Sep-2023 2K+ Views

The fourth power of a number x is x raised to the power 4 or x4. Natural numbers are all positive integers excluding zero. Thus, the sum of the fourth powers of the first N natural numbers is βˆ’ $\mathrm{Sum = 1^4 + 2^4 + 3^4 + 4^4 + … + N^4}$ This article describes some approaches for finding the sum using minimum time and space complexity. Problem Statement Given the number N, find the sum $\mathrm{1^4 + 2^4 + 3^4 + 4^4 + … + N^4}$. Example 1 Input: 3 Output: 98 Explanation $\mathrm{Sum = 1^4 + ...

Read More

Centered Pentadecagonal Number

Rinish Patidar
Rinish Patidar
Updated on 27-Sep-2023 313 Views

The problem includes printing the N-th centered pentadecagonal number for any input number N. A centered pentadecagonal number is a number that can be represented in the form of a figure with a dot in the centre and surrounded by successive layers of the pentadecagon i.e. 15-sided polygon. Here the successive layers of the pentadecagon depict that the first layer surrounding the dot in the centre will be 15-sided polygon, the next layer will be 30-sided polygon followed by a 45-sided polygon and so on. We can understand the concept of centered pentadecagonal with the below figures. The first ...

Read More

Centered Octagonal Number

Rinish Patidar
Rinish Patidar
Updated on 27-Sep-2023 507 Views

The problem statement includes printing the N-th centered octagonal number for some positive integer N, which will be given by the user. A centered octagonal number is a type of number which can be represented in a pattern of figures. Every centered octagonal number can be represented as a dot in the centre surrounded by the successive layers of an Octagon. An octagon is a type of polygon in geometry which has 8 sides in it. The successive layers of an octagon means that the first layer surrounding the dot in the centre will be an octagon, the second ...

Read More

Centered Octadecagonal Number

Rinish Patidar
Rinish Patidar
Updated on 27-Sep-2023 249 Views

The problem includes to print the N-th centered octadecagonal number, where N will be given as an input. A centered octadecagonal number is a type of figurative number which is represented as a dot in the centre surrounded by the successive layers of the octadecagon. An octadecagon is a polygon with 18 sides in it. The successive layers of the octadecagon are the first layer will be 18-sided polygon, the next will be 36-sided polygon and so on. The numbers can be better explained with the help of figures. The first number is represented as a dot in the ...

Read More

Centered nonadecagonal number

Rinish Patidar
Rinish Patidar
Updated on 27-Sep-2023 226 Views

The problem statement includes printing of the N-th centered nonadecagonal number for any positive value of N. A centered nonadecagonal numbers are numbers which are represented in a particular pattern of figure. This number can be represented in a figure as a dot in the centre surrounded by the successive layers of the nonadecagon. A nonadecagon is a type of polygon in mathematics which has 19 sides in it. The successive layers of the nonadecagon suggests that the first layer surrounding the dot in the centre will be 19 sided polygon followed by 38 sided polygon and so ...

Read More

Centered dodecahedral number

Rinish Patidar
Rinish Patidar
Updated on 27-Sep-2023 353 Views

The problem statement says to print the N-th centered dodecahedral number for any positive value of N which will be the user input. A centered dodecahedral number is a number that can be represented in a particular pattern of figure. A dodecahedron is a three-dimensional figure in mathematics which has 12 flat faces. And a centered dodecahedral number is a number which can be represented in the form of a figure with a dot in the centre surrounded by the successive layers of the dodecahedron (12 faced 3-d structure). The successive layers of the dodecahedron says the first layer will ...

Read More

Centered cube number

Rinish Patidar
Rinish Patidar
Updated on 27-Sep-2023 450 Views

The problem statement includes printing the N-th centered cube number for some positive value of N, which will be the user input. A centered cube number is the number of points in a three-dimensional pattern created by a point surrounded by concentric cubical layers of points, with i^2 points on the square faces of the ith layer. It is equivalently the number of points in a body-centered cubic pattern within the cube with n + 1 points along each of its edges. You can refer to wikipedia for figurative representation of the centered cube number which will help in better ...

Read More

Difference between Static and Dynamic Hashing

Manisha Shejwal
Manisha Shejwal
Updated on 14-Sep-2023 44K+ Views

Hashing is a computation technique in which hashing functions take variable-length data as input and issue a shortened fixed-length data as output. The output data is often called a "Hash Code", "Key", or simply "Hash". The data on which hashing works is called a "Data Bucket". Characteristics of Hashing Technique Hashing techniques come with the following characteristics βˆ’ The first characteristic is, hashing technique is deterministic. Means, whatever number of times you invoke the function on the same test variable, it delivers the same fixed-length result. The second characteristic is its unidirectional action. There is no way you can ...

Read More
Showing 211–220 of 1,635 articles
« Prev 1 20 21 22 23 24 164 Next »
Advertisements