際際滷

際際滷Share a Scribd company logo
Bubble Sort


By: Yoo Lee & Gabrielle Ortiz
         Block 2A
Basic Introduction:
Bubble Sort is a simple yet effective sorting algorithm.
Data is placed adjacent to each other.
The sort starts from one end (the beginning), compares
2 adjacent data, and swaps them if they are in the
wrong order.
It moves on down the list and continues doing so.
When it reaches the end of the data, it starts over until
all the data is in the right order.
*As easy as the Bubble Sort is, it is sometimes
ineffective if there is a lot of data.
When to Use Bubble Sort


Not much use in the real world, but is a great learning tool
because its easy to understand and fast to implement.
Use when a fast algorithm is needed to sort:
   1.) an extremely small set of data (Ex. Trying to get the books on
   a library shelf back in order.)
                      or
   2.) a nearly sorted set of data. (Ex. Trying to decide which
   laptop to buy, because it is easier to compare pairs of laptops
   one at a time and decide which you prefer, than to look at them
   all at once and decide which was best.)
When to Not Use Bubble Sort


When dealing with a large set of data.

When you are looking for a quick algorithm.
Compared to other sorting algorithm, bubble sort is
really slow.
EXAMPLE




LETS MIX IT UP!!
EXAMPLE
EXAMPLE
EXAMPLE




Now this box will go through the list, swapping
numbers if the one previous is greater than the
one after, until the numbers are in order.
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE




Thats better.
EXAMPLE




Moving on.
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




Now the box has reached the end of the line
of numbers.
It will go back to the beginning and restart
the process
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE
EXAMPLE




WRONG ORDER!
SWITCH!
EXAMPLE
EXAMPLE




Moving on.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE
EXAMPLE




HEY its already in the right
order! No need to change.
EXAMPLE




YAY WERE DONE!
Links Used

http://stackoverflow.com/questions/276113/what-is-a-bubble-sort-good-
for

http://www.stoimen.com/blog/2012/02/20/computer-algorithms-
bubble-sort/


http://vimeo.com/4315697


http://www.algolist.net/Algorithms/Sorting/Bubble_sort
Ad

More Related Content

What's hot (20)

Quicksort Presentation
Quicksort PresentationQuicksort Presentation
Quicksort Presentation
irdginfo
How bubble sort works
How bubble sort worksHow bubble sort works
How bubble sort works
Gaurav Kumar
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
Mohammed Hussein
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
Meghaj Mallick
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
hydpy
Selection sort algorithm presentation, selection sort example using power point
Selection sort algorithm presentation, selection sort example using power point Selection sort algorithm presentation, selection sort example using power point
Selection sort algorithm presentation, selection sort example using power point
University of Science and Technology Chitttagong
Linear and binary search
Linear and binary searchLinear and binary search
Linear and binary search
Arjunsinh Jadeja
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
Tech_MX
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
Insertion sort
Insertion sort Insertion sort
Insertion sort
Monalisa Patel
AVL Tree
AVL TreeAVL Tree
AVL Tree
Dr Sandeep Kumar Poonia
Sorting types and Algorithms
Sorting types and AlgorithmsSorting types and Algorithms
Sorting types and Algorithms
Ali Khan
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
Omprakash Chauhan
Insertion sort
Insertion sortInsertion sort
Insertion sort
almaqboli
Singly linked list
Singly linked listSingly linked list
Singly linked list
Amar Jukuntla
Time complexity
Time complexityTime complexity
Time complexity
Katang Isip
Array data structure
Array data structureArray data structure
Array data structure
maamir farooq
Circular linked list
Circular linked listCircular linked list
Circular linked list
chauhankapil
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Trupti Agrawal
Quicksort Presentation
Quicksort PresentationQuicksort Presentation
Quicksort Presentation
irdginfo
How bubble sort works
How bubble sort worksHow bubble sort works
How bubble sort works
Gaurav Kumar
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
Mohammed Hussein
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
Meghaj Mallick
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
hydpy
Linear and binary search
Linear and binary searchLinear and binary search
Linear and binary search
Arjunsinh Jadeja
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
Tech_MX
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
Sorting types and Algorithms
Sorting types and AlgorithmsSorting types and Algorithms
Sorting types and Algorithms
Ali Khan
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
Omprakash Chauhan
Insertion sort
Insertion sortInsertion sort
Insertion sort
almaqboli
Singly linked list
Singly linked listSingly linked list
Singly linked list
Amar Jukuntla
Time complexity
Time complexityTime complexity
Time complexity
Katang Isip
Array data structure
Array data structureArray data structure
Array data structure
maamir farooq
Circular linked list
Circular linked listCircular linked list
Circular linked list
chauhankapil

Viewers also liked (20)

Bubblesort Algorithm
Bubblesort AlgorithmBubblesort Algorithm
Bubblesort Algorithm
Tobias Straub
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topic
Saddam Hussain
Bubble sort
Bubble sort Bubble sort
Bubble sort
rmsz786
Selection sort
Selection sortSelection sort
Selection sort
Jay Patel
3.1 bubble sort
3.1 bubble sort3.1 bubble sort
3.1 bubble sort
Krish_ver2
Selection sort
Selection sortSelection sort
Selection sort
smlagustin
Selection sort
Selection sortSelection sort
Selection sort
asra khan
Sorting
SortingSorting
Sorting
Ghaffar Khan
Merge sort
Merge sortMerge sort
Merge sort
Vidushi Pathak
Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]
Muhammad Hammad Waseem
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
Kaushal Shah
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Mohammed Hussein
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
multimedia9
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
3.4 selection sort
3.4 selection sort3.4 selection sort
3.4 selection sort
Krish_ver2
Selection sort
Selection sortSelection sort
Selection sort
stella D
Quick Sort
Quick SortQuick Sort
Quick Sort
priyankanaidu6
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
NeoClassical
The selection sort algorithm
The selection sort algorithmThe selection sort algorithm
The selection sort algorithm
David Burks-Courses
Mergesort
MergesortMergesort
Mergesort
luzenith_g
Bubblesort Algorithm
Bubblesort AlgorithmBubblesort Algorithm
Bubblesort Algorithm
Tobias Straub
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topic
Saddam Hussain
Bubble sort
Bubble sort Bubble sort
Bubble sort
rmsz786
Selection sort
Selection sortSelection sort
Selection sort
Jay Patel
3.1 bubble sort
3.1 bubble sort3.1 bubble sort
3.1 bubble sort
Krish_ver2
Selection sort
Selection sortSelection sort
Selection sort
smlagustin
Selection sort
Selection sortSelection sort
Selection sort
asra khan
Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]
Muhammad Hammad Waseem
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
Kaushal Shah
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
multimedia9
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
3.4 selection sort
3.4 selection sort3.4 selection sort
3.4 selection sort
Krish_ver2
Selection sort
Selection sortSelection sort
Selection sort
stella D
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
NeoClassical
Ad

Similar to Bubble Sort (20)

SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptx
Dr.Shweta
Sorting algorithm
Sorting algorithmSorting algorithm
Sorting algorithm
Muhammad Farhan
Bubble sorting lab manual
Bubble sorting lab manualBubble sorting lab manual
Bubble sorting lab manual
maamir farooq
COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5
Vishal Patil
Sorting algorithums > Data Structures & Algorithums
Sorting algorithums  > Data Structures & AlgorithumsSorting algorithums  > Data Structures & Algorithums
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
Presentation about Bubble Sort
Presentation about Bubble SortPresentation about Bubble Sort
Presentation about Bubble Sort
Md. Masud Rana Ashik
Sorting
SortingSorting
Sorting
Sameer Memon
Sorting
SortingSorting
Sorting
Varendra University Rajshahi-bangladesh
Sorting algos
Sorting algosSorting algos
Sorting algos
Omair Imtiaz Ansari
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Zaid Hameed
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Edward Blurock
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Eleonora Ciceri
Bubble sort
Bubble sortBubble sort
Bubble sort
SujataRao11
Bubble sort
Bubble sortBubble sort
Bubble sort
Abdelrahman Saleh
Sorting-Algorithms-A-Comprehensive-Guide.pptx
Sorting-Algorithms-A-Comprehensive-Guide.pptxSorting-Algorithms-A-Comprehensive-Guide.pptx
Sorting-Algorithms-A-Comprehensive-Guide.pptx
ReemEmad26
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptxMYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
ArjayBalberan1
Sorting Algorithm
Sorting AlgorithmSorting Algorithm
Sorting Algorithm
Abu Shaik saurab
Searching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structuresSearching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structures
PRIANKA R
Sorting
SortingSorting
Sorting
BHARATH KUMAR
Solving Problems with Algorithms, making things simple
Solving Problems with Algorithms, making things simpleSolving Problems with Algorithms, making things simple
Solving Problems with Algorithms, making things simple
Omuabe
SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptx
Dr.Shweta
Bubble sorting lab manual
Bubble sorting lab manualBubble sorting lab manual
Bubble sorting lab manual
maamir farooq
COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5
Vishal Patil
Sorting algorithums > Data Structures & Algorithums
Sorting algorithums  > Data Structures & AlgorithumsSorting algorithums  > Data Structures & Algorithums
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Zaid Hameed
Sorting-Algorithms-A-Comprehensive-Guide.pptx
Sorting-Algorithms-A-Comprehensive-Guide.pptxSorting-Algorithms-A-Comprehensive-Guide.pptx
Sorting-Algorithms-A-Comprehensive-Guide.pptx
ReemEmad26
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptxMYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
ArjayBalberan1
Searching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structuresSearching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structures
PRIANKA R
Solving Problems with Algorithms, making things simple
Solving Problems with Algorithms, making things simpleSolving Problems with Algorithms, making things simple
Solving Problems with Algorithms, making things simple
Omuabe
Ad

Bubble Sort