Upcoming SlideShare
×

# Sorting bubble-sort anim

1,313 views

Published on

4 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,313
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
162
0
Likes
4
Embeds 0
No embeds

No notes for slide

### Sorting bubble-sort anim

1. 1. Sorting Algorithms 1. Selection 2. Bubble 3. Insertion 4. Merge 5. Quick 6. Shell
2. 2. An Animated Example 674523 14 6 3398 42 0 1 2 3 4 5 6 7 pos_akhir index 6 N 8 did_swap true
3. 3. An Animated Example 674523 14 6 3398 42 pos_akhir index 6 0 N 8 did_swap false 0 1 2 3 4 5 6 7
4. 4. An Animated Example 674523 14 6 3398 42 pos_akhir index 6 0 N 8 Swap did_swap false 0 1 2 3 4 5 6 7
5. 5. An Animated Example 674598 14 6 3323 42 pos_akhir index 6 0 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
6. 6. An Animated Example 674598 14 6 3323 42 pos_akhir index 6 1 N 8 did_swap true 0 1 2 3 4 5 6 7
7. 7. An Animated Example 674598 14 6 3323 42 pos_akhir index 6 1 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
8. 8. An Animated Example 679845 14 6 3323 42 pos_akhir index 6 1 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
9. 9. An Animated Example 679845 14 6 3323 42 pos_akhir index 6 2 N 8 did_swap true 0 1 2 3 4 5 6 7
10. 10. An Animated Example 679845 14 6 3323 42 pos_akhir index 6 2 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
11. 11. An Animated Example 671445 98 6 3323 42 pos_akhir index 6 2 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
12. 12. An Animated Example 671445 98 6 3323 42 pos_akhir index 6 3 N 8 did_swap true 0 1 2 3 4 5 6 7
13. 13. An Animated Example 671445 98 6 3323 42 pos_akhir index 6 3 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
14. 14. An Animated Example 671445 6 98 3323 42 pos_akhir index 6 3 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
15. 15. An Animated Example 671445 6 98 3323 42 pos_akhir index 6 4 N 8 did_swap true 0 1 2 3 4 5 6 7
16. 16. An Animated Example 671445 6 98 3323 42 pos_akhir index 6 4 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
17. 17. An Animated Example 981445 6 67 3323 42 pos_akhir index 6 4 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
18. 18. An Animated Example 981445 6 67 3323 42 pos_akhir index 6 5 N 8 did_swap true 0 1 2 3 4 5 6 7
19. 19. An Animated Example 981445 6 67 3323 42 pos_akhir index 6 5 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
20. 20. An Animated Example 331445 6 67 9823 42 pos_akhir index 6 5 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
21. 21. An Animated Example 331445 6 67 9823 42 pos_akhir index 6 6 N 8 did_swap true 0 1 2 3 4 5 6 7
22. 22. An Animated Example 331445 6 67 9823 42 pos_akhir index 6 6 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
23. 23. An Animated Example 331445 6 67 4223 98 pos_akhir index 6 6 N 8 Swap did_swap true 0 1 2 3 4 5 6 7
24. 24. After First Pass of Outer Loop 331445 6 67 4223 98 pos_akhir index 6 7 N 8 Finished first “Bubble Up” did_swap true 0 1 2 3 4 5 6 7
25. 25. The Second “Bubble Up” 331445 6 67 4223 98 pos_akhir index 5 0 N 8 did_swap false 0 1 2 3 4 5 6 7
26. 26. The Second “Bubble Up” 331445 6 67 4223 98 pos_akhir index 5 0 N 8 did_swap false No Swap 0 1 2 3 4 5 6 7
27. 27. The Second “Bubble Up” 331445 6 67 4223 98 pos_akhir index 5 1 N 8 did_swap false 0 1 2 3 4 5 6 7
28. 28. The Second “Bubble Up” 331445 6 67 4223 98 pos_akhir index 5 1 N 8 did_swap false Swap 0 1 2 3 4 5 6 7
29. 29. The Second “Bubble Up” 334514 6 67 4223 98 pos_akhir index 5 1 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
30. 30. The Second “Bubble Up” 334514 6 67 4223 98 pos_akhir index 5 2 N 8 did_swap true 0 1 2 3 4 5 6 7
31. 31. The Second “Bubble Up” 334514 6 67 4223 98 pos_akhir index 5 2 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
32. 32. The Second “Bubble Up” 33614 45 67 4223 98 pos_akhir index 5 2 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
33. 33. The Second “Bubble Up” 33614 45 67 4223 98 pos_akhir index 5 3 N 8 did_swap true 0 1 2 3 4 5 6 7
34. 34. The Second “Bubble Up” 33614 45 67 4223 98 pos_akhir index 5 3 N 8 did_swap true No Swap 0 1 2 3 4 5 6 7
35. 35. The Second “Bubble Up” 33614 45 67 4223 98 pos_akhir index 5 4 N 8 did_swap true 0 1 2 3 4 5 6 7
36. 36. The Second “Bubble Up” 33614 45 67 4223 98 pos_akhir index 5 4 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
37. 37. The Second “Bubble Up” 67614 45 33 4223 98 pos_akhir index 5 4 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
38. 38. The Second “Bubble Up” 67614 45 33 4223 98 pos_akhir index 5 5 N 8 did_swap true 0 1 2 3 4 5 6 7
39. 39. The Second “Bubble Up” 67614 45 33 4223 98 pos_akhir index 5 5 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
40. 40. The Second “Bubble Up” 42614 45 33 6723 98 pos_akhir index 5 5 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
41. 41. After Second Pass of Outer Loop 42614 45 33 6723 98 pos_akhir index 5 6 N 8 did_swap true Finished second “Bubble Up” 0 1 2 3 4 5 6 7
42. 42. The Third “Bubble Up” 42614 45 33 6723 98 pos_akhir index 4 0 N 8 did_swap false 0 1 2 3 4 5 6 7
43. 43. The Third “Bubble Up” 42614 45 33 6723 98 pos_akhir index 4 0 N 8 did_swap false Swap 0 1 2 3 4 5 6 7
44. 44. The Third “Bubble Up” 42623 45 33 6714 98 pos_akhir index 4 0 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
45. 45. The Third “Bubble Up” 42623 45 33 6714 98 pos_akhir index 4 1 N 8 did_swap true 0 1 2 3 4 5 6 7
46. 46. The Third “Bubble Up” 42623 45 33 6714 98 pos_akhir index 4 1 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
47. 47. The Third “Bubble Up” 42236 45 33 6714 98 pos_akhir index 4 1 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
48. 48. The Third “Bubble Up” 42236 45 33 6714 98 pos_akhir index 4 2 N 8 did_swap true 0 1 2 3 4 5 6 7
49. 49. The Third “Bubble Up” 42236 45 33 6714 98 pos_akhir index 4 2 N 8 did_swap true No Swap 0 1 2 3 4 5 6 7
50. 50. The Third “Bubble Up” 42236 45 33 6714 98 pos_akhir index 4 3 N 8 did_swap true 0 1 2 3 4 5 6 7
51. 51. The Third “Bubble Up” 42236 45 33 6714 98 pos_akhir index 4 3 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
52. 52. The Third “Bubble Up” 42236 33 45 6714 98 pos_akhir index 4 3 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
53. 53. The Third “Bubble Up” 42236 33 45 6714 98 pos_akhir index 4 4 N 8 did_swap true 0 1 2 3 4 5 6 7
54. 54. The Third “Bubble Up” 42236 33 45 6714 98 pos_akhir index 4 4 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
55. 55. The Third “Bubble Up” 45236 33 42 6714 98 pos_akhir index 4 4 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
56. 56. After Third Pass of Outer Loop 45236 33 42 6714 98 pos_akhir index 4 5 N 8 did_swap true Finished third “Bubble Up” 0 1 2 3 4 5 6 7
57. 57. The Fourth “Bubble Up” 45236 33 42 6714 98 pos_akhir index 3 0 N 8 did_swap false 0 1 2 3 4 5 6 7
58. 58. The Fourth “Bubble Up” 45236 33 42 6714 98 pos_akhir index 3 0 N 8 did_swap false Swap 0 1 2 3 4 5 6 7
59. 59. The Fourth “Bubble Up” 452314 33 42 676 98 pos_akhir index 3 0 N 8 did_swap true Swap 0 1 2 3 4 5 6 7
60. 60. The Fourth “Bubble Up” 452314 33 42 676 98 pos_akhir index 3 1 N 8 did_swap true 0 1 2 3 4 5 6 7
61. 61. The Fourth “Bubble Up” 452314 33 42 676 98 pos_akhir index 3 1 N 8 did_swap true No Swap 0 1 2 3 4 5 6 7
62. 62. The Fourth “Bubble Up” 452314 33 42 676 98 pos_akhir index 3 2 N 8 did_swap true 0 1 2 3 4 5 6 7
63. 63. The Fourth “Bubble Up” 452314 33 42 676 98 pos_akhir index 3 2 N 8 did_swap true No Swap 0 1 2 3 4 5 6 7
64. 64. The Fourth “Bubble Up” 452314 33 42 676 98 pos_akhir index 3 3 N 8 did_swap true 0 1 2 3 4 5 6 7
65. 65. The Fourth “Bubble Up” 452314 33 42 676 98 pos_akhir index 3 3 N 8 did_swap true No Swap 0 1 2 3 4 5 6 7
66. 66. After Fourth Pass of Outer Loop 452314 33 42 676 98 pos_akhir index 3 4 N 8 did_swap true Finished fourth “Bubble Up” 0 1 2 3 4 5 6 7
67. 67. The Fifth “Bubble Up” 452314 33 42 676 98 pos_akhir index 2 0 N 8 did_swap false 0 1 2 3 4 5 6 7
68. 68. The Fifth “Bubble Up” 452314 33 42 676 98 pos_akhir index 2 0 N 8 did_swap false No Swap 0 1 2 3 4 5 6 7
69. 69. The Fifth “Bubble Up” 452314 33 42 676 98 pos_akhir index 2 1 N 8 did_swap false 0 1 2 3 4 5 6 7
70. 70. The Fifth “Bubble Up” 452314 33 42 676 98 pos_akhir index 2 1 N 8 did_swap false No Swap 0 1 2 3 4 5 6 7
71. 71. The Fifth “Bubble Up” 452314 33 42 676 98 pos_akhir index 2 2 N 8 did_swap false 0 1 2 3 4 5 6 7
72. 72. The Fifth “Bubble Up” 452314 33 42 676 98 pos_akhir index 2 2 N 8 did_swap false No Swap 0 1 2 3 4 5 6 7
73. 73. After Fifth Pass of Outer Loop 452314 33 42 676 98 pos_akhir index 2 3 N 8 did_swap false Finished fifth “Bubble Up” 0 1 2 3 4 5 6 7
74. 74. Finished “Early” 452314 33 42 676 98 pos_akhir index 2 3 N 8 did_swap false We didn’t do any swapping, so all of the other elements must be correctly placed. We can “skip” the last two passes of the outer loop. 0 1 2 3 4 5 6 7