Computer Algorithms.

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.
Computer Algorithms. Fact: computers are dumb machines Basic property of a computer (a machine): Computers do what we tell them to do Unfortunately, computer.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
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
Algorithms Friday 7th Week. Algorithms What is an Algorithm? –A series of precise steps, known to stop eventually, to solve a problem –NOT necessarily.
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.
What does a computer program look like: a general overview.
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
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
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.
1 UMBC CMSC 104, Section Fall 2002 Algorithms, Part 1 of 3 Topics Definition of an Algorithm Algorithm Examples Syntax versus Semantics Reading.
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.
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.
THE QUADRATIC FORMULA.
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
TK3043 Analysis and Design of Algorithms
Solving Quadratic Equations by the Quadratic Formula
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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.
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.
Solving Quadratic Equations by the Quadratic Formula
Algorithms I: An Introduction to Algorithms
Introduction to Computer Programming
2008/09/24: Lecture 6b CMSC 104, Section 0101 John Y. Park
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
Solving Quadratic Equations by the Quadratic Formula
3.7: Solving Quadratic Equations by the Quadratic Formula
Dividing by Decimals.
Multiplying 3 digits by 2 digits
PROBLEM SOLVING SKILLS
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.
Solving Quadratic Equations by the Quadratic Formula
UMBC CMSC 104 – Section 01, Fall 2016
Dividing by Decimals.
Solving Quadratic Equations by the Quadratic Formula
Solving Quadratic Equations by the Quadratic Formula
Algorithms, Part 1 of 3 Topics Definition of an Algorithm
Reading Math to Promote Fluency and Recall
THE QUADRATIC FORMULA.
Solving Quadratic Equations by the Quadratic Formula
Solving Quadratic Equations by the Quadratic Formula
Introduction to Algorithms
5.6 Solving Quadratic Equations by the Quadratic Formula
Learning Intention I will learn about the standard algorithm for input validation.
Algorithms, Part 1 of 3 Topics Definition of an Algorithm
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Solving Quadratic Equations by the Quadratic Formula
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.
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.

A real life algorithm (cont.) Euclid's Algorithm: 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

A real life algorithm (cont.) Example of the Euclid Algorithm: 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)