Coders Packet

Sorting and Searching in Java

By Priyadarshini Gopal

Sorting an unsorted array using Bubble Sort and Searching for a key in a sorted array using Binary Search in Java.

The program provides a template for users to sort and search data that can be used in various applications easily.

It provides three options to the users via a menu:

    1. Sort an unsorted array:

        The user inputs the size of the array. After this, the user inputs each element of the unsorted array one by one.

        The program uses Bubble Sort to sort the array and display it.

    2. Search for a key in a sorted array:

        The user inputs the size of the array. After this, the user inputs each element of the sorted array one by one.

        The program uses Binary Search to search for the key and display its index if found.

    3. Sort an unsorted array and then search for a key in this sorted array:

        This provides the user the option to search for a key while providing an unsorted array.

        The user inputs the size of the array. After this, the user inputs each element of the unsorted array one by one.

        The program then sorts the array and displays it. Following this, the user can input the value to be searched in the array. The program displays, if

        found, the index of the searched element.

Download project

Reviews Report

Submitted by Priyadarshini Gopal (Priyadarshini)

Download packets of source code on Coders Packet