![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: algorithm, analysis, help, java, programming, tutorial |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| ||||
| ** I just got pissed off because there was Database error for 1s and then got back again (by the time I clicked submit) ** And yeah, didn't save anything that I just wrote... yeah, really long... anyways.. haha... I'm bored anyways!! Hello all~! Come back to HelloWorld's Tutorial again!!! It's been a long time that I haven't wrote tutorial, and yeah here it is again, hopefully this tutorial would be helpful for everyone. Please don't hate, blame, or sue me (if you're in the U.S) if you got an F on your homework, test, or whatever you do... (got fired? lol..) Use this at your own risk. However, this tutorial has been tested and works on JVM 1.6 on Eclipse 3.2 Europa I have had fun for these past days analyzing some algorithm and see the difference at their running time. I choose 3 algorithm that built on each other for this tutorial purpose: Arrays, ArrayList, and Vector These Data Structures are built on each other: Array is the foundation ArrayList is built from Arrays Vector is built from ArrayList as well as Arrays However, please note that Vector and ArrayList are just exactly the same thing if you don't use it in the multithreading application. The only difference between Vector and ArrayList is that Vector is SYNCHRONIZED while ArrayList is NOT. So, it is make sense that Vector is running slower on the application that is not multi-threaded. You will see it in this program that you'll be creating as the part of this tutorial. If you're confused on what are all of this means, stop for a while and read the tutorial that I created about multithreading: http://www.programmerstalk.net/thread845.html Hopefully the code and the comments are self explanatory. There's nothing that's too amazing to explain. However, feel free to throw me any questions regarding this tutorial in this thread ![]() ** CODE IS TESTED AND WORK ON JVM 1.6 ** PHP Code: The result that I get: (may vary) Code:
Pay attention that it's E8, E9, and E9.. I assume that you know what are those means ![]() Note that Vector must be the slowest from all 3 because of the explanation that I made earlier. Thanx to whoever that helped me: Java API and my brain.. FOR ALL OF MY CLASSMATES: Better not just copy and paste! but well, you're lucky for coming to this site ![]() Last edited by HelloWorld : 07-17-2007 at 12:25 AM. |
| The Following User Says Thank You to HelloWorld For This Useful Post: | ||
Leech (07-17-2007) | ||
| |
| |||
| Very nice, however, your code seems to work only with n1. When I replace n1 with either n2 or n3, it throws an ArrayIndexOutOfBoundsException. The error points to the line if (numbers[j] < numbers[min]) in the ArraySelectionSort and the line where we take in n1, n2 or n3. Last edited by Leech : 07-17-2007 at 11:23 PM. |
| The Following User Says Thank You to For This Useful Post: | ||
HelloWorld (07-17-2007) | ||
![]() |
| Thread Tools | |
| Display Modes | |
| |