what is Bubble sorting

what is Bubble sorting - Selamat datang di situs media global terbaru Xivanki, Pada halaman ini kami menyajikan informasi tentang what is Bubble sorting !! Semoga tulisan dengan kategori ini bermanfaat bagi anda. Silahkan sebarluaskan postingan what is Bubble sorting ini ke social media anda, Semoga rezeki berlimpah ikut dimudahkan Allah bagi anda, Lebih jelas infonya lansung dibawah -->


Bubble sort
Bubble sort  sometimes referred to as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, compaire Bring each pair of adjacent items and swapping them if they are in the wrong order
The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted
The algorithm gets its name from the way smaller elements "bubble" to the top of the list.
Because it only uses comparisons to operate on elements, it is a comparison sort

 Performance of bubble sort

Rabbits and turtles

The positions of the elements in bubble sort will play a large part in determining its performance.
Large elements at the beginning of the list do not pose a problem, as they are quickly swapped.
Small elements towards the end, however, move to the beginning extremely slowly.
This has led to these types of elements being named rabbits and turtles respectively.
Various efforts have been made to eliminate turtles to improve upon the speed of bubble sort


Complexity of bubble sort

  • It is measured in terms of number of comparisons. 
  •  It requires n-1 comparisons to sort list of n numbers  

Algorithm of bubble sort

(Bubble Sort) BUBBLE (DATA, N)

1.Repeat steps 2 and 3 for K= 1 to N-1

2. Set PTR:=1 [initializes pass pointer PTR]

3.ReRpeat while PTR <= N-K [executes pass]

           (a) If DATA[PTR] > DATA[PTR+1], then:

           Interchange DATA[PTR] and DATA[PTR+1]

  [End of if structure]

            (b) Set PTR:= PTR+1

         [end of inner loop]

  [end of step 1 outer loop]

4.    Exit
 





Demikian info what is Bubble sorting, Semoga dengan adanya postingan ini, Anda sudah benar benar menemukan informasi yang memang sedang anda butuhkan saat ini. Bagikan informasi what is Bubble sorting ini untuk orang orang terdekat anda, Bagikan infonya melalui fasilitas layanan Share Facebook maupun Twitter yang tersedia di situs ini.

Previous Post Next Post