Results 1 to 6 of 6
  1. #1
    Fatz is offline Member
    Join Date
    May 2012
    Posts
    12
    Rep Power
    0

    Default Bubble sort algorithms

    Is this considered a bubble sort algorithm, or does it have to swap for it to be completed?

    Java Code:
    public static boolean sort(int[]D)
    	{
    		int D[]={4,9,9,2,8};
    		for(int i=0; i<D.length-1; i++)
    		{
    			if(D[i] >D[i+1])
    			{
    				return false;
    			}
    		}
    		System.out.println(D);
    		return true;
    		
    	}

  2. #2
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: Bubble sort algorithms

    See Optimizing bubble sort Pseudocode in Bubble sort - Wikipedia, the free encyclopedia.

  3. #3
    Fatz is offline Member
    Join Date
    May 2012
    Posts
    12
    Rep Power
    0

    Default Re: Bubble sort algorithms

    So you do have to swap?

  4. #4
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: Bubble sort algorithms

    Yes. That is what is shown in the bubble sort Pseudocode.

    Currently, your program is not sorting anything.

  5. #5
    Fatz is offline Member
    Join Date
    May 2012
    Posts
    12
    Rep Power
    0

    Default Re: Bubble sort algorithms

    Thanks, and really sorry for posting such a stupid question.

  6. #6
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Bubble sort algorithms

    No honest questions are stupid ones. Let us know when we can help!

Similar Threads

  1. Bubble-sort method
    By Mapisto in forum New To Java
    Replies: 10
    Last Post: 12-27-2011, 10:43 PM
  2. Bubble sort
    By pineapple in forum New To Java
    Replies: 3
    Last Post: 04-25-2009, 01:45 AM
  3. How to sort a list using Bubble sort algorithm
    By Java Tip in forum Algorithms
    Replies: 3
    Last Post: 04-29-2008, 09:04 PM
  4. Bubble Sort in Java
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-15-2008, 08:42 PM
  5. need help with bubble sort
    By lowpro in forum New To Java
    Replies: 3
    Last Post: 12-17-2007, 06:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •