Results 1 to 4 of 4

Thread: What is bubble sort in data structure

  1. #1
    Join Date
    Dec 2010
    Posts
    10

    What is bubble sort in data structure

    Hello friends, I am aware of the process sorting and some of its type not all. I wanted to know the bubble sorting. I have no ideas about it. I also wanted the code for bubble sorting. I have tried it but I was unable to get the appropriate output. If anyone is having any clue or idea about this query then please let me know so that my concepts are cleared and I can get the appropriate output.

  2. #2
    Join Date
    Apr 2009
    Posts
    569

    Re: What is bubble sort in data structure

    In this method 0th element is compared with the 1st element. If it is found to be greater than the 1st element then they are interchanged .Then the first element is compared with the 2nd element, if it is found to be greater, then they are interchanged. In this way all the elements are compared with the next element and interchanged if required. This is the first iteration and on completing this iteration the last element gets placed at the last position.

  3. #3
    Join Date
    May 2009
    Posts
    529

    Re: What is bubble sort in data structure

    Similarly in the second iteration the comparisons are made till the last but one element and this time the second largest element gets placed at the second last position in the list. As a result after all the iteration the list becomes a sorted list. You must make sure that the list is sorted and compared properly after the iteration process is over. Many of them mistakes while comparing when iteration is done.

  4. #4
    Join Date
    May 2009
    Posts
    511

    Re: What is bubble sort in data structure

    Code:
    Declare array AA
       store elements in to array AA
      
         Repeat for i= 0 to i<=3                        // for passess
              Repeat for j=0 to j<=3-i                    // for comparision
                   check  if AA[j] >AA[j+1]             // for exchanging largest number
                                int  k = AA[j]
                                   AA[j]=AA[j+1]
                              AA[j+1] =k
            increment j by 1            
              repeat step 6 to 9
            End of loop
      increment i by 1    
         repeat step  5 to 11
        end of loop

Similar Threads

  1. What is the use of insertion sort in data structure?
    By Venugopala in forum Software Development
    Replies: 3
    Last Post: 04-01-2011, 02:41 AM
  2. What do you mean by Merge sort in data structure
    By fLUTE in forum Software Development
    Replies: 3
    Last Post: 04-01-2011, 02:12 AM
  3. Replies: 3
    Last Post: 04-01-2011, 01:25 AM
  4. what is Quick Sort or partition Exchanger in data structure
    By Venugopala in forum Software Development
    Replies: 3
    Last Post: 03-01-2011, 08:47 AM
  5. How to use Bubble sort in C# to sort parallel arraylists
    By Ground 0 in forum Software Development
    Replies: 3
    Last Post: 03-08-2009, 12:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,616,360.32928 seconds with 17 queries