Java Program to Find Largest Number in Array Using Recursion

Here you will get java program to find largest number in array using recursion.

Output Given Array: 5 12 10 6 15 Largest Number is 15 Comment below if you have any queries regarding above program.

Read more

Java Program to Find Inverse of a Matrix

Here you will get java program to find inverse of a matrix of order 2×2 and 3×3. We can find inverse of a matrix in following way. First find the determinant of matrix. Calculate adjoint of matrix. Finally divide adjoint of matrix by determinant. Image Source Below I have shared program to find inverse of 2×2 and 3×3 matrix. Java Program to Find Inverse of a Matrix 2×2 Matrix

Output Enter elements of matrix row wise: 4 7 2

Read more

Java Program to Insert Element in Array at Specified Position

Here you will get java program to insert element in array at specified position. How it works? First copy all the elements before the position where element is to be inserted in a new array. Now assign the element at given position in the new array. Finally copy all the elements after the position where element is to be inserted in a new array. We can partially copy elements of one array to another using System.arraycopy() method. Its syntax is

Read more

Java Program for Matrix Multiplication

Here you will get java program for matrix multiplication. Suppose we have matrix A with number of rows and columns as m and n. Let B be a matrix with number of rows and columns as p and q. Their multiplication is possible only if number of columns of matrix A is equal to number of rows of matrix B i.e. n should be equal to p. The resultant matrix is of order mxq. Also Read: Java Program for Matrix Addition

Read more

Java Program for Matrix Addition

Here you will get java program for matrix addition. If you have ever done addition of two matrices in your maths subject then you can easily do this in java also. It can be done in following way. Read two matrices in 2D array a[][] and b[][] respectively inside loop. Now add each element of a[][] with corresponding position element of b[][] and save the result in c[][]. Finally display the 2D array c[][]. Note: The addition is possible only when

Read more

Heap Sort in Java

Here you will get program for heap sort in java. Heap sort is a sorting algorithm that uses heap data structure. Its best, worst and average time complexity is O (n log n).   How heap sort algorithm works? First we make max heap from given set of elements. In max heap each parent node is greater than or equal to its left and right child. Now first node is swapped by last node and size of heap is reduced by 1.

Read more

Bubble Sort in Java

In this tutorial you will learn about bubble sort in Java. In bubble sort algorithm each element is compared with adjacent element and are swapped if not in correct order. It is one of the simplest but worst sorting algorithm. It is suitable for sorting small list of numbers. As bubbles come up on surface in water, in the same way the lighter or smaller elements come forward and heavier or bigger elements goes back. Below image shows how bubble

Read more

Difference between Array and ArrayList in Java

Here you will learn about difference between array and arraylist in java. Both array and arraylist are most important and frequently used data structure in java. Below I have discussed about various differences between them.   Difference between Array and ArrayList in Java Property Array ArrayList Size Array is fixed in size. Once declared, its size can’t be changed. ArrayList size can be changed after declaration. For example when we add or remove element in arraylist, its size increases or

Read more
1 2