What is Bubble sort in c language and how does it work?

@Sureoi (176)
Philippines
December 31, 2012 3:10am CST
I am a first year IT student and we are focusing on C programming language. My professor told us to study about bubble sort while we're on vacation. I'm sorry for asking this very basic topic but I'm really too slow to understand this on my own. I really need help. Please and Thanks in advance! ^^
2 responses
@dollar3235 (2062)
• India
1 Jan 13
Hi Sureoi, I see that owlwings has already provided you the basics of bubblesort, however, I would suggest you to check this video, in this video, they've explained how it works: http://www.youtube.com/watch?v=P00xJgWzz2c You can ask if you've any doubt related to this.
@Sureoi (176)
• Philippines
2 Jan 13
Thanks alot buddy and thanks to you too, owlwings. I did'nt expect that bubble sort was that very simple hehe but still I have to strive hard and improve my skills in tracing and also in coding. My prof said that we should practice tracing. Is tracing really important?
• India
2 Jan 13
Hi Sureoi, Generally, when you are new in college, there will be a lot of hype created for programming languages, everyone will have their own story to prove how tough the programming language is but the fact is, it's very easy and interesting. It's always good to trace your good, it gives you a fair idea if your code is syntactically and logically correct or not. However, you can have your own approach towards programming at the end of the day, you should be able to program, that's what is required.
• India
2 Jan 13
I'm sorry. It's always good to trace your program*
@owlwings (43910)
• Cambridge, England
31 Dec 12
Before you start programming any kind of sort in a particular language, it is helpful to understand how it works in 'pseudocode' or graphically. The bubble sort is one of the simplest (and least efficient) sorting algorithms. It takes the elements of data in pairs and swaps the values if the second element is smaller/higher than the first. It requires many passes through the data, each pass becoming progressively less as more of the data is marked as 'sorted'. This page describes the algorithm simply and graphically: http://www.sorting-algorithms.com/bubble-sort It also shows the other common sort algorithms and you can see in real time how each one deals with various states of data. You might also get more understanding by reading the Wikipedia entry: http://en.wikipedia.org/wiki/Bubble_sort