Thread Tools
Old September 21, 2003, 06:49   #1
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
Need help with Java
Does anyone know where I can find the sourcecode for Quick Search, Merge Search and Heap Search?

I need the source code, because our teachers told us to download them from the internet, and we should comment the different lines in the code, so they know we understand it. Our assignment isn't based on the "do-it-yourself", because we didn't have enough time for this assignment to actually do it ourself.

Does anyone know where I can find those?
__________________
This space is empty... or is it?
Adagio is offline  
Old September 21, 2003, 07:19   #2
Skanky Burns
Alpha Centauri Democracy GameACDG The Cybernetic ConsciousnessC4DG Team Alpha CentauriansApolytoners Hall of FameACDG3 Spartans
 
Skanky Burns's Avatar
 
Local Time: 20:04
Local Date: November 2, 2010
Join Date: Aug 2001
Location: Skanky Father
Posts: 16,530
Sorry, a quick search (grin) with google didn't turn up anything interesting with any of them.
__________________
I'm building a wagon! On some other part of the internets, obviously (but not that other site).
Skanky Burns is offline  
Old September 21, 2003, 07:22   #3
Skanky Burns
Alpha Centauri Democracy GameACDG The Cybernetic ConsciousnessC4DG Team Alpha CentauriansApolytoners Hall of FameACDG3 Spartans
 
Skanky Burns's Avatar
 
Local Time: 20:04
Local Date: November 2, 2010
Join Date: Aug 2001
Location: Skanky Father
Posts: 16,530
Goldmine!

http://www.cs.ubc.ca/spider/harrison...ting-demo.html

and if that doesn't help, some more from sun
http://java.sun.com/docs/books/tutor...ns/algorithms/
__________________
I'm building a wagon! On some other part of the internets, obviously (but not that other site).
Skanky Burns is offline  
Old September 21, 2003, 07:22   #4
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
Thx, I'll take a look
__________________
This space is empty... or is it?
Adagio is offline  
Old September 21, 2003, 07:32   #5
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
Do you know an easy way to compile SortAlgorithm.jav and SortItem.java?

I can't find them as class files, and I can't compile them because file1 needs file2, and file2 needs file1
__________________
This space is empty... or is it?
Adagio is offline  
Old September 21, 2003, 07:36   #6
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
Nevermind, found the way
__________________
This space is empty... or is it?
Adagio is offline  
Old September 21, 2003, 09:05   #7
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 10:04
Local Date: November 2, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
how?
__________________
Concrete, Abstract, or Squoingy?
"I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis
Immortal Wombat is offline  
Old September 21, 2003, 09:07   #8
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
By opening the files in a project (I'm using JCreator)
__________________
This space is empty... or is it?
Adagio is offline  
Old September 21, 2003, 09:11   #9
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 10:04
Local Date: November 2, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
cunning
__________________
Concrete, Abstract, or Squoingy?
"I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis
Immortal Wombat is offline  
Old September 21, 2003, 09:19   #10
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
Could someone please take a look at my code and tell me what's wrong here?


Tester.java is the execution file.
I'm having problems with HeapSort.java

I have included a lot of System.out.println's to find the error, but I can't seem to find anything wrong in the code.

For some strange reason it just stops in the middle of the for-loop in heapSort method

Can someone see what's wrong here?
__________________
This space is empty... or is it?
Adagio is offline  
Old September 21, 2003, 12:15   #11
Urban Ranger
NationStatesApolyton Storywriters' GuildNever Ending Stories
Deity
 
Urban Ranger's Avatar
 
Local Time: 17:04
Local Date: November 2, 2010
Join Date: May 1999
Location: The City State of Noosphere, CPA special envoy
Posts: 14,606
Shouldn't you use v[] instead of data[] inside HeapSort?
__________________
(\__/) 07/07/1937 - Never forget
(='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
(")_(") "Starting the fire from within."
Urban Ranger is offline  
Old September 22, 2003, 05:44   #12
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
Uhmm... I guess so, but this doesn't make any difference. The problem is the pause(); methods. I don't understand why they're included. If I don't include them it goes on forever, but if I include them, the program ends with a pause(); (Using the System.out.println("Pause1"); line in the pause(); method)
__________________
This space is empty... or is it?
Adagio is offline  
Old September 22, 2003, 06:05   #13
Skanky Burns
Alpha Centauri Democracy GameACDG The Cybernetic ConsciousnessC4DG Team Alpha CentauriansApolytoners Hall of FameACDG3 Spartans
 
Skanky Burns's Avatar
 
Local Time: 20:04
Local Date: November 2, 2010
Join Date: Aug 2001
Location: Skanky Father
Posts: 16,530
Which line exactly does it stop at, or which for loop?
What are the variables doing just before it stops responding?

Have your println call display the values of the variables used in that particular section of code, it should help point out the problem.
__________________
I'm building a wagon! On some other part of the internets, obviously (but not that other site).
Skanky Burns is offline  
Old September 22, 2003, 06:10   #14
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
In HeapSort line 101 it calls the medhod pause(), which is line 61 - 67 in class SortAlgorithm

The last thing it does before stopping is printing "Pause1" (line 65). I have checked, it doesn't enter this:

if (stopRequested)
{
throw new Exception("Sort Algorithm");
}
__________________
This space is empty... or is it?
Adagio is offline  
Old September 22, 2003, 11:33   #15
Urban Ranger
NationStatesApolyton Storywriters' GuildNever Ending Stories
Deity
 
Urban Ranger's Avatar
 
Local Time: 17:04
Local Date: November 2, 2010
Join Date: May 1999
Location: The City State of Noosphere, CPA special envoy
Posts: 14,606
The pause() method is part of Java's AWT. It seems like it was included to be used as part of some sorting demo program. I think you can take it out.
__________________
(\__/) 07/07/1937 - Never forget
(='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
(")_(") "Starting the fire from within."
Urban Ranger is offline  
Old September 22, 2003, 11:39   #16
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
I have tried to take it out, but if I do it, it makes something strange. It prints out like this:

(...)
5
44
89
1
56
4
8
12
11
18
(...)

It has printed very much, before I get the chance to stop the print's, which makes it impossible to see where it fails
__________________
This space is empty... or is it?
Adagio is offline  
Old September 22, 2003, 13:24   #17
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
I just found a MergeSort.class file, but somethings weird about it. When sorting, the graf shows it mostly only takes 0-10 milliseconds to sort 5000 ints

The funny thing is, when I insert some System.out.print()'s to check to see if it really sorts it, the array is actually sorted... sounds too fast to be true...
__________________
This space is empty... or is it?
Adagio is offline  
Old September 22, 2003, 13:33   #18
Adagio
staff
Spore
Deity
 
Adagio's Avatar
 
Local Time: 11:04
Local Date: November 2, 2010
Join Date: Jun 2001
Posts: 11,112
Just tried the test with 50,000 ints, but it still sorted correctly, and this within 10 milliseconds...
__________________
This space is empty... or is it?
Adagio is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:04.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team