• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java first semester programming, could use some help!

OverVolt

Lifer
Well, just wondering how i can sort a small array of integers from smallest-largest and largest-smallest. Just tell me the basic idea, i can code it myself. All the program has to do is take in a set of integers into an array, insert, delete, calc average, mode, and median, i figured all of that out on my own, but sorting has me stumped.
 
There would be two ways to go about it. The first is to write your own sorting algorithm. For a beginner this would typically be something like a buble sort or an insertion sort (do you know either of these?). The other is to use Collections.sort(). That will require you to put your numbers into a List which you may or may not know how to do at this point but it's definitely the less-work solution 🙂
 
Thanks 😛!

i googled bubble sorts, lots of helpful info there. Gave me the general idea of what i need to be doing, just need to intergrate into the program so that after i sort it doesn't throw off the ins/del/avg stuff. I'll try and see if i can make a quick menu and do a quick sort too.
 
I could give you my "notfred" algorithm, but then again it takes an average of 40 seconds to sort 5 items.
 
lol notfred, give him one of the most difficult sorting algorithms.

look at bubble sort and insertion sort. they are the easiest. order n^2, but the easiest.

-silver
 
Back
Top