Interview Questions

Data Structures

Java Program to Reverse a Linked List

Use the following code to reverse a Linked list using Java.

/**
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

Java - Bubble Sorting

/**
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

Java Data Structure

In this article lets discuss about how to write a simple data structure in java.

Data structure is a logical representation of data. There are different datastructures in java like Array, ArrayList, Set, Map etc. Each one has their own logical representation of the data elements. For example, ArrayList stores data in an ordered(in which it is inserted) but unsorted way.

Java Sorting Algorithm

In this section let's look into the implementation of basic sorting algorithms in java.
In today's world of computer science, sorting is a basic operation which is unavoidable. Whatever may be the application you work on, sorting of data will be the preliminary operation that one would be required to do. Here we will stick only to integer sorting.
The following java program is self explanatory with necessary comments. It contains a set of methods implementing various sorting algorithms to sort integer values in ascending order.

Java Searching algorithm

In this article lets look in to the implementation of basic searching algorithms in java.

One of the important operation that a programmer encounters every day is Searching. It involves searching a given number against a collection, a particular name from a set of employee names and also searching records in a DB. Whatever may be the scenario involved with searching, in comes under three basic algorithm.
1. Linear Search
2. Binary Search
3. Hash Search