Saturday, February 19, 2011

Alice In Wonderland Who Am I Monologue

insertion sort .... BUBBLE METHOD What is it? EXTRA POINTS

Good day, this song is already saturated on the Internet but I will give only the most important information in this topic.




DEFINITION
This sorting algorithm (downward or upward) is based on the principle of comparing pairs of adjacent elements and exchange among themselves until they are all sorted. EXAMPLE



Supogamos you want to rank in order of the vector or list ascedente

50 ---- 15 --- 56 --- 14 --- 35 --- 1 --- - 12 ---- 9
A [1]-A [2]-A [3]-A [4]-A [5]-A [6]-A [7]-A [8]

steps to order are:
1 .- Compare A [1] and A [2] , if they are in order, are kept, otherwise, are exchanged between them. 2 .-
below compares the elements 2 and 3 are exchanged again if necessary.
3 .- The process continues until each element of the vector has been compared with their adjacent elements and exchanges have been made necessary.

In pseudocode main thing is (the method):

from i = 1 to 7 do
if element [i]> element [i +1] then
aux = A [i]
A [i] = A [i +1]
A [i +1] = aux
fin_si
fin_desde

NOTE: the words in bold are those of language.

FACTS METHOD OF BUBBLE

This is the simplest and oldest method to sort a data set is also the slowest
.
bubble
The algorithm has two loops for internal
cross the vector element by comparing the j- th -1 with the element with the j-th
element and if this is greater makes a change from the elements.

With two internal loops the behavior is generally O (n ^ 2), and best
conditions behaves like O (n).

This is a link to an example in C language code
http://rapidshare.com/files/448851279/metodo_burbuja.c

I'm open to any doubt or error could have caused .

0 comments:

Post a Comment