Bubble sort a best presentation topic

  • View
    197

  • Download
    0

Embed Size (px)

Text of Bubble sort a best presentation topic

  1. 1. A Presentation topic for c++ topic A Good style and appreciated
  2. 2. Sorting Sorting takes an unordered collection and makes it an ordered one. 512354277 101 1 2 3 4 5 6 5 12 35 42 77 101 1 2 3 4 5 6
  3. 3. Introduction: Bubble Sort Also called Exchange sort. It repeatedly visits the array and compares two items at a time. It swaps these two items if they are in the wrong order. It continues to visit the array until no swaps are needed that means the array is sorted.
  4. 4. 674523 14 6 3398 42 The First Bubble Up
  5. 5. 674523 14 6 3398 42 The First Bubble Up
  6. 6. 674523 14 6 3398 42 Swap The First Bubble Up
  7. 7. 674598 14 6 3323 42 Swap The First Bubble Up
  8. 8. 674598 14 6 3323 42 The First Bubble Up
  9. 9. 674598 14 6 3323 42 Swap The First Bubble Up
  10. 10. 679845 14 6 3323 42 Swap The First Bubble Up
  11. 11. 679845 14 6 3323 42 The First Bubble Up
  12. 12. 679845 14 6 3323 42 Swap The First Bubble Up
  13. 13. 671445 98 6 3323 42 Swap The First Bubble Up
  14. 14. 671445 98 6 3323 42 The First Bubble Up
  15. 15. 671445 98 6 3323 42 Swap The First Bubble Up
  16. 16. 671445 6 98 3323 42 Swap The First Bubble Up
  17. 17. 671445 6 98 3323 42 The First Bubble Up
  18. 18. 671445 6 98 3323 42 Swap The First Bubble Up
  19. 19. 981445 6 67 3323 42 Swap The First Bubble Up
  20. 20. 981445 6 67 3323 42 The First Bubble Up
  21. 21. 981445 6 67 3323 42 Swap The First Bubble Up
  22. 22. 331445 6 67 9823 42 Swap The First Bubble Up
  23. 23. 331445 6 67 9823 42 The First Bubble Up
  24. 24. 331445 6 67 9823 42 Swap The First Bubble Up
  25. 25. 331445 6 67 4223 98 Swap The First Bubble Up
  26. 26. 331445 6 67 4223 98 Finished first Bubble Up The First Bubble Up
  27. 27. The Second Bubble Up 331445 6 67 4223 98
  28. 28. The Second Bubble Up 331445 6 67 4223 98 No Swap
  29. 29. The Second Bubble Up 331445 6 67 4223 98
  30. 30. The Second Bubble Up 331445 6 67 4223 98 Swap
  31. 31. The Second Bubble Up 334514 6 67 4223 98 Swap
  32. 32. The Second Bubble Up 334514 6 67 4223 98
  33. 33. The Second Bubble Up 334514 6 67 4223 98 Swap
  34. 34. The Second Bubble Up 33614 45 67 4223 98 Swap
  35. 35. The Second Bubble Up 33614 45 67 4223 98
  36. 36. The Second Bubble Up 33614 45 67 4223 98 No Swap
  37. 37. The Second Bubble Up 33614 45 67 4223 98
  38. 38. The Second Bubble Up 33614 45 67 4223 98 Swap
  39. 39. The Second Bubble Up 67614 45 33 4223 98 Swap
  40. 40. The Second Bubble Up 67614 45 33 4223 98
  41. 41. The Second Bubble Up 67614 45 33 4223 98 Swap
  42. 42. The Second Bubble Up 42614 45 33 6723 98 Swap
  43. 43. 42614 45 33 6723 98 Finished second Bubble Up The Second Bubble Up
  44. 44. The Third Bubble Up 42614 45 33 6723 98
  45. 45. The Third Bubble Up 42614 45 33 6723 98 Swap
  46. 46. The Third Bubble Up 42623 45 33 6714 98 Swap
  47. 47. The Third Bubble Up 42623 45 33 6714 98
  48. 48. The Third Bubble Up 42623 45 33 6714 98 Swap
  49. 49. The Third Bubble Up 42236 45 33 6714 98 Swap
  50. 50. The Third Bubble Up 42236 45 33 6714 98
  51. 51. The Third Bubble Up 42236 45 33 6714 98 No Swap
  52. 52. The Third Bubble Up 42236 45 33 6714 98
  53. 53. The Third Bubble Up 42236 45 33 6714 98 Swap
  54. 54. The Third Bubble Up 42236 33 45 6714 98 Swap
  55. 55. The Third Bubble Up 42236 33 45 6714 98
  56. 56. The Third Bubble Up 42236 33 45 6714 98 Swap
  57. 57. The Third Bubble Up 45236 33 42 6714 98 Swap
  58. 58. After Third Pass of Outer Loop 45236 33 42 6714 98 Finished third Bubble Up
  59. 59. The Fourth Bubble Up 45236 33 42 6714 98
  60. 60. The Fourth Bubble Up 45236 33 42 6714 98 Swap
  61. 61. The Fourth Bubble Up 452314 33 42 676 98 Swap
  62. 62. The Fourth Bubble Up 452314 33 42 676 98
  63. 63. The Fourth Bubble Up 452314 33 42 676 98 No Swap
  64. 64. The Fourth Bubble Up 452314 33 42 676 98
  65. 65. The Fourth Bubble Up 452314 33 42 676 98 No Swap
  66. 66. The Fourth Bubble Up 452314 33 42 676 98
  67. 67. The Fourth Bubble Up 452314 33 42 676 98 No Swap
  68. 68. 452314 33 42 676 98 Finished fourth Bubble Up After Fourth Pass of Outer Loop
  69. 69. The Fifth Bubble Up 452314 33 42 676 98
  70. 70. The Fifth Bubble Up 452314 33 42 676 98 No Swap
  71. 71. The Fifth Bubble Up 452314 33 42 676 98
  72. 72. The Fifth Bubble Up 452314 33 42 676 98 No Swap
  73. 73. The Fifth Bubble Up 452314 33 42 676 98
  74. 74. The Fifth Bubble Up 452314 33 42 676 98 No Swap
  75. 75. After Fifth Pass of Outer Loop 452314 33 42 676 98 Finished fifth Bubble Up
  76. 76. 452314 33 42 676 98 We did not do any swapping, so all of the other elements must be correctly placed. We can skip the last two passes of the outer loop.
  77. 77. Program void main() { int arr[5],i,j,tem; cout