Example { 1 –11 50 6 8 –1} Use Bubble Sort (sort in increasing order} After first pass {-11 1 6 8 –1 50} After Second Pass {-11 1 6 -1 8 50} After.

Slides:



Advertisements
Similar presentations
22C:19 Discrete Math Algorithms and Complexity
Advertisements

Bubble Sort Example 9, 6, 2, 12, 11, 9, 3, 7 6, 9, 2, 12, 11, 9, 3, 7 Bubblesort compares the numbers in pairs from left to right exchanging.
Data Structures by R.S. Chang, Dept. CSIE, NDHU1 Chapter 2 Algorithm Design Human Problems Result Input Data Structures Processing Output Data Structures.
Chapter 3 With Question/Answer Animations 1. Chapter Summary Algorithms Example Algorithms Algorithmic Paradigms Growth of Functions Big-O and other Notation.
Algorithms Chapter 3 Sec 3.1 &3.2 With Question/Answer Animations.
CSE115/ENGR160 Discrete Mathematics 02/28/12
Identify and state the value of a penny, nickel, dime, quarter Level 1 CLICK HERE TO START LEVEL 1.
Problem Solving and Program Design Programming. COMP102 Prog Fundamentals I : Problem Solving and Program Design/Slide 2 Problem Solving Process l Define.
CSE115/ENGR160 Discrete Mathematics 03/03/11 Ming-Hsuan Yang UC Merced 1.
In Class Exercises. TV  Think about your television as an object.  You send messages to it using the remote control. What messages can you send?  What.
I wonder who has more money…. 1 dollar, 3 nickels, 5 dimes 6 dimes, 3 pennies, 5 quarters 8 pennies, 6 nickels, 3 dimes 2 half dollars, 5 pennies, 8 nickels.
Math Meeting Write today’s date ____________________ What was (will be) the date on the fourth Sunday of this month? _________________________ Time: ______________.
Algorithms Section 3.1. Problems and Algorithms In many domains there are key general problems that ask for output with specific properties when given.
Math Review Show each amount using the fewest number of coins. 98¢ pennies nickels dimes quarters 1.
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
Section 3.1: Proof Strategy Now that we have a fair amount of experience with proofs, we will start to prove more difficult theorems. Our experience so.
22C:19 Discrete Structures Algorithms and Complexity Fall 2014 Sukumar Ghosh.
Math Meeting Write today’s date __________________________ Which months have 31 days? ___________________________________________________________________.
Counting Money Pennies, Nickels, & Dimes Created by Mrs. Miller Math SOL K.7 & 1.10.
Penny Nickel Dime Penny Nickel Dime Quarter Half Dollar.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Counting Coins. The Basics Quarter 25 cents Dime 10 cents.
The Fundamentals: Algorithms, the Integers & Matrices.
MONEY! Pick the correct coin! Click here to get started!!
CompSci 102 Discrete Math for Computer Science
Touch Money Jane Hancock.
Canadian Money. Coins Penny 1 cent 1¢ Nickel 5 cents 5¢
Halting Problem Introduction to Computing Science and Programming I.
Let’s Learn About Money!
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
Section 3.1. Section Summary Properties of Algorithms Algorithms for Searching and Sorting Greedy Algorithms Halting Problem.
Sorting Techniques Rizwan Rehman Centre for Computer Studies Dibrugarh University.
Name the United States Coins Count the Pennies 10 ¢
Math Meeting Write today’s date __________________________ What was (will be) the date on the third Monday of this month? _________________________ Time:
CS 103 Discrete Structures Lecture 12
3.3 Complexity of Algorithms
Bubble Sort Example
ALGORITHMS.
22C:19 Discrete Math Algorithms and Integers Fall 2010 Sukumar Ghosh.
Math Meeting Write today’s date __________________________ How many days are in 1 year? ________________ Time: ________________ (evening) What was the.
Chapter 3 1 Kenneth Rosen, Discrete Mathematics and its Applications, 7th edition, McGraw Hill Instructor: Longin Jan Latecki,
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
Math Meeting Write today’s date __________________________ What was (will be) the date on the fourth Friday of this month? ___________________ Time: +
Chapter 3 With Question/Answer Animations 1. Chapter Summary Algorithms Example Algorithms Algorithmic Paradigms Growth of Functions Big-O and other Notation.
Money – Change Combinations &MathLine. Start with each ring representing a penny Money – Change.
Greedy Algorithms Prof. Kharat P. V. Department of Information Technology.
Chapter 3 Sec 3.1 &3.2 With Question/Answer Animations 1.
Algorithms Chapter 3.
CSE15 Discrete Mathematics 03/06/17
Introduction to Computing Science and Programming I
k-2 Lesson d: kids as coins Coin Signs
Money Concept Assessment Bank
CS 2210 Discrete Structures Algorithms and Complexity
Algorithms Chapter 3 With Question/Answer Animations
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
Advanced Learner Coin Pictures
CS 2210 Discrete Structures Algorithms and Complexity
Name the United States Coins
Discrete Mathematics CMP-101 Lecture 12 Sorting, Bubble Sort, Insertion Sort, Greedy Algorithms Abdul Hameed
Quarters - $10 Quarters - $10 Quarters - $10 Quarters - $10
Bubble Sort Example 9, 6, 2, 12, 11, 9, 3, 7 6, 9, 2, 12, 11, 9, 3, 7 Bubblesort compares the numbers in pairs from left to right exchanging.
Permutations COURSE 2 LESSON 12-6
CSCE 222 Discrete Structures for Computing
Algorithms Chapter 3 With Question/Answer Animations.
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Algorithms Chapter 3 With Question/Answer Animations
Money Math Review.
The Foundations: Logic and Proofs
Counting Money Pennies, Nickels, & Dimes
CS 2210 Discrete Structures Algorithms and Complexity
Presentation transcript:

Example { 1 – –1} Use Bubble Sort (sort in increasing order} After first pass { –1 50} After Second Pass { } After Third Pass { } After Fourth Pass { } After Fifth Pass { } Done

Example { 1 – –1} Use Insertion Sort (sort in increasing order} After first pass { } After Second Pass { } After Third Pass { } After Fourth Pass { } After Fifth Pass { } Done

Example { 1 – –1} Use Selection Sort (sort in increasing order} After first pass ( { } After Second Pass { } ( {-11 – }, {-11 – } After Third Pass { } After Fourth Pass { } After Fifth Pass { } Done

An example of greedy algorithm: Solution is in steps and every step you pick the best solution for that step.

Compare your solution (using the greedy algorithm) with the best solution (the one gives you the fewest number of coins). Both will have the same number of quarters ….. (# of your quarters >= # of best solution’s quarters). If the inequality is strict, then # of coins in the best solution will be greater than yours …. From so the changes in dimes, nickels and pennies in both solutions are the same (the remainder of the change divided by 25c). So both solution will have the same number of coins. Suppose now you only use quarters, dims and pennies. Do you think the greedy algorithm work? What is the result of the greedy algorithm for 30c? Is this the optimal solution? (The fewest coins)? Why?

Halting Problem Does there exist a procedure (algorithm or program) that can tell a given program with a given input will stop (halt) after a finite number of steps. A Fundamental and interesting (theoretical) problem in computer science.

More Specifically: Let H(P, Q) be the halting program (it returns two values: halt and loop forever). Define a new program K, taking input P(any program) K(P) K(P) will loop forever if H(P, P) return “halt” K(P) will halt if H(P, P) return “loop forever” Then, H(P, Q) does not work for K. If H(K, K) return halt, by definition K(K) will loop forever If H(K, K) return loop forever, by definition K(K) will halt.