corejava
View Answers
July 18, 2009 at 5:01 PM
Hi Friend,
Try the following code:
public class MergeSort{
public static void main(String a[]){
int i;
int array[] = {12,9,4,99,120,1,3,10};
System.out.println("Values Before the sort:\n");
for(i = 0; i < array.length; i++)
System.out.print( array[i]+" ");
System.out.println();
mergeSort_srt(array,0, array.length-1);
System.out.print("Values after the sort:\n");
for(i = 0; i <array.length; i++)
System.out.print(array[i]+" ");
System.out.println();
}
public static void mergeSort_srt(int array[],int lo, int n){
int low = lo;
int high = n;
if (low >= high) {
return;
}
int middle = (low + high) / 2;
mergeSort_srt(array, low, middle);
mergeSort_srt(array, middle + 1, high);
int end_low = middle;
int start_high = middle + 1;
while ((lo <= end_low) && (start_high <= high)) {
if (array[low] < array[start_high]) {
low++;
} else {
int Temp = array[start_high];
for (int k = start_high- 1; k >= low; k--) {
array[k+1] = array[k];
}
array[low] = Temp;
low++;
end_low++;
start_high++;
}
}
}
}
Thanks
Related Tutorials/Questions & Answers:
CoreJava ProjectCoreJava Project Hi Sir,
I need a simple project(using core Java, Swings, JDBC) on core Java... If you have please send to my account
Advertisements
corejava - Java Beginnerscorejava pass by value semantics Example of pass by value semantics in Core Java. Hi friend,Java passes parameters to methods using pass by value semantics. That is, a copy of the value of each of the specified
JListJList pls tell me about the concept the JList in
corejava? and tell me a suitable example
core java - Java Beginnerscore java how to create a login page using only
corejava(not servlets,jsp,hibernate,springs,structs)and that created loginpage contains database(ms-access) the database contains data what ever u r enter and automatically date
Java Locale/
corejava/javatext/parseAndFormatDateUsingLocale.html
Thanks
Eclipse - IDE QuestionsEclipse Hi To All..
I am new to ECLIPSE IDE. Please suggest me any book which can give me complete idea of setting environment and development with basic to advance development of java like(
corejava,servlet,jsp,struts,ejb
HOW TO BECOME A GOOD PROGRAMMERHOW TO BECOME A GOOD PROGRAMMER I want to know how to become good programmer
Hi Friend,
Please go through the following link:
CoreJava Tutorials
Here you will get lot of examples with illustration where you can
how to count words in string using javahow to count words in string using java how to count words in string using
corejava
Hi Friend,
Try the following code:
import java.util.*;
class CountWords{
public static void main(String[] args
Factorial Program in Java");
}
}
}
Output
C:\Documents and Settings\bharat\Desktop\bipul\
CoreJava...:\Documents and Settings\bharat\Desktop\bipul\
CoreJava\Swing Example\Factorial>
What are the prerequisites for learning Java? for practicing.
Corejava Interview,
Corejava questions,
Corejava Interview Questions,
Corejava
- In this section we have interview
questions... Glossary
Q - Java Terms
R - Java Terms
S - Java Terms
T
Interthread Communication in Java corejava;
class Queue {
int n;
boolean valueSet = false;
synchronized...();
}
}
class Producer implements Runnable {
Queue
q;
Producer(Queue
q) {
this.q =
q;
new Thread(this, "Producer").start();
}
public
What are the prerequisites for learning Java? Tutorials
- Many example of Java/JDK for practicing.
Corejava Interview,
Corejava questions,
Corejava Interview Questions,
Corejava
... Glossary
O - Java Glossary
P - Java Glossary
Q - Java Terms
Mutliple files upload;
if (skilltype == "Java") {
list = new Array("
CoreJava","J2EE","J2SE...");
listValue = new Array("
CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload;
if (skilltype == "Java") {
list = new Array("
CoreJava","J2EE","J2SE...");
listValue = new Array("
CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload;
if (skilltype == "Java") {
list = new Array("
CoreJava","J2EE","J2SE...");
listValue = new Array("
CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload == "Java") {
list = new Array("
CoreJava","J2EE","J2SE...");
listValue = new Array("
CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload;
if (skilltype == "Java") {
list = new Array("
CoreJava","J2EE","J2SE...");
listValue = new Array("
CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP