Found 9321 Articles for Object Oriented Programming

Java Program to Find Harmonic Series

Shiva Keerthi
Updated on 10-Apr-2023 18:24:51

610 Views

The reciprocals of an arithmetic series without considering 0 is known as Harmonic series. If $a_{1}, a_{2}, a_{3}$… is arithmetic series then $\frac{1}{a1}$, $\frac{1}{a2}$, $\frac{1}{a3}$, … is the harmonic series. In this article, we will discuss how to implement a java program to find the harmonic series. Harmonic Series For 1st term n = 1 and for every term n is incremented by 1 and at last the nth term the value is ‘n’. Harmonic series : $1+\frac{1}{2}+\frac{1}{3}$.......+$\frac{1}{n}$ Where, 1/n is the nth term of harmonic series. Examples Harmonic Series: $\frac{1}{1}+\frac{1}{2}+\frac{1}{3}+\frac{1}{4}+.............\frac{1}{n}$ Example 1 Input: n = 4 ... Read More

Java Program to Find Area of Rectangle Using Method Overloading

Shiva Keerthi
Updated on 10-Apr-2023 16:21:05

1K+ Views

We can calculate the area of the rectangle in Java using Method Overloading. “Method Overloading” is a feature in Java that allows one to write more than one method in the same class using the same method name. It will enable us to declare more than one method with the same names but with different signatures i.e., the number of parameters in the method may be different or the datatype of parameters may be different. Method Overloading helps us to increase the readability of the code so that we can use the same method in different ways. Now, let us ... Read More

Java Program to Find G.C.D and L.C.M of Two Numbers Using Euclid's Algorithm

Shiva Keerthi
Updated on 10-Apr-2023 16:20:17

2K+ Views

Euclid’s Algorithm is an efficient algorithm which helps us to find G.C.D and L.C.M of two numbers. In this article, we are learning to write a Java program to find the G.C.D and L.C.M of two numbers using Euclid’s Algorithm. G.C.D. of two numbers G. C. D, known as Greatest Common Divisor is the highest common factor that divides the two given numbers exactly. Now let us look into an example and calculate the G.C.D of a two numbers. Factors − In mathematics, Factors are the numbers that can divide a given number. Ex − 8 can be divided ... Read More

Java Program to Find Chromatic Index of Cyclic Graphs

Shiva Keerthi
Updated on 10-Apr-2023 16:19:02

123 Views

Chromatic Index of a graph is the parameter which indicates the minimum number of colours needed to colour all the edges of graph such that no two edges sharing the common vertex have same coloured edge. In this article, we will discuss how to find the chromatic index of cyclic graphs using the Java programming language. What is a Cyclic Graph? Cyclic Graph is a graph which consists of at least one cycle path in that particular graph. Cyclic path is a path that starts from a specific node and ends at the same node. What is Graph Colouring? ... Read More

Java Program to Find Common Elements Between Two Arrays

Shiva Keerthi
Updated on 31-May-2024 15:06:05

6K+ Views

We can use different approaches in Java to Find Common Elements between two arrays. We will discuss the approaches, including the basic steps involved, and provide the necessary code to achieve our goal. Whether you are a beginner or an experienced Java programmer, this article will provide you with the tools and knowledge necessary to solve this common programming problem. In this article, we will learn different ways of finding the common elements between two arrays. Examples for Common Elements Between Two Arrays: Example 1: Input: array1 = {4, 2, 3, 1, 6} array2 = {6, 7, 9, ... Read More

Java Program to Find Cube Root of a number using Binary Search

Shiva Keerthi
Updated on 10-Apr-2023 16:13:54

709 Views

Cube Root of a number is an integer value when multiplied by itself thrice, gives the original number. In this article, we are going to write a java program to find the cube root of a number using binary search. Finding cube root of a number is one of the application of the binary search algorithm. We will discuss in detail how we calculate the cube root using binary search in this article. Input-Output Examples Example-1: Input: 64 Output: 4 As, the cube root of 64 is 4, the output is 4. Example-2: Input: 216 ... Read More

Java Program to Find Area of circle Using Method Overloading

Shiva Keerthi
Updated on 09-Jul-2024 12:23:14

1K+ Views

We can calculate the area of the circle in Java using Method Overloading. “Method Overloading” is a feature in Java that allows one to write more than one method in the same class using the same method name. It will enable us to declare more than one method with the same names but with different signatures i.e., the number of parameters in the method may be different or the datatype of parameters may be different. Now, let us achieve Method Overloading in Java by considering the “area of a circle” as an example. Before moving to an example, now ... Read More

Java Program to Find the GCDs of given index ranges in an array

Rudradev Das
Updated on 06-Apr-2023 15:22:34

177 Views

In the field of data structure, a range query is a pre-processing method to operate on some input data in an efficient manner. A range query is responsible to answer any query of the particular input on any data subset. If we want to copy some data columns from a table we need to maintain an index for that particular dataset. An index is a direct link or a key, which is designed to provide an efficient searching process in a data set. It is mainly used to speed up the data retrieving from a lost data source. In mathematics, ... Read More

Java program to find array sum using bitwise OR after splitting given array in two halves after K circular shifts

Rudradev Das
Updated on 06-Apr-2023 18:00:21

143 Views

Array is a set of a single non primitive similar data types (values or variables) that stores the elements in a memory with a fixed number of values. After creating an array with certain elements, the length of this data set became fixed. Here non primitive means, these data types can be used to call a method to perform a particular operation which can be null in character. Here the bitwise sum means, sum of certain numbers with an exactly 2 bits set. Bitwise OR denotes that each integer is present in a subarray. It is an adjacent non-void element ... Read More

Java Program to count inversions of size three in a given array

Rudradev Das
Updated on 13-Apr-2023 12:02:43

159 Views

Inversion count is a step counting method by which we can calculate the number of sorting steps taken by a particular array. It is also capable to count the operation time span for an array. But, if we want to sort an array in a reverse manner, the count will be maximum number present in that array. Array: { 5, 4, 3, 2, 1} // for the reverse manner Pairs: {5, 4}, {5, 3} , {3, 2}, {3, 1}, {2, 1}, {4, 3}, {4, 2}, {4, 1}, }, {5, 2}, {5, 1} Output: 10 Array: {1, 2, 3, 4, ... Read More

Advertisements