Results 1 to 2 of 2
Thread: Bubble sort Algorithm
- 06-06-2012, 05:06 AM #1
Member
- Join Date
- Sep 2011
- Posts
- 2
- Rep Power
- 0
Bubble sort Algorithm
I need some help with this code the out put isn't the required output, the required output being the Array sorted.
Java Code:class Derpyface { public static void main(String[] args){ int derp[]= {16, 100, 205, 8, 1, 3, 2, 5, 7, 6, 15, 10, 14}; for(int num = 0; num < derp.length; num++ ){ System.out.print(derp[num] + ","); } for(int array = derp.length -1; array > 0; array--){ for (int x = 0; x < derp.length -1; x++){ int temp1 = derp[x]; int temp2 = derp[x+1]; if(derp[x] > derp[x+1]){ derp[x] = temp2; derp[x=1]= temp1; } } } System.out.println(); for(int x = 0; x < derp.length; x++){ System.out.print(derp[x] + ","); } } }
- 06-06-2012, 07:38 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Bubble-sort method
By Mapisto in forum New To JavaReplies: 10Last Post: 12-27-2011, 09:43 PM -
Bubble sort
By pineapple in forum New To JavaReplies: 3Last Post: 04-25-2009, 12:45 AM -
Trouble w/ Bubble Sort
By bri1547 in forum New To JavaReplies: 4Last Post: 08-01-2008, 04:41 PM -
How to sort a list using Bubble sort algorithm
By Java Tip in forum AlgorithmsReplies: 3Last Post: 04-29-2008, 08:04 PM -
need help with bubble sort
By lowpro in forum New To JavaReplies: 3Last Post: 12-17-2007, 05:27 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks