Java Program for First Come First Serve (FCFS) Scheduling Algorithm

In this article we are going to learn about first come first serve (fcfs) scheduling in Java with program example. FCFS strategy will be helpful in many situations especially in tie breaking situations. Here we will see FCFS strategy with scheduling problem. First Come First Serve (FCFS) Scheduling First come First serve means whatever the job came first we should process that job first regardless other properties. This situation we can map with our real time scenario. When we are

Read more

Why Java is Platform Independent Language?

In this article we will learn about why java is platform independent. Before getting into details of this first we should know what platform independence is. Platform Independence: It means if we have written a program it should run on any platform without any modifications. Platform means hardware + operating system. Why Java is Platform Independent Language? Java package is coming with JDK (Java Runtime Environment) and JRE (Java Runtime Environment). JDK will be useful for developing and compiling java code.

Read more

Quick Sort in Java (Program & Algorithm)

Here you will learn about quick sort in Java with program example. As name suggested it is one of the fastest algorithms with average time complexity O(nlogn). It is also using divide and conquer strategy to sort as like merge sort. It has taken all advantages of merge sort and it has overcome the disadvantage of using auxiliary space also. It is popular because it is faster and also space efficient. But in worst case it is O(n^2) then also

Read more

Merge Sort in Java

In this tutorial you will learn about merge sort in Java with program and example. Merge sort has gained its popularity because of its runtime and simplicity. It will exhibit best runtime for sorting. Now we will see algorithm, program with example for merge sort. It uses divide-and-conquer policy to sort input elements. Divide phase: It will divide problem into smaller sub problems of same kind. Conquer phase: In this phase we will solve each sub problem. Combine phase: In

Read more

Insertion Sort in Java

In this tutorial you will learn about insertion sort in Java with example and program. Insertion Sort Principle The strategy behind this sorting is much similar to playing cards. In cards playing we used to see that player will hold the cards in sorted manner. Whenever he wants to insert a new card he will put that in such way that again the cards in hand should be in sorted manner only. The below image can illustrate the phenomenon. When

Read more

Selection Sort in Java

In this tutorial you will learn about selection sort in Java with example. It will sort the input elements in ascending or descending order by taking small or large element among the input elements and swap that element with the element in 1st position. Then it picks second small or large element and swap it with the element in second position. Likewise it will sort all the elements in the input in n-1 passes if our input size is n.

Read more

Breadth First Search (BFS) Java Program

Here you will get Breadth First Search (BFS) Java program along with example. Breadth First Search is graph traversal algorithm which has many applications in most of the algorithms. We will start with one node and we will explore all the nodes (neighbor nodes) in the same level. Then we should go to next level to explore all nodes in that level. Here BFS should fallow the graph traversal rule that it should visit each node exactly once. Also Read: Depth

Read more

Depth First Search (DFS) Java Program

In this tutorial you will learn about implementation of Depth First Search in Java with example. To traverse in trees we have traversal algorithms like inorder, preorder, postorder. Same way to traverse in graphs we have mainly two types of algorithms called DFS (Depth First Search) and BFS (Breadth First Search). In Depth First Search traversal we try to go away from starting vertex into the graph as deep as possible. We may face the case that our search never

Read more
1 2 3 14