5 Replies - 1582 Views - Last Post: 23 March 2012 - 10:42 PM Rate Topic: -----

#1 Courtney2012   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 16-March 12

insertion sort & selection sort methods?

Posted 23 March 2012 - 05:53 PM

I have been working on the code for an alpha sort file and have become stumped. I need to incorporate both an insertion sort & selection sort method into my code before it will run.

I attached the file I have been working on and it runs on Bluej with Java JDK. I would apretiate if you could take a look at it. If you would prefer not to download my file I have posted my code that I have been working on below.

I am not familiar with the structure of an insertion sort or a selection sort mothod. I also am not clear on the point in which these methods would need to be placed in the file.

I AM LOOKING FOR THE STRUCTURE OF THESE METHODS. I UNDERSTAND THAT A PORTION OF THE WWW.DREAMINCODE.COM COMMUNITY, IS UNDER THE IMPRESSION THAT SUCH A REQUEST WOULD BE AN ACT OF LAZZYNESS AND MISCHEVIOUS INDIGNITY AND MAYBE EVEN ACADEMIC/CYBER INFEDELITY JUDGING BY THE BACK SPLASH I AM CURRENTLY TYPING OVER.

I UNDERSTAND WERE YOU ARE COMMING FROM. IT WOULD BE WRONG OF ME TO ASK YOU TO WRITE MY FINAL EXAM FOR ME. BUT THAT IS WHY WE HAVE TESTS AND EXAMS, TO SHOW WHAT KNOLEDGE WE HAVE ACTUALY RETAINED.

EVEN THOUGH YOU MAY BE, "SOMETIMES GROUCHY" GREG BRENNON PAGE 2,I WOULD LIKE YOU TO TAKE A MINUTE AND EMPATHIZE WITH ME. I AM LEARNING A NEW LANGUAGE HERE.IMAGIN YOU WERE LEARNING FRENCH AND NEEDED TO LEARN HOW TO SAY "THE RED DOG JUMPED OVER THE FENCE", YOUR PROBLEM BEING THAT YOU HAVE NEVER SPOKEN A WORD OF FRENCH IN YOUR LIFE. HOW WOULD YOU FEEL IF YOU CAME TO ME FOR HELP BUT INSTEAD OF HELPING I JUST TOLD YOU, "TELL ME WHAT YOUR ERRORS YOU ARE GETTING. TELL ME WHAT YOU THINK IT SHOULD SOUND LIKE AND THEN ILL GIVE YOU SOME HINTS AS TO WHICH WORDS YOU HAVE MISPRONOUNCED."?


IT CAN BE HARD FOR US TO UNDERSTAND THAT SOMETHING THAT COMES SO ESILY TO US MAY NOT TO OTHERS ASWELL. I DO NOT SPEAK JAVA AND THEREFORE AM CURRENTLY IN THE SAME POSITION AS YOU WOULD HAVE BEEN IN THE ABOVE EXAMPLE.

DO YOU THINK THAT YOU TOUGHT YOURSELF TO WRITE IN ENGLISH OR DO YOU THINK IT MAY HAVE BEEN THOSE WHO WERE AROUND YOU? WHY WOULD I BE ANY DIFFERANT FROM YOU?

I AM SORRY IF I HAVE COME OFF AS RUDE BUT I AM JUST TRYING TO MAKE YOU UNDERSTAND WHERE I AM COMMING FROM. THANKYOU.




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

public class Words
{
ArrayList<String> words;

public Words()
{
words = getData("wordlist.txt");
}

public void displayWords()
{
for(int i=0; i<words.size(); i++) {
System.out.println(words.get(i));
}
}

public ArrayList<String> getData(String filename)
{
ArrayList<String> list = new ArrayList<String>();
File myFile = new File(filename);
if(myFile.exists() && myFile.length()>0) {
try {
BufferedReader in = new BufferedReader( new FileReader(myFile) );
String word = in.readLine();
while( word != null ) {
list.add(word);
word = in.readLine();
}
} catch( Exception e )
{} 
}
return list;
}
}



Is This A Good Question/Topic? 0
  • +

Replies To: insertion sort & selection sort methods?

#2 Courtney2012   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 16-March 12

Re: insertion sort & selection sort methods?

Posted 23 March 2012 - 06:02 PM

Here is the file.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#3 GregBrannon   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2250
  • View blog
  • Posts: 5,340
  • Joined: 10-September 10

Re: insertion sort & selection sort methods?

Posted 23 March 2012 - 06:03 PM

Why are you yelling?
Was This Post Helpful? 0
  • +
  • -

#4 Courtney2012   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 16-March 12

Re: insertion sort & selection sort methods?

Posted 23 March 2012 - 06:09 PM

Because I am sad and no one listens to me. :(
Was This Post Helpful? 0
  • +
  • -

#5 GregBrannon   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2250
  • View blog
  • Posts: 5,340
  • Joined: 10-September 10

Re: insertion sort & selection sort methods?

Posted 23 March 2012 - 06:31 PM

There are several sorting algorithm discussions and tutorials available on the web with pseudo-code and even functional code examples for most popular languages covering the common sorting algorithms. Considering that, it's hard to understand why you haven't made even the tiniest effort at writing a sort routine, not a single line. Absent something to work with, what do you expect us to do to help you other than write the code for you? What do you want us to do?
Was This Post Helpful? 0
  • +
  • -

#6 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8379
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: insertion sort & selection sort methods?

Posted 23 March 2012 - 10:42 PM

View PostCourtney2012, on 23 March 2012 - 09:09 PM, said:

Because I am sad and no one listens to me. :(

Nobody will if you yell at them
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1