Computer Algorithms. Fact: computers are dumb machines Basic property of a computer (a machine): Computers do what we tell them to do Unfortunately, computer.

Slides:



Advertisements
Similar presentations
CSci 107 Introduction to Computer Science Lecture 1.
Advertisements

CMSC 104, Version 8/061L04Algorithms1.ppt Algorithms, Part 1 of 3 Topics Definition of an Algorithm Algorithm Examples Syntax versus Semantics Reading.
1 Chapter Six Algorithms. 2 Algorithms An algorithm is an abstract strategy for solving a problem and is often expressed in English A function is the.
Ch. 10: What is a number?. MAIN DEFINITION OF THE COURSE: A symmetry of an object (in the plane or space) means a rigid motion (of the plane or space)
CSci 107 Introduction to Computer Science Lecture 1.
Introduction to a Programming Environment
Section Section Summary Recursive Algorithms Proving Recursive Algorithms Correct Recursion and Iteration (not yet included in overheads) Merge.
a x 10n, Scientific Notation Scientific Notation
Genome Sciences 373 Genome Informatics Quiz Section #1 March 31, 2015.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
Theory of Computation. Computation Computation is a general term for any type of information processing that can be represented as an algorithm precisely.
Procedural Writing. Directions for Cube Activity Each person will build a shape using 6 cube blocks of various colors (2 minutes) After building, you.
9-Aug-15 Vocabulary. Programming Vocabulary Watch closely, you might even want to take some notes. There’s a short quiz at the end of this presentation!
Programming a computer. What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded.
The computer memory and the binary number system.
BIT Presentation 4.  An algorithm is a method for solving a class of problems.  While computer scientists think a lot about algorithms, the term.
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
CSCI-100 Introduction to Computing Algorithms Part I.
CSCI 1900 Discrete Structures
Polynomial Division: Dividing one polynomial by another polynomial to find the zeros of the polynomial. Ex 1: Find the zeros of Solution:1 st way: At.
COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs)
Dividing by Decimals. Dividing decimals is a lot like dividing by a whole number. There is just one thing you need to remember before dividing: You have.
Algorithms and Programming
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
CSC201 Analysis and Design of Algorithms Asst.Proof.Dr.Surasak Mungsing Oct-151 Lecture 2: Definition of algorithm and Mathematical.
Some quotes…. I really hate this damned machine I wish that they would sell it. It never does quite what I want But only what I tell it. ~Anon These machines.
WIKIPEDIA HAS MANY MORE DIVISIBILITY RULES. EXAMPLE Since 52=13(4) is divisible by 4, is divisible by 4 Since 452=56(8)+4 is not divisible.
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
What does a computer program look like: a general overview.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
CMSC 1041 Algorithms I An Introduction to Algorithms.
Algorithms, Part 1 of 3 Topics  Definition of an Algorithm  Algorithm Examples  Syntax versus Semantics Reading  Sections
RATIONAL EXPRESSIONS. Rational Expressions and Functions: Multiplying and Dividing Objectives –Simplifying Rational Expressions and Functions –Rational.
CMSC 1041 Algorithms I An Introduction to Algorithms.
ILLUSTRATING INTEGERS
What's The Plan? Algorithmic Thinking Step-by-step directions for whatever someone, or the computer, needs to do © 2004 Lawrence Snyder.
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
… Computer Science Inside… Algorithm Development.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3 rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Euclidean Algorithm How to find a greatest common divisor in several easy steps.
Introduction to design and analysis algorithm
1 UMBC CMSC 104, Section Fall 2002 Algorithms, Part 1 of 3 Topics Definition of an Algorithm Algorithm Examples Syntax versus Semantics Reading.
Adding 2-digit numbers with regrouping. Always add the ones place first
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.
Comp1004: Programming in Java II Computational Thinking.
1 Introduction to design and analysis algorithm. 2.
Systems in the Small: An Introduction to Algorithms David Millard
CMSC 104, L041 Algorithms, Part 1 of 3 Topics Definition of an Algorithm Example: The Euclidean Algorithm Syntax versus Semantics Reading Sections 3.1.
Recursive Algorithms Section 5.4.
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
Algorithms, Part 1 of 3 The First step in the programming process
Algorithms, Part 1 of 3 Topics Definition of an Algorithm
Greatest Common Divisor
Greatest Common Divisor
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
Algorithms I: An Introduction to Algorithms
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
2008/09/17: Lecture 4 CMSC 104, Section 0101 John Y. Park
Multiplying 3 digits by 2 digits
PROBLEM SOLVING SKILLS
UMBC CMSC 104 – Section 01, Fall 2016
Algorithms, Part 1 of 3 Topics Definition of an Algorithm
Computer Algorithms.
THE QUADRATIC FORMULA.
Algorithms, Part 1 of 3 Topics Definition of an Algorithm
Presentation transcript:

Computer Algorithms

Fact: computers are dumb machines Basic property of a computer (a machine): Computers do what we tell them to do Unfortunately, computer do not necessarily do what we want them to do.... (Because we can make mistake in telling the computer what we want to do... These mistakes are called "bugs")

Algorithm Definition: algorithm Dictionary definition: Algorithm = a step-by-step procedure for solving a problem or accomplishing some task, especially by means of a computer

Computer Algorithms Computer Algorithm: is an algorithm that can be executed by a computer

Computer Algorithms (cont.) Properties of computer algorithms: The steps in an algorithm must be consists of operations that can be executed by a computer The step in an algorithm must be unambiguous (Remember that a dumb machine like a computer will do what it is told to do. Resolving ambiguity requires some thinking (intelligence) which computers cannot do !) Computers cannot think.

Algorithm development We will now illustrate the process of developing an algorithm An algorithm always accomplishes some well-defined task or solves some well-defined problem The task/problem that we will use to illustrate the process of developing an algorithm is: Replacing a burned out light bulb

Instruction for humans on replacing a burned out light bulb Typical instructions given to humans on how to replace a light bulb: These brief instructions assume a lot of common sense knowledge that a machine does not have !!! Remove the burned-out bulb Insert a new bulb

Instruction for humans on replacing a burned out light bulb (cont.) What can go wrong if a machine uses these instructions: A machine does not know how to remove a bulb It could yank the bulk out of its socket and damage the fixture in the process. A machine does not know how to insert a bulb A machine can replace the bulb with one that has an inadequate wattage (too bright or too dim)

Instructions for computers on replacing a burned out light bulb Computers have no common sense knowledge (really dumb) Instructions for computers must be given very explicitly (in "baby steps")

Instructions for computers on replacing a burned out light bulb (cont.) Example of how you would instruct a computer to change a light bulb: [The following instructions will remove the burn-out bulb] repeat until (bulb comes free of socket) { turn bulb in counter-clockwise direction } [The following instructions will find a suitable bulb] select a new bulb repeat until (wattage of bulb selected = wattage of old bulb) { discard the selected bulb select another bulb } [The following instructions will insert the new bulb] repeat until (bulb is secure in socket) { turn bulb in clockwise direction }

A real life algorithm Here is a famous algorithm that you can try out: Take 2 pieces of paper and write on one piece "A" and on the other piece "B": Write a positive integer on each piece of paper.

Euclid's Algorithm: A real life algorithm (cont.) As long as one of the number is not zero (0) do { if ( number on A ≥ number on B ) replace the number on A by the value (A - B) otherwise replace the number on B by the value (B - A) } The Greatest Common Divisor (GCD) of the numbers A and B is the non-zero number on one of the papers

Example of the Euclid Algorithm: A real life algorithm (cont.) We start with the following 2 number: Since number on A < number on B, we replace the number on B (= 36) by the value (B − A) = 8:

A real life algorithm (cont.) Now number on A ≥ number on B, so we replace the number on A (= 28) by the value (A − B) = 20: Again, number on A ≥ number on B, so we replace the number on A (= 20) by the value (A − B) = 12:

A real life algorithm (cont.) Yet again, number on A ≥ number on B, so we replace the number on A (= 12) by the value (A − B) = 4: This time, number on B > number on A, so we replace the number on B (= 8) by the value (B − A) = 4:

A real life algorithm (cont.) Now, number on A ≥ number on B, so we replace the number on A (= 4) by the value (B − A) = 0: One of the number on the papers is now zero According to the Euclid's Algorithm, the other number (= 4) is equal to the GCD of (28, 36)