Click here to Skip to main content
16,005,437 members
Home / Discussions / Java
   

Java

 
AnswerRe: How do i get all values from a JTextfields that is located on another JInternalFrame? Pin
427748021-Sep-09 4:37
427748021-Sep-09 4:37 
QuestionHaving trouble with recursion (kind of long, but please read) Pin
KingLane20-Sep-09 12:48
KingLane20-Sep-09 12:48 
AnswerI got the code to work Pin
KingLane20-Sep-09 14:06
KingLane20-Sep-09 14:06 
QuestionJava projects Pin
prietycool19-Sep-09 0:29
prietycool19-Sep-09 0:29 
AnswerRe: Java projects Pin
Richard MacCutchan20-Sep-09 9:29
mveRichard MacCutchan20-Sep-09 9:29 
QuestionJava web Project using Springs Pin
prietycool19-Sep-09 0:27
prietycool19-Sep-09 0:27 
AnswerRe: Java web Project using Springs Pin
427748021-Sep-09 5:22
427748021-Sep-09 5:22 
QuestionMerge Sort problem Pin
snssewell18-Sep-09 18:02
snssewell18-Sep-09 18:02 
We have to use different sorting algorithms to sort an array. So I already got the quick, bubble, and insertion sort working and I am not posting the code since it already works Laugh | :laugh: However the Merge Sort is giving me problems. I already searched online but could not find the right answer. Anyway...here it goes. We were provided with some code snippets and have to make them work. What data do they want when they say min, max? I thought that it would be the first element in the array and the last....No? cause its not working like that. Here is my code please someone help me what they want... Cry | :((

import java.io.*;
  import java.util.*;

   class MergeSortArray
  {
      public static void main(String[] args)
     {

        int choice = 0;

        int[]values;
        int counter = 0;
        int backCounter = 10;

        values = new int[10];

        while(counter != 10)
        {
           Scanner scanner = new Scanner (System.in);
           System.out.println("Enter " + backCounter + " more integers:");
           choice = scanner.nextInt();
           values[counter] = choice;
           counter++;
           backCounter--;
        }

        System.out.println(counter);


            mergeSort (values, 0, values.length-1);
            merge (values, first, mid, last);



        int i=0;
        while(i<10)
        {
           System.out.println(values[i]);
           i++;
        }

     }
         // RIGHT HERE....what do they want from me?
            public static void mergeSort (Comparable[] data, int min, int max)
     {
        if (min < max)
        {
           int mid = (min + max) / 2;
           mergeSort(data, min, mid);
           mergeSort(data, mid+1, max);
           merge (data, min, mid, max);

        }
     }

  //---------------------------------------------------------------------------------------
  //  Sorts the specified array of objects using the merge sort algorithm.
  //---------------------------------------------------------------------------------------

      public static void merge (Comparable[] data, int first, int mid, int last)
     {
        Comparable[] temp = new Comparable[data.length];

        int first1 = first, last1 = mid; //endpoints of first subarray
        int first2 = mid + 1, last2 = last; //endpoints of second subarray
        int index = first1; // next index open in temp array

     // Copy smaller item from each subarry into temp until one of the subarrays is exhausted

        while (first1 <= last1 && first2 <= last2)
        {
           if (data[first1].compareTo(data[first2]) < 0)
           {
              temp[index] = data[first1];
              first1++;
           }
           else
           {
              temp[index] = data[first2];
              first2++;
           }
           index++;
        }
     //  Copy remaining elements from first subarray, if any
        while (first1 <= last1)
        {
           temp[index] = data[first1];
           first1++;
           index++;
        }

     //  Copy remaining elements from second subarray, if any
        while (first2 <= last2)
        {
           temp[index] = data[first2];
           first2++;
           index++;
        }

     // Copy merged data into original array
        for (index = first; index <= last; index++)
           data[index] = temp[index];
     }
  }


Please help me to get this working. Pretty Please!!! Shucks | :-\
AnswerRe: Merge Sort problem Pin
427748018-Sep-09 18:13
427748018-Sep-09 18:13 
GeneralRe: Merge Sort problem Pin
snssewell18-Sep-09 18:25
snssewell18-Sep-09 18:25 
GeneralResolved Pin
snssewell18-Sep-09 18:29
snssewell18-Sep-09 18:29 
GeneralRe: Merge Sort problem Pin
427748018-Sep-09 18:30
427748018-Sep-09 18:30 
GeneralRe: Another Problem now Pin
snssewell18-Sep-09 18:46
snssewell18-Sep-09 18:46 
AnswerRe: Merge Sort problem Pin
427748018-Sep-09 18:59
427748018-Sep-09 18:59 
GeneralRe: Finally resolved..I hope..lol Pin
snssewell18-Sep-09 19:20
snssewell18-Sep-09 19:20 
QuestionOutput String returned from encryption/decryption Fuction into a text file???Help please!!!! Pin
ChiSmile18-Sep-09 16:36
ChiSmile18-Sep-09 16:36 
AnswerRe: Output String returned from encryption/decryption Fuction into a text file???Help please!!!! Pin
427748018-Sep-09 17:54
427748018-Sep-09 17:54 
Questionhow to move cookie value from https to http page? [modified] Pin
sangeethanarayan17-Sep-09 21:54
sangeethanarayan17-Sep-09 21:54 
AnswerRe: https to http Pin
Nagy Vilmos17-Sep-09 21:57
professionalNagy Vilmos17-Sep-09 21:57 
AnswerRe: how to move cookie value from https to http page? Pin
427748018-Sep-09 18:32
427748018-Sep-09 18:32 
GeneralRe: how to move cookie value from https to http page? Pin
sangeethanarayan20-Sep-09 19:06
sangeethanarayan20-Sep-09 19:06 
QuestionWhich laguages does FreeTTS Supported. Pin
sharkbc17-Sep-09 17:01
sharkbc17-Sep-09 17:01 
AnswerRe: Which laguages does FreeTTS Supported. Pin
427748017-Sep-09 18:22
427748017-Sep-09 18:22 
QuestionMy code won't complile right in JCreator Pin
Dale Leach II17-Sep-09 13:38
Dale Leach II17-Sep-09 13:38 
AnswerRe: My code won't complile right in JCreator Pin
427748017-Sep-09 15:55
427748017-Sep-09 15:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.