CMSC 1041 Algorithms I An Introduction to Algorithms.

Slides:



Advertisements
Similar presentations
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Advertisements

CSci 107 Introduction to Computer Science Lecture 1.
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP
CMSC 104, Version 8/061L04Algorithms1.ppt Algorithms, Part 1 of 3 Topics Definition of an Algorithm Algorithm Examples Syntax versus Semantics Reading.
Design & Analysis of Algoritms
Computer Algorithms. Fact: computers are dumb machines Basic property of a computer (a machine): Computers do what we tell them to do Unfortunately, computer.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Computer Software & Software Development H&K Chapter 1 Instructor – Gokcen Cilingir Cpt S 121 (June 20, 2011) Washington State University.
1 Lecture 1: Course Overview Course: CSE 360 Instructor: Dr. Eric Torng TA: Huamin Chen.
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
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.
Hints for homework 6.2. divisors A divisor of an integer n, also called a factor of n, is an integer which evenly divides n without leaving a remainder.
Programming Fundamentals (750113) Ch1. Problem Solving
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Design and Analysis of Algorithms - Chapter 11 Algorithm An algorithm is a.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
Invitation to Computer Science 5th Edition
Problem Solving Methods. CSCE 1062 Outline Problem Solving Methods Problem solving steps The analytical method The algorithmic method The software engineering.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
Review Introduction to Searching External and Internal Searching Types of Searching Linear or sequential search Binary Search Algorithms for Linear Search.
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.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
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
Design & Analysis of Algorithms Lecture 1 Introduction.
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
Computer Science/Ch. Algorithmic Foundation of CS 4-1 Chapter 4 Chapter 4 Algorithmic Foundation of Computer Science.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Introduction to design and analysis algorithm
CMSC 104, Section 301, Fall Lecture 04, 9/11/02 Operating Systems and Using Linux Review Operating System. Linux Overview. Frequently Used Linux.
1 UMBC CMSC 104, Section Fall 2002 Algorithms, Part 1 of 3 Topics Definition of an Algorithm Algorithm Examples Syntax versus Semantics Reading.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
1.  A step by step process to solve any problem is called algorithm.  Algorithm is a process which take some values as input and provide us output.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
1 Introduction to design and analysis algorithm. 2.
CMSC 104, L041 Algorithms, Part 1 of 3 Topics Definition of an Algorithm Example: The Euclidean Algorithm Syntax versus Semantics Reading Sections 3.1.
Problem Solving & Computer Programming
Algorithms and Problem Solving
Algorithms, Part 1 of 3 The First step in the programming process
Algorithms, Part 1 of 3 Topics Definition of an Algorithm
TK3043 Analysis and Design of Algorithms
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.
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.
Introduction to the Design and Analysis of 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.
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
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.
Programming Fundamentals (750113) Ch1. Problem Solving
UMBC CMSC 104 – Section 01, Fall 2016
KNOWLEDGE REPRESENTATION
Algorithms, Part 1 of 3 Topics Definition of an Algorithm
Lecture 6 Architecture Algorithm Defin ition. Algorithm 1stDefinition: Sequence of steps that can be taken to solve a problem 2ndDefinition: The step.
Computer Algorithms.
Introduction to Algorithms
Design and Analysis of Algorithms
Algorithms, Part 1 of 3 Topics Definition of an Algorithm
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Advanced Analysis of Algorithms
Algorithms and Data Structures
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:

CMSC 1041 Algorithms I An Introduction to Algorithms

CMSC 1042 Problem Solving “Problem solving is the process of transforming the description of a problem into the solution of that problem by using our knowledge of the problem domain and by relying on our ability to select and use appropriate problem- solving strategies, techniques, and tools.”

CMSC 1043 Algorithms l An algorithm is a procedure with: oA specific finite sequence of definite actions, and oA definite criterion for ending.

CMSC 1044 Algorithms Specificity l Steps must be unambiguous oNot “Do the regular thing at this point.” l Steps should be robust --- “Unlikely to fail” oWhat happens when MARKUP = PRICE/COST and COST = 0.0?

CMSC 1045 Algorithms Stopping Rule l Algorithms must have a clear stopping rule. l The rule does not have to specify a definite number of steps --- but it must give an unambiguous criterion oGood: “Stop when F(x i )-F(x i-1 ) < EPS ” oBad: “Continue until done.”

CMSC 1046 Algorithms l Why bother writing an algorithm ? oTo recognize and understand the essence of a problem or a solution. oFor your own use in the future. (Why solve the same problem twice?) oSo others can solve the problem, even if they know very little about the principles behind how the solution was derived.

CMSC 1047 Algorithms Algorithms are Stored Thought.

CMSC 1048 Examples of Algorithms l Starting a car. l Washing machine instructions l Instructions for a ready-to-assemble piece of furniture l A Classic: GCD - Greatest Common Divisor - The Euclidean Algorithm

CMSC 1049 Starting a Car l Check to see if the car is an automatic l If it is an automatic oInsert key into ignition oDepress brake pedal oTurn key oDone! l If it is a manual oInsert key into ignition oDepress brake pedal oDepress clutch pedal oTurn key oDone! This isn’t a good algorithm. It stops when the key is turned, not when the car is started. What happens if the key doesn’t fit, the brake or clutch pedal can’t be depressed, or the key can’t be turned? Can you see how this algorithm can be simplified?

CMSC Washing Machine Instructions l Separate clothes into white clothes and colored clothes. l For white clothes: oSet water temperature knob to HOT. oPlace white laundry in tub. l For colored clothes: oSet water temperature knob to COLD oPlace colored laundry in tub. l Add 1 cup of powdered laundry detergent to the tub. l Close lid and press the start button.

CMSC Observations about the Washing Machine Instructions l There are a finite number of steps. l The steps are all clearly defined l When the steps are complete, the washing machine will be ready to start. l What is the relationship between this algorithm and clean clothes? l Do we want the washing machine to run until all of the clothes are clean ?

CMSC Refinement of the Definition l Our old definition: oAn algorithm is a step by step solution to a problem. l Adding our observations: oAn algorithm is a finite set of executable instructions that directs a terminating activity.

CMSC Instructions for a Ready-to-Assemble Piece of Furniture l "Align the marks on side A with the grooves on Part F “ l Why are these instructions typically so hard to follow ? oLack of proper tools - instructions are not executable oWhich side is A ? A & B look alike. Both line up with Part F - Ambiguous instructions.

CMSC Final Version of the Definition: An algorithm is a finite set of unambiguous, executable instructions that directs a terminating activity.

CMSC History of Algorithms l The study of algorithms began as a subject in mathematics. Abu Ja’far Mohammed ibn Musa al Khowarizmi Persian (c. 825 AD) l The search for algorithms was a significant activity of early mathematicians. l Goal: To find a single set of instructions that could be used to solve any problem of a particular type.

CMSC GCD - The Euclidean Algorithm l 1. Assign M and N the value of the larger and the value of the smaller of the two positive integer input values, respectively. l 2. Divide M by N and call the remainder R. l 3. If R is not 0, then assign M the value of N, assign N the value of R and return to step 2, otherwise the greatest common divisor is the value currently assigned to N.

CMSC Finding the GCD or 24 and 9 MNR So 3 is the GCD of 24 and 9.

CMSC Euclidean GCD Algorithm (continued) l Do we need to know the theory that Euclid used to come up with this algorithm in order to use it ? l What intelligence is required to find the GCD using this algorithm ?

CMSC The Idea Behind Algorithms l Once an algorithm behind a task has been discovered oDon't need to understand the principles. oTask is reduced to following the instructions. oIntelligence is "encoded into the algorithm” “An algorithm is stored thought.”

CMSC Algorithm Representation l Syntax and Semantics oSyntax refers to the representation itself. oSemantics refers to the concept represented.