Bubble sort Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Playing computer with logic problems Please use speaker notes for additional information!
Advertisements

9.4: Inequalities and Absolute Value
Decision Maths 1 Sorting Algorithms Bubble Sort A V Ali : 1.Start at the beginning of the data set. 2.Compare the first two elements,
Give qualifications of instructors: DAP
CS 151 Digital Systems Design Lecture 19 Sequential Circuits: Latches.
Sorting CMSC 201. Sorting In computer science, there is often more than one way to do something. Sorting is a good example of this!
Exchange Sorting CS-240 Dick Steflik. Exchange Sort Strategy Make n-1 compares of adjacent items, swapping when needed Do this n-1 times with one less.
Selection Sorting CS-240 Dick Steflik. Selection Sort Strategy Find the largest item by making n-1 compares, swap the largest item with the last item.
Selection Sort
Adding rational numbers Essential question: How can you add rational numbers? Unit 1-2.
Grade 9 Integer Review Review Day 1.
Do Now Pass out calculators. Solve the following system by graphing: Graph paper is in the back. 5x + 2y = 9 x + y = -3 Solve the following system by using.
Scientific Notation.
Array - adding to array at run time Please see speaker notes for additional information!
Inequalities Section 10.2 Solving Inequalities. Property of Comparison For all real numbers a and b, one and only one of the following must be true: a
Decision Maths 1 Sorting Algorithm Shuttle Sort A V Ali : 1.Compare items 1 and 2; swap them if necessary 2.Compare 2 and 3; swap.
Notes on ADO from other projects Please use speaker notes for additional information!
Operations with Integers PowerPoint Created By: Ms. Cuervo.
Introduction to Excel Please use speaker notes for additional information!
Selection Sort Comparison Data Movement Sorted.
Selection Sort
Adding SubtractingMultiplyingDividingMiscellaneous.
Choose your characters and speech bubbles and drag them onto the slide Use the flip and rotate tools when needed and add text.
Adding Integers on a Number Line
BDE tutorial By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 13, 2008.
One Step Inequalities Review. Adding Negative Numbers: Same signs add and keep the sign Different signs subtract and keep the sign of the larger Subtracting.
Systems of equations 2 or more equations on the same graph.
All even numbers are divisible by 2 Even numbers are numbers that end with either 0, 2, 4, 6, or 8.
My Book of Divisibility. THE 2’s Example: 30, 42, 24, 76, 98, Must be an even number Number must end in a 0, 2, 4, 6, or 8.
Copyright 2013, 2009, 2005, 2001, Pearson, Education, Inc.
Bubble Sort. Sorting  Computers only use numeric values for sorting  Does this mean you cannot sort a file by a character field (such as last name or.
Sorting arrays/tables Top Down sort Please use speaker notes for additional information!
Sorting  Selection Sort  Bubble Sort  Insertion Sort  Merge Sort (chap. 14)  Quick Sort (chap. 14)  Heap Sort (chap. 9)
We have three different ways we can give direction when we are navigating around the world. These directions are all based off a compass. The three ways.
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
UNIT 7: TRANSFORMATIONS Final Exam Review. TOPICS TO INCLUDE  Types of Transformations  Translations  Reflections  Rotations  Dilations  Composition.
Addition. Mental Maths Learning Objective I am able to count in 2’s, 5’s, 7s, 10s, and ½’s.
MIPS Coding. Exercise – the bubble sort 7/9/2016week04-3.ppt2.
Processing multiple files
Solving Systems of Equations using Elimination
Sorting Algorithms.
MIPS instructions.
Draw pictures to indicate the subproblems middleMax solves at each level and the resulting maxPtr and PrevPtr for each on this linked list:
لجنة الهندسة الكهربائية
Please use speaker notes for additional information!
And now for something completely different . . .
Unit 1: Transformations
Choose your characters and speech bubbles and drag them onto the slide
Unit 6: Transformations
Choose your characters and speech bubbles and drag them onto the slide
Operations with Integers PowerPoint
test for not equal. Parallel arrays Two dimensional array.
Choose your characters and speech bubbles and drag them onto the slide
Divisibility Rules How to Check for Divisibility
(edited by Nadia Al-Ghreimil)
Summer of Gratitude Summer 2018 Name:.
Choose your characters and speech bubbles and drag them onto the slide
Complexity of a Bubble Sort
1) Latched, initial state Q =1
Adding with 9’s.
Adding with 10’s.
Choose your characters and speech bubbles and drag them onto the slide
Loading… Please Wait $ $ $100 $100 $100 $100 $100 $200 $200 $200 $200 $300 $300 $300 $300 $300 $400 $400 $400 $400 $400 $500 $500 $500 $500 $500.
Insert Presentation Title Here Insert Presentation Summary Here
Please insert Title Please insert sub-title 1
Adding fractions with like Denominators
Sorting.
Heaps By JJ Shepherd.
Adding ____ + 10.

Presentation transcript:

Bubble sort Please use speaker notes for additional information!

Bubble sort - PASS #1 Original numbers: SUB1 1 SUB Compare 5 which is what SUB1 is pointing to and 6 which is what SUB2 is pointing to. In this instance, 5 < 6 so nothing is done. After numbers: HOLDEND-PT 5 FLIP-CT 0

Bubble sort - PASS #1 Before numbers: SUB1 1 2 SUB Compare 6 which is what SUB1 is pointing to and 6 which is what SUB2 is pointing to. In this instance, 6 > 2 so flip and add one to the flip-ct.. After numbers: HOLD 6 END-PT 5 FLIP-CT

Bubble sort - PASS #1 Before numbers: SUB SUB Compare 6 which is what SUB1 is pointing to and 3 which is what SUB2 is pointing to. In this instance, 6 > 3 so flip and add one to the flip-ct.. After numbers: HOLD 6 END-PT 5 FLIP-CT

Bubble sort - PASS #1 Before numbers: SUB SUB Compare 6 which is what SUB1 is pointing to and 4 which is what SUB2 is pointing to. In this instance, 6 > 4 so flip and add one to the flip-ct.. After numbers: HOLD 6 END-PT 5 FLIP-CT

Bubble sort - PASS #1 Before numbers: SUB SUB At this point SUB2 is greater than END-PT so the pass is complete. After numbers: HOLDEND-PT 5 FLIP-CT

Bubble sort - Reset for PASS #2 Before numbers: SUB1 1 SUB2 2 HOLDEND-PT 5 4 FLIP-CT 0

Bubble sort - PASS #2 Before numbers: SUB1 1 SUB Compare 5 which is what SUB1 is pointing to and 2 which is what SUB2 is pointing to. In this instance, 5 >2 so a flip is done and 1 is added to flip-ct. After numbers: HOLD 5 END-PT 4 FLIP-CT

Bubble sort - PASS #2 Before numbers: SUB1 1 2 SUB Compare 5 which is what SUB1 is pointing to and 3 which is what SUB2 is pointing to. In this instance, 5 >3 so a flip is done and 1 is added to flip-ct. After numbers: HOLD 5 END-PT 4 FLIP-CT

Bubble sort - PASS #2 Before numbers: SUB SUB Compare 5 which is what SUB1 is pointing to and 4 which is what SUB2 is pointing to. In this instance, 5 >4 so a flip is done and 1 is added to flip-ct. After numbers: HOLD 5 END-PT 4 FLIP-CT

Bubble sort - PASS #2 Before numbers: SUB SUB At this point SUB2 is greater than END-PT so the pass is complete. After numbers: HOLDEND-PT 4 FLIP-CT END-PT signals the end of the pass. We can test either by using SUB2 > END-PT or SUB1 = END-PT.

Bubble sort - Reset for PASS #3 Before numbers: SUB1 1 SUB2 2 HOLDEND-PT FLIP-CT 0

Bubble sort - PASS #3 Before numbers: SUB1 1 SUB Compare 2 which is what SUB1 is pointing to and 3 which is what SUB2 is pointing to. In this instance, 2< 3 so a no flip is done. After numbers: HOLDEND-PT 3 FLIP-CT 0

Bubble sort - PASS #3 Before numbers: SUB1 1 2 SUB Compare 3 which is what SUB1 is pointing to and 4 which is what SUB2 is pointing to. In this instance, 3< 4 so a no flip is done. After numbers: HOLDEND-PT 3 FLIP-CT 0

Bubble sort - PASS #3 Before numbers: SUB SUB At this point SUB2 is greater than END-PT so the pass is complete. AND since there were no flips the sort is complete. After numbers: HOLDEND-PT 3 FLIP-CT 0 END-PT signals the end of the pass. We can test either by using SUB2 > END-PT or SUB1 = END-PT.