Parallel Arrays

no coding needed

Page 1 of 1

4 Replies - 1185 Views - Last Post: 04 May 2009 - 03:48 PM Rate Topic: -----

#1 anonymous18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 11-November 08

Parallel Arrays

Post icon  Posted 04 May 2009 - 12:31 AM

I need to create a file using user input data and parallel arrays. The data needs to be sorted, so the question I have is "Do I write the data to the file and then sort it or do I sort the data and then write it to the file?

This post has been edited by anonymous18: 04 May 2009 - 12:31 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Parallel Arrays

#2 Mikeyp926  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 29
  • View blog
  • Posts: 205
  • Joined: 20-March 09

Re: Parallel Arrays

Posted 04 May 2009 - 12:45 AM

You should sort the data first and then write it to the file.

And does the assignment specify that you must use parallel arrays? If not then you might want to consider doing it a little differently, parallel arrays usually aren't the easiest way to do things. If the assignment says you have to use them, then I guess you do, and it should be a good learning experience. :-)

-Michael
Was This Post Helpful? 0
  • +
  • -

#3 anonymous18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 11-November 08

Re: Parallel Arrays

Posted 04 May 2009 - 01:26 AM

View PostMikeyp926, on 3 May, 2009 - 11:45 PM, said:

You should sort the data first and then write it to the file.

And does the assignment specify that you must use parallel arrays? If not then you might want to consider doing it a little differently, parallel arrays usually aren't the easiest way to do things. If the assignment says you have to use them, then I guess you do, and it should be a good learning experience. :-)

-Michael


Yeah we have to use parallel arrays and we cannot uses classes just methods. Okay, so I need the same data to be written to two different files and sorted differently. So should I get the data, create two separate methods that sort and write the data to the file as it should be. I've found that it's quite complicated for beginning java class, I haven't found any java help sites that talk about sorting parallel arrays and writing it to a file.

This post has been edited by anonymous18: 04 May 2009 - 01:42 AM

Was This Post Helpful? 0
  • +
  • -

#4 Mikeyp926  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 29
  • View blog
  • Posts: 205
  • Joined: 20-March 09

Re: Parallel Arrays

Posted 04 May 2009 - 01:05 PM

Ok, well the writing the data to the files shouldn't be too difficult. I would think that the actual sorting would be the hard part, but I guess it depends on the assignment. I think the basic structure of the program would look like this.

1. Get user input and store in parallel arrays
2. Perform first sort on the arrays
3. Store the data in a file
4. Perform the second sort of the arrays
5. Store the data in a second file



Something like that.

What type of data are you sorting? Do you already have a good idea of how to perform the sorting?

-Michael
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

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

Reputation: 8328
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Parallel Arrays

Posted 04 May 2009 - 03:48 PM

Do not write a method that sorts and write to file

Write a method that sorts a parrallel array (the Code Snippet section contains sorts of all sorts [but not parrallel arrys I'm afraid])
Write a method that save an array to file... it could receive as parameter the array to write and the filename

for sorting parallel arrays just remember you will have to swap the elements in the 2 arrays at the same time
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1