|
| ||||||||||
| Tags: array, array list, bubble sort, data structure, for loop |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| What is bubble sort in data structure
|
|
#2
| |||
| |||
| 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
| |||
| |||
| 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
| |||
| |||
| 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 |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |