Java

Let’s learn selection sort java. Selection sort java In selection sort algorithm smallest element in unsorted array is shifted to its correct position in an array. The number of times sorting takes place will always be one less than the number of integer elements in an array. To select lowest element we need to scan…

Read More Selection sort java

Let’s learn java reverse string array. Java reverse string array Here’s reverse string array program using for loop. import java.util.Arrays; public class ReverseStringArrayInJava { public static void main(String[] args) { String[] strHierarchy = new String[]{“Junior Developer”,”Senior Developer”,”Team Lead”,”Project Manager”,”Senior Manager”,”CEO”}; System.out.println(“Given string array: ” + Arrays.toString(strHierarchy)); for(int a = 0; a < strHierarchy.length / 2;…

Read More Java reverse string array

Let’s learn how to rename file in java. How to rename file in java To rename a file renameTo() method is used of File class. Here’s the syntax of renameTo() method of File class. public boolean renameTo(File dest) renameto method returns true if and only if the renaming is succeeded; false otherwise. Many aspects of…

Read More How to rename file in java

Let’s learn random number generator in java. Random number generator in java How to generate random numbers in java is one of the common interview question. Let’s learn how to generate random numbers in java using some built in methods and classes. Math.random() method in java random function in java returns pseudo random double greater…

Read More Random number generator in java

Let’s learn quicksort java. Quicksort java Basically quicksort is a divide and conquer algorithm. Quicksort is one of the widely used sorting algorithm. Because it is used to sort large datasets or lists. quick sort in java implementation Below are steps for quicksort algorithm java. Given an array of numbers we want to sort them…

Read More Quicksort java

Let’s learn merge sort java. Merge sort java Merge sort is divide and conquer algorithm. Merge sort is comparison based sorting algorithm which sorts array in ascending order. In merge sort, given array is divided into two smaller portions. To divide a collection, mergesort take the middle of collection and split into two smaller lists.…

Read More Merge sort java

Let’s learn linear search in java. Linear search in java Linear search is very simple sequential search algorithm. It’s used to search key element in the given array. Here search starts from leftmost element of an array and key element is compared with every element in an array. Search continues until the key element is…

Read More Linear search in java

Let’s learn insertion sort java. Insertion sort java Insertion sort sorts elements the way in which we sort playing cards. This sort can be fast when used with smaller arrays. Given an array of elements, let’s sort them in increasing order. So let’s look at sample list of integer elements. We have an array of…

Read More Insertion sort java