# Category Archives: Java Programs

## How to remove loop in LinkedList in Java ?

In this post, we will learn How to remove loop in LinkedList in Java. This problem statement is the extension of the below problems: How to check whether a linked list has a loop/cycle in java ? Find start node of the loop in Singly LinkedList in java After removing loop from Above image shown output… Read More »

## Depth-First Search or DFS for a Graph Data Structure

In post talks about Depth-First Search or DFS for a Graph Data Structure with example To solve problems on graphs, we need a mechanism for traveling the graph. graph traversal algorithms are usually called Graph Search Algorithms. like trees traversal algorithms( inorder, preorder, and level order traversals), Graph Search algorithms can be thought of As… Read More »

## Breadth-First Search or BFS for a Graph Data Structure

In post talks about Breadth-First Search or BFS for a Graph Data Structure with example To solve problems on graphs, we need a mechanism for traveling the graph. graph traversal algorithms are usually called Graph Search Algorithms. like trees traversal algorithms( inorder, preorder, and level order traversals), Graph Search algorithms can be thought of As… Read More »

## How to write the Counting Sort program in Java ?

In this post, we will learn How to write the Counting Sort program in Java. Counting sort is one of the O(n) sorting algorithm like Bucket Sort and Radix Sort. Since it runs in linear time O(n) so counting sort is faster than the comparison-based algorithms like Quick Sort and Merge Sort. Even though counting… Read More »

## How to write a Bucket Sort program in Java ?

In this post, we will learn How to write a Bucket sort program in Java. Bucket sort has a time complexity of O(n) like Radix sort and Counting sort. It runs in linear time O(n) so Bucket sort is faster than the comparison-based algorithms like Quick Sort or Merge Sort. Similar to the Counting sort,… Read More »

## How to write a Quick Sort program in Java ?

In this post, we will learn How to write a quicksort program in Java. Quicksort is usually considered the fastest in-memory sorting algorithm in most of the situations. Just like Merge sort, It is also a divide and conquer algorithm. which works on the idea to partition the large list into smaller lists around a… Read More »

## How to write a Radix sort program in Java

In this post, we will learn How to write a Radix sort program in Java. Radix sort is in the group of Counting Sort and Bucket Sort which are O(n) sorting algorithms. How does Radix sort work? The radix sort usually works by doing the sorting in passes moving from least significant digit to the… Read More »

## How to write Merge sort program in Java ?

In this post, we will learn How to write a Merge sort program in Java? Merge sort is very much efficient than the simple sorting algorithms like the bubble sort, selection sort, and insertion sort. the only drawback is that it requires an additional array along with the input array that is sorted. How to… Read More »

## Reverse the first K elements of a Queue ?

In this post, We will learn How to write a Java Program to Reverse the first K elements of a Queue? First, let’s try to understand the problem statement in little more detail for better clarity: You have given an integer K and a Queue of Integers then How would you reverse the order of the… Read More »

## How to delete the last node in a Doubly Linked List in Java?

In the previous post, How to delete the first node in a Doubly Linked List in Java?  we learned how to delete the first node from LinkedList. In this post, We will learn How to delete the last node in a Doubly Linked List in Java? Logic is Very Simple: if List is Empty than throws NoSuchElementException Exception… Read More »