Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



What is bubble sort in data structure

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 04-01-2011
Member
 
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.

Reply With Quote
  #2  
Old 04-01-2011
Member
 
Join Date: Apr 2009
Posts: 562
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.
Reply With Quote
  #3  
Old 04-01-2011
Member
 
Join Date: May 2009
Posts: 517
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.
Reply With Quote
  #4  
Old 04-01-2011
Member
 
Join Date: May 2009
Posts: 497
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What is bubble sort in data structure"
Thread Thread Starter Forum Replies Last Post
What is the use of insertion sort in data structure? Venugopala Software Development 3 04-01-2011 01:41 AM
What do you mean by Merge sort in data structure fLUTE Software Development 3 04-01-2011 01:12 AM
What is the difference between binary tree sort and heap sort in data structure sRIPRIYA Software Development 3 04-01-2011 12:25 AM
what is Quick Sort or partition Exchanger in data structure Venugopala Software Development 3 03-01-2011 07:47 AM
How to use Bubble sort in C# to sort parallel arraylists Ground 0 Software Development 3 03-08-2009 12:12 PM


All times are GMT +5.5. The time now is 01:18 PM.