Talk:Sorting algorithms/Bubble sort: Difference between revisions

→‎This is bubble sort?: Knuth is my homeboy
(bubble is bubble)
(→‎This is bubble sort?: Knuth is my homeboy)
Line 17:
swap(a+i);
}
 
--IanOsgood
 
:That may be "your bubble short", but it is definitely not Bubble Sort. The basic feature of Bubble Sort is that it finishes sorting when there were no more swaps needed. Because of this, the best case execution time of Bubble Sort is O(N), i.e. linear time, which is significantly better than that of QuickSort, O(N*Log(N)). --[[User:PauliKL|PauliKL]] 18:51, 24 November 2008 (UTC)
Line 37 ⟶ 39:
 
:::I'd like to say mine: the pseudocode proposed is a BubbleSort; as far as I remember, BubbleSorting can be implementend in both the way, and still is BubbleSort. The name BubbleSort comes since it let the smaller elements get on the top like bubbles (in water?), letting the lighter bubble pass beyond the near heavier bubble. The principle is the same, but the pseudocode is more efficient since there's a test that avoid looping without swapping (while in the previous code extern loop must be executed even if the inner loop has not swapped anything) --[[User:ShinTakezou|ShinTakezou]] 17:31, 9 December 2008 (UTC)
 
: As the person who originally asked the question, I acknowledge that I was mistaken about the definition of "Bubble Sort". The given algorithm was the first sorting algorithm I learned, but I am happy to implement the better one for this task. The task's bubble sort is the one analyzed by Knuth. I mean... '''KNUTH!''' /discussion --[[User:IanOsgood|IanOsgood]] 18:04, 9 December 2008 (UTC)
Anonymous user