skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

  • Home
 
  • RSS
  • Twitter
Showing posts with label Sorting Example. Show all posts
Showing posts with label Sorting Example. Show all posts
Monday, August 11, 2014

To Sort an Interger Array using Shell Sort

Posted by Happy Coder at 4:37 PM – 0 comments
 
To Sort an Interger Array using Shell Sort

class ShellSort {

    public static int[] shellSort(int[] array) {
  int N = array.length;
  
  // determine the initial h value
  int h = 1;
     while (h < N / 3) 
      h = 3 * h + 1; // 1, 4, 13, 40, 121, 364, 1093, ...
     
     while (h >= 1) {
      // h-sort the array
      for (int i = h; i < array.length; i++) {
       // do insertion sort for h-sized array
       for (int j = i; j >= h && array[j] < array[j - h]; j -= h)
        swap(array, j, j - h);
      }
      
      h = h / 3; // reverse the h-size
     }
     
     return array;
 }
 
 /*
  * swaps data elements between 2 indexes of an array
  */
 private static void swap(int[] array, int i, int j) {
  int temp = array[i];
  array[i] = array[j];
  array[j] = temp;
 } 
    
    public static void  main(String args[]){
     ShellSort sSort = new ShellSort();
     int[] array = { 77, 99, 44, 55, 22, 88, 11, 0, 66, 33 };
     int[] sortedArray = sSort.shellSort(array);
     for (int i = 0; i < array.length; i++)
         System.out.println(sortedArray[i]);
     
    }
}

Output of the Program : 
0
11
22
33
44
55
66
77
88
99

Try it by yourself here : http://ideone.com/veRv5P
[ Read More ]
Read more...

Sort an Integer array with Bucket Sort

Posted by Happy Coder at 4:29 PM – 0 comments
 
Here is a java program to Sort an Integer array with Bucket Sort

class BucketSort {

    public int[] bucketSort(int[] array) {
        // create an array the size of the largest value + 1
        int[] bucket = new int[100];   

        // for every value in array, increment its corresponding bucket
        for (int i = 0; i < array.length; i++)
            bucket[array[i]]++;

        int outPos = 0;
        for (int i = 0; i < bucket.length; i++) { 
         if (bucket[i] > 0)
             array[outPos++] = i;
        }
        
        return array;
    }
    
    public static void  main(String args[]){
     BucketSort bSort = new BucketSort();
     int[] array = { 77, 99, 44, 55, 22, 88, 11, 0, 66, 33 };
     int[] sortedArray = bSort.bucketSort(array);
     for (int i = 0; i < array.length; i++)
         System.out.println(sortedArray[i]);
     
    }
}

Output of the Program :
0
11
22
33
44
55
66

Try By Yourself Here : http://ideone.com/OpHXmH
[ Read More ]
Read more...
Thursday, August 15, 2013

Merge-Sort Algorithm implementation in JAVA

Posted by Admin at 10:10 AM – 0 comments
 
Merge-Sort Function

void MergeSort(int low, int high)
   // a[low : high] is a global array to be sorted.
   // Small(P) is true if there is only one element to
   // sort. In this case the list is already sorted.
   {
       if (low < high) { // If there are more than one element
              // Divide P into subproblems.
              // Find where to split the set.
              int mid = (low + high)/2;
              // Solve the subproblems.
              MergeSort(low, mid);
              MergeSort(mid + 1, high);
              // Combine the solutions.
              Merge(low, mid, high);
       }
   }

   void Merge(int low, int mid, int high)
   // a[low:high] is a global array containing two sorted
   // subsets in a[low:mid] and in a[mid+1:high]. The goal
   // is to merge these two sets into a single set residing
   // in a[low:high]. b[] is an auxiliary global array.
   {
       int h = low, i = low, j = mid+1, k;
       while ((h <= mid) && (j <= high)) {
          if (a[h] <= a[j]) { b[i] = a[h]; h++; }
          else { b[i] = a[j]; j++; } i++;
       }
       if (h > mid) for (k=j; k<=high; k++) {
                       b[i] = a[k]; i++;
                    }
       else for (k=h; k<=mid; k++) {
               b[i] = a[k]; i++;
            }
       for (k=low; k<=high; k++) a[k] = b[k];
   }


Merge Sort Java Code :
import java.util.*;

public class MergeSort {
 public int a[] = new int[50];

 public void merge_sort(int low, int high) {
  int mid;
  if (low < high) {
   mid = (low + high) / 2;
   merge_sort(low, mid);
   merge_sort(mid + 1, high);
   merge(low, mid, high);
  }
 }

 public void merge(int low, int mid, int high) {
  int h, i, j, k;
  int b[] = new int[50];
  h = low;
  i = low;
  j = mid + 1;

  while ((h <= mid) && (j <= high)) {
   if (a[h] <= a[j]) {
    b[i] = a[h];
    h++;
   } else {
    b[i] = a[j];
    j++;
   }
   i++;
  }
  if (h > mid) {
   for (k = j; k <= high; k++) {
    b[i] = a[k];
    i++;
   }
  } else {
   for (k = h; k <= mid; k++) {
    b[i] = a[k];
    i++;
   }
  }
  for (k = low; k <= high; k++)
   a[k] = b[k];
 }

 public MergeSort() {
  int num, i;

  System.out.println("             MERGE SORT PROGRAM            ");

  System.out.println();
  System.out.println();
  System.out
    .println("Please Enter THE No. OF ELEMENTS you want to sort[THEN PRESS ENTER]:");
  num = new Scanner(System.in).nextInt();
  System.out.println();
  System.out.println("Now, Please Enter the (" + num
    + ") nos. [THEN PRESS ENTER]:");
  for (i = 1; i <= num; i++) {
   a[i] = new Scanner(System.in).nextInt();
  }
  merge_sort(1, num);
  System.out.println();
  System.out.println("So, the sorted list (using MERGE SORT) will be :");
  System.out.println();
  System.out.println();

  for (i = 1; i <= num; i++)
   System.out.print(a[i] + "    ");

 }

 public static void main(String[] args) {
  new MergeSort();
 }
}
[ Read More ]
Read more...
Wednesday, October 24, 2012

Alphanumeric String Sorting using Java

Posted by Raju Gupta at 6:30 PM – 0 comments
 

Alphanumeric is a combination of alphabetic and numeric characters (sometimes shortened to alphameric).

In computing, the alphanumeric Strings can be seen very common to represent various codes etc. Sorting the alphanumeric strings can sometimes be a trouble by using regular sort techniques.

import java.util.Arrays;
import java.util.Comparator;
 
public class AlphanumericSorting implements Comparator {
    /**
     * The compare method that compares the alphanumeric strings
     */
    public int compare(Object firstObjToCompare, Object secondObjToCompare) {
        String firstString = firstObjToCompare.toString();
        String secondString = secondObjToCompare.toString();
 
        if (secondString == null || firstString == null) {
            return 0;
        }
 
        int lengthFirstStr = firstString.length();
        int lengthSecondStr = secondString.length();
 
        int index1 = 0;
        int index2 = 0;
 
        while (index1 < lengthFirstStr && index2 < lengthSecondStr) {
            char ch1 = firstString.charAt(index1);
            char ch2 = secondString.charAt(index2);
 
            char[] space1 = new char[lengthFirstStr];
            char[] space2 = new char[lengthSecondStr];
 
            int loc1 = 0;
            int loc2 = 0;
 
            do {
                space1[loc1++] = ch1;
                index1++;
 
                if (index1 < lengthFirstStr) {
                    ch1 = firstString.charAt(index1);
                } else {
                    break;
                }
            } while (Character.isDigit(ch1) == Character.isDigit(space1[0]));
 
            do {
                space2[loc2++] = ch2;
                index2++;
 
                if (index2 < lengthSecondStr) {
                    ch2 = secondString.charAt(index2);
                } else {
                    break;
                }
            } while (Character.isDigit(ch2) == Character.isDigit(space2[0]));
 
            String str1 = new String(space1);
            String str2 = new String(space2);
 
            int result;
 
            if (Character.isDigit(space1[0]) && Character.isDigit(space2[0])) {
                Integer firstNumberToCompare = new Integer(Integer
                        .parseInt(str1.trim()));
                Integer secondNumberToCompare = new Integer(Integer
                        .parseInt(str2.trim()));
                result = firstNumberToCompare.compareTo(secondNumberToCompare);
            } else {
                result = str1.compareTo(str2);
            }
 
            if (result != 0) {
                return result;
            }
        }
        return lengthFirstStr - lengthSecondStr;
    }
 
    /**
     * Testing the alphanumeric sorting
     */
    public static void main(String[] args) {
        String[] alphaNumericStringArray = new String[] { "NUM10071",
                "NUM9999", "9997", "9998", "9996", "9996F" };
 
        /*
         * Arrays.sort method can take an unsorted array and a comparator
         * to give a final sorted array.
         *
         * The sorting is done according to the comparator that we have
         * provided.
         */
        Arrays.sort(alphaNumericStringArray, new AlphanumericSorting());
 
        for (int i = 0; i < alphaNumericStringArray.length; i++) {
            System.out.println(alphaNumericStringArray[i]);
        }
 
    }
 
}

[ Read More ]
Read more...
Monday, October 15, 2012

DataTable Sorting using wicket

Posted by Raju Gupta at 4:00 PM – 0 comments
 
Sorting a data table using apache wicket

//   DataTablePage.java

import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;

public class DataTablePage extends WebPage {
    
    public DataTablePage() {
        final DataTableUser user = new DataTableUser();
        
        IColumn[] columns = new IColumn[2];
        columns[0] = new PropertyColumn(new StringResourceModel("firstNameTableHeaderLabel", this, null), "name.first", "name.first");
        columns[1] = new PropertyColumn(new Model("Last Name"), "name.last", "name.last");
        
        DefaultDataTable table = new DefaultDataTable("datatable", columns, user, 10);
        
        add(table);
    }

}


// DataTableUser.java

import java.io.Serializable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

public class DataTableUser extends SortableDataProvider {

 class SortableDataProviderComparator implements Comparator<Contact>, Serializable {
  public int compare(final Contact o1, final Contact o2) {
   PropertyModel<Comparable> model1 = new PropertyModel<Comparable>(o1, getSort().getProperty());
   PropertyModel<Comparable> model2 = new PropertyModel<Comparable>(o2, getSort().getProperty());

   int result = model1.getObject().compareTo(model2.getObject());

   if (!getSort().isAscending()) {
    result = -result;
   }

   return result;
  }

 }

 private List<Contact> list = new ArrayList<Contact>();
 private SortableDataProviderComparator comparator = new SortableDataProviderComparator();

 public DataTableUser() {
  // The default sorting
  setSort("name.first", true);

  list.add(new Contact(new Name("FN1", "LN1")));
  list.add(new Contact(new Name("FN2", "LN2")));
  list.add(new Contact(new Name("FN3", "LN3")));

 }

 public Iterator<Contact> iterator(final int first, final int count) {

  // Get the data
  List<Contact> newList = new ArrayList<Contact>(list);

  // Sort the data
  Collections.sort(newList, comparator);

  return newList.subList(first, first + count).iterator();
 }

 public IModel<Contact> model(final Object object) {
  return new AbstractReadOnlyModel<Contact>() {
   @Override
   public Contact getObject() {
    return (Contact) object;
   }
  };
 }

 public int size() {
  return list.size();
 }

}

class Contact implements Serializable {

 private final Name name;

 public Contact(final Name name) {
  this.name = name;
 }

 public Name getName() {
  return name;
 }
}

class Name implements Serializable {

 private String firstName;
 private String lastName;

 public Name(final String fName, final String lName) {
  firstName = fName;
  lastName = lName;
 }

 public String getFirst() {
  return firstName;
 }

 public String getLast() {
  return lastName;
 }

 public void setFirst(final String firstName) {
  this.firstName = firstName;
 }

 public void setLast(final String lastName) {
  this.lastName = lastName;
 }
}

// DataTablePage.html

<html>
<head>
 <title>DataTable</title>
</head>

<body>
<table wicket:id="datatable"></table>
</body>
</html>


// DataTablePage.properties

firstNameTableHeaderLabel=First Name

[ Read More ]
Read more...
Friday, September 14, 2012

Sort Java Vector in descending order using comparator

Posted by Admin at 1:19 PM – 0 comments
 
Sort Java Vector in descending order using comparator example his java example shows how to sort elements of Java Vector in descending order using comparator and reverseOrder method of Collections class.
mport java.util.Vector;
mport java.util.Collections;
mport java.util.Comparator;
 
public class SortVectorInDescendingOrderExample {
 
  public static void main(String[] args) {
   
    //create a Vector object
    Vector v = new Vector();
   
    //Add elements to Vector
    v.add("1");
    v.add("2");
    v.add("3");
    v.add("4");
    v.add("5");
   
    /*
      To get comparator that imposes reverse order on a Collection use
      static Comparator reverseOrder() method of Collections class
    */
   
    Comparator comparator = Collections.reverseOrder();
   
    System.out.println("Before sorting Vector in descending order : " + v);
   
    /*
      To sort an Vector using comparator use,
      static void sort(List list, Comparator c) method of Collections class.
    */
   
    Collections.sort(v,comparator);
    System.out.println("After sorting Vector in descending order : " + v);
   
  }
}


[ Read More ]
Read more...
Monday, February 13, 2012

To Apply Bubble Sort on Strings

Posted by Admin at 6:15 AM – 0 comments
 
Here is a Java Program to Bubble Sort for Strings

class SortString {
  static String arr[] = {
    "Now", "is", "the", "time", "for", "all", "good", "men",
    "to", "come", "to", "the", "aid", "of", "their", "country"
  };
  public static void main(String args[]) {
    for(int j = 0; j < arr.length; j++) {
      for(int i = j + 1; i < arr.length; i++) {
        if(arr[i].compareTo(arr[j]) < 0) {
          String t = arr[j];
          arr[j] = arr[i];
          arr[i] = t;
        }
      }
      System.out.println(arr[j]);
    }
  }
}

Output of Above Java Program
Now
aid
all
come
country
for
good
is
men
of
the
the
their
time
to
to

[ Read More ]
Read more...
Older Posts
Subscribe to: Posts ( Atom )

List of Java Programs

  • Java Program to check Greater between the Two Number
  • Java Program to find that given number is Palindrome or not
  • Java Program to Demonstrate the Use of Pre and Post Operator
  • Java Program to Reverse the Given Number
  • Java Program to Print Number in the Given Data Type
  • Program to Demonstrate Skipping using Continue
  • Program to find whether entered character is a vowel or Consonant
  • Java Program to Calculate the Sum of Digits of Given Number
  • How to swap two numbers using only two variables
  • Checking the Given Number is Armstrong or Not
  • Average an Array of Values
  • Display ASCII Code Instead of Character
  • Comparison of Two Variable using If
  • Printing Table In java using While Loop
  • Generate Random Number Using Math.Random Function
  • To Find roots of Quadratic Equation
  • Performing Arithmetic Opration on Two Variable
  • Concatenation of Two String in Java
  • Command Line Argument in JAVA
  • Java Hello World Program
  • Calculate Circle Perimeter | Java Program
  • Calculate the Area of Circle | Java Program
  • To Find Whether Given Year is a Leap Year or not
  • Popular
  • Recent
  • Archives

Total Pageviews

Sparkline

Followers

Popular Posts of This Week

  • Interthread Communication java
    class Q { int n; boolean valueSet = false; synchronized int get() { if(!valueSet) try { wait(); } cat...
  • Merge-Sort Algorithm implementation in JAVA
    Merge-Sort Function void MergeSort(int low, int high) // a[low : high] is a global array to be sorted. // Small(P) is true if there...
  • Sort an Integer array with Bucket Sort
    Here is a java program to Sort an Integer array with Bucket Sort class BucketSort { public int[] bucketSort(int[] array) { /...
  • Stop Watch Program - To measure the amount of time to process each input
    public class Stopwatch { private final long start; public Stopwatch() { start = System.currentTimeMillis(); } ...
  • Java Program to Generate the Lottery Number between 1 to 49
     A lottery requires that you select six different numbers from the integers 1 to 49. Write a program to do this for you and generate five s...
  • String Search through FTP files
    Searching for a string through number of files in an FTP folder manually is a cumbersome process especially when the number of files in the ...
  • JFrame EXIT_ON_CLOSE vs DISPOSE_ON_CLOSE
    //For creating a Frame JFrame testFrame = new JFrame("This is a test Frame"); //Set Size of the Frame testFrame.setSize(400, 40...
  • Java program to create a Binary Heap and Perform various operation
    A binary heap (min-heap) is a complete binary tree with elements from a partially ordered set, such that the element at every node is less ...
  • Java - Excel Connectivity
    This contains the sample code for Java Excel Connectivity import java.sql.*; import java.io.*; import java.util.*; import java.text.*; /*...
  • Singly linked list with header - Data Structure
    class OrderedList { private int value; private OrderedList next; // Note: No setValue() method or setNext() methods are provide...
Powered by Blogger.

Archives

  • ▼  2014 ( 4 )
    • ▼  August ( 4 )
      • Java program to create a Binary Heap and Perform v...
      • Create an Adjacency matrix Graph and perform Add a...
      • To Sort an Interger Array using Shell Sort
      • Sort an Integer array with Bucket Sort
  • ►  2013 ( 6 )
    • ►  August ( 1 )
    • ►  April ( 5 )
  • ►  2012 ( 673 )
    • ►  November ( 9 )
    • ►  October ( 223 )
    • ►  September ( 272 )
    • ►  August ( 2 )
    • ►  June ( 1 )
    • ►  February ( 67 )
    • ►  January ( 99 )
 

Our Blogs

  • Linux Tutorial
  • C Programming Tutorial

Labels

  • Agile Methodology ( 1 )
  • Algorithm ( 3 )
  • AntiSamy ( 1 )
  • Arithmetic Operation ( 1 )
  • Array Example ( 9 )
  • ArrayList Examples ( 11 )
  • Average an Array of Values ( 1 )
  • Barcode Example ( 1 )
  • Basic Java Programs ( 34 )
  • Bing API Example ( 2 )
  • BitSet Example ( 1 )
  • Boolean Example ( 1 )
  • Bouncy Castle API ( 1 )
  • Break Statement ( 2 )
  • BufferedReader Example ( 2 )
  • Calendar Example ( 1 )
  • Chart Generation Example ( 1 )
  • Command Line Argument ( 1 )
  • Comparator Example ( 1 )
  • Concatenation of String ( 1 )
  • Continue Statement ( 1 )
  • Control Structure ( 1 )
  • Copy File Example ( 1 )
  • CRC Example ( 1 )
  • CSV Example ( 6 )
  • Data Structure ( 5 )
  • Date Example ( 2 )
  • Directory Example ( 1 )
  • Do - While Loop Example ( 1 )
  • Domino Database ( 1 )
  • Email Example ( 8 )
  • Encryption Example ( 3 )
  • Excel Example ( 15 )
  • Factorial Example ( 1 )
  • File Upload Example ( 1 )
  • Find Roots of Quadratic Equation ( 1 )
  • FTP Example ( 2 )
  • Graph Examples ( 1 )
  • Greater between Two Numbers ( 1 )
  • GSON Library ( 1 )
  • HashMap Example ( 1 )
  • HashSet Example ( 1 )
  • Hello World Program ( 1 )
  • If Condition ( 2 )
  • Inner Class Example ( 1 )
  • iText Example ( 3 )
  • JAR File ( 1 )
  • JAVA Applet ( 1 )
  • Java Applications ( 1 )
  • Java AWT Example ( 9 )
  • Java Certification ( 1 )
  • Java Class Examples ( 15 )
  • Java Collection Example ( 1 )
  • Java Command Example ( 4 )
  • Java Constructor Examples ( 1 )
  • Java Currency Example ( 1 )
  • Java Database Example ( 3 )
  • Java Date and Time Example ( 3 )
  • Java DateFormat Example ( 3 )
  • Java Examples ( 2 )
  • Java Exception Example ( 5 )
  • Java File Example ( 22 )
  • Java GUI Example ( 1 )
  • Java Image Examle ( 3 )
  • Java Inheritance Example ( 3 )
  • Java Input Output Example ( 1 )
  • Java IO Example ( 3 )
  • Java Jar Example ( 1 )
  • Java JSON Example ( 3 )
  • Java Mail Examples ( 4 )
  • Java Map Example ( 5 )
  • Java MapReduce Example ( 2 )
  • Java MultiThreading Example ( 7 )
  • Java Network Example ( 9 )
  • Java Package ( 1 )
  • Java Programs ( 1 )
  • Java RMI ( 1 )
  • Java Robot Class Examples ( 2 )
  • Java Runtime Example ( 1 )
  • Java Swing Example ( 9 )
  • Java Util Example ( 1 )
  • Java Vector Example ( 4 )
  • Java Voice Example ( 1 )
  • Java Webservice Example ( 1 )
  • Java XML Example ( 3 )
  • Java Zip Class Examples ( 2 )
  • JDBC ( 9 )
  • JDK Version Comparison ( 1 )
  • JFrame Example ( 3 )
  • JOptionPane Dialog Example ( 1 )
  • JPanel Example ( 1 )
  • JSP Example ( 2 )
  • JSTL Example ( 1 )
  • jUnit Example ( 2 )
  • LinkedList Example ( 2 )
  • List Example ( 1 )
  • Long Variable ( 1 )
  • Lottery Nubmer ( 1 )
  • MD5 Hashing Example ( 3 )
  • Memory Management Example ( 1 )
  • Method Override ( 1 )
  • MIDI Sound ( 8 )
  • Module Operator Example ( 2 )
  • Multiplication Table ( 1 )
  • Observer Interface Example ( 1 )
  • Operator Example ( 5 )
  • Pagination ( 1 )
  • Palindrome Number ( 1 )
  • Pass By Reference Example ( 1 )
  • Pass By Value Example ( 1 )
  • PDF File Example ( 3 )
  • PDF Generation Example ( 4 )
  • Pre and Post Operator ( 2 )
  • Prime Number ( 3 )
  • Progress Bar Example ( 1 )
  • Property List Example ( 2 )
  • Random Function ( 7 )
  • Recursion Example ( 2 )
  • Regex Example ( 2 )
  • Remote Host Example ( 2 )
  • Robot Class ( 4 )
  • Searching Example ( 3 )
  • Slideshow ( 1 )
  • Sorting Example ( 7 )
  • SpringLayout Example ( 1 )
  • Stack Example ( 4 )
  • Static Variable ( 1 )
  • StreamTokenizer Example ( 2 )
  • String Example ( 19 )
  • Struts2 Example ( 1 )
  • Sum of Digits ( 1 )
  • Swap Two Numbers ( 1 )
  • Switch Case ( 3 )
  • Tapestry Components ( 1 )
  • Thumbnail Example ( 2 )
  • TimerTask Example ( 2 )
  • To Calculate Volume ( 1 )
  • To Check Armstrong Number ( 1 )
  • Tree Example ( 1 )
  • TreeMap Example ( 1 )
  • TreeSet Example ( 1 )
  • Two Dimensional Array Example ( 1 )
  • UUID ( 1 )
  • Validation Example ( 2 )
  • Variable Casting ( 1 )
  • While Loop ( 1 )
  • XML Parsing ( 7 )
  • XSS Attacks ( 1 )
  • Zip File ( 15 )

Popular Posts

  • Java program to create a Binary Heap and Perform various operation
    A binary heap (min-heap) is a complete binary tree with elements from a partially ordered set, such that the element at every node is less ...
  • To Sort an Interger Array using Shell Sort
    To Sort an Interger Array using Shell Sort class ShellSort { public static int[] shellSort(int[] array) { int N = array.length; ...
  • Java Class to Calculate the Volume of Box
    Here is a Java Class to Calculate the Volume of Box. class Box { double width; double height; double depth; // This is the con...
  • Implementation of a basic generic tree, with labels of type T - Data Structure
    // This implements a basic generic tree, with labels of type T, // pointer to the parent node, and a singly linked list of children nodes...
  • Printing Table In java using While Loop
    Here is a Java Program to Print the Table public class Table { public static void main(String[] args) { int no = Integer.p...
  • Create an Adjacency matrix Graph and perform Add and Remove operation
    import java.util.ArrayList; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; import...
  • Sort an Integer array with Bucket Sort
    Here is a java program to Sort an Integer array with Bucket Sort class BucketSort { public int[] bucketSort(int[] array) { /...
  • Merge-Sort Algorithm implementation in JAVA
    Merge-Sort Function void MergeSort(int low, int high) // a[low : high] is a global array to be sorted. // Small(P) is true if there...
  • Stack implemented as array - Data Structure
    // Stack implemented as array public class ArrayStack<T> { private T[] stack; private int numElements = 0; // points to s...
  • Performing Arithmetic Opration on Two Variable in Java
    Here is a Program to Perform the Arithmetic Operation between two Variable public class IntOps { public static void main(String[] ar...
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger