# Category Archives: Java Programs

Given an array arr[] of size n. Three elements arr[i], arr[j] and arr[k] form an inversion of size 3 if a[i] > a[j] >a[k] and… Read More
Breadth First Traversal (or Search) for a graph is similar to Breadth First Traversal of a tree (See method 2 of this post). The only… Read More
Given a Singly Linked List, starting from the second node delete all alternate nodes of it. For example, if the given linked list is 1->2->3->4->5… Read More
Given two linked lists, insert nodes of the second list into the first list at alternate positions of the first list. For example, if first list… Read More
Given a linked list with a loop, the task is to find whether it is palindrome or not. You are not allowed to remove the… Read More
Given two numbers represented by two linked lists, write a function that returns the sum list. The sum list is linked list representation of the… Read More
Before understanding how the brightness is adjusted in any image first we have to understand how an image is represented. image is represented in the… Read More
Given an array of n non-negative integers. The task is to find frequency of a particular element in the arbitrary range of array[]. The range… Read More
Given a linked list, print reverse of it using a recursive function. For example, if the given linked list is 1->2->3->4, then output should be… Read More
Given an array of numbers, arrange them in a way that yields the largest value. For example, if the given numbers are {54, 546, 548,… Read More
Using pointers, loop through the whole list and keep track of the node prior to the node containing the last occurrence key using a special… Read More
Algorithm For Java:In Java, automatic garbage collection happens, so deleting a linked list is easy. Just need to change head to null. Implementation: Java //… Read More
Given a linked list handling string data, check to see whether data is palindrome or not? Examples: Input: a -> bc -> d -> dcb… Read More
Given n numbers (both +ve and -ve), arranged in a circle, find the maximum sum of consecutive numbers.  Examples:  Input: a[] = {8, -8, 9,… Read More
Given singly linked list with every node having an additional “arbitrary” pointer that currently points to NULL. We need to make the “arbitrary” pointer to… Read More