Chapter 10 Algorithmic Thinking. Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the.

Slides:



Advertisements
Similar presentations
Basics of Recursion Programming with Recursion
Advertisements

Heuristic Search techniques
College of Information Technology & Design
Software Development Languages and Environments. Programming languages High level languages are problem orientated contain many English words are easier.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
1 CS101 Introduction to Computing Lecture 17 Algorithms II.
Chapter 1 An Overview of Computers and Programming Languages.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Algorithmic Thinking What’s the Plan? lawrence snyder c h a p t e r 10.
The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.
Reference :Understanding Computers
Introduction to C Programming
Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm.
Chapter 10 Algorithmic Thinking. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Learning Objectives List the five essential.
Chapter 10 What's The Plan?: Algorithmic Thinking.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction to Computers CS Dr. Zhizhang Shen Chapter 10: How to.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Chapter 2: Algorithm Discovery and Design
Chapter 2 The Algorithmic Foundations of Computer Science
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1. By the end of this lecture you should be able … To describe in general terms how computers function To describe the fetch-execute cycle To explain.
Introduction to C Programming
CHAPTER 6 FILE PROCESSING. 2 Introduction  The most convenient way to process involving large data sets is to store them into a file for later processing.
CHAPTER 10 Recursion. 2 Recursive Thinking Recursion is a programming technique in which a method can call itself to solve a problem A recursive definition.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Design and Analysis of Algorithms
Fundamentals of Python: From First Programs Through Data Structures
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
CSCI-100 Introduction to Computing Algorithms Part I.
Fundamentals of Python: First Programs
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
Fundamentals of Algorithms MCS - 2 Lecture # 1
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
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.
Chapter 13 Recursion. Learning Objectives Recursive void Functions – Tracing recursive calls – Infinite recursion, overflows Recursive Functions that.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
CSIS 123A Lecture 9 Recursion Glenn Stevenson CSIS 113A MSJC.
Algorithms CS139 – Aug 30, Problem Solving Your roommate, who is taking CS139, is in a panic. He is worried that he might lose his financial aid.
Algorithms Algorithms are a familiar idea. Our goal is to learn to specify them right so someone or something else does the work.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
What's The Plan? Algorithmic Thinking Step-by-step directions for whatever someone, or the computer, needs to do © 2004 Lawrence Snyder.
Algorithms & FlowchartsLecture 10. Algorithm’s CONCEPT.
Lexical Analysis S. M. Farhad. Input Buffering Speedup the reading the source program Look one or more characters beyond the next lexeme There are many.
ALGORITHMS.
Algorithms CS280 – 10/20/05. Announcement  Part 1 of project 2 due.  Read chapters 10, 7 for this unit  Tuesday we will also be in the classroom We.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
INVITATION TO Computer Science 1 11 Chapter 2 The Algorithmic Foundations of Computer Science.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004.
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
Introduction to Algorithms
Introduction To Flowcharting
Computer Programming.
Unit# 9: Computer Program Development
Algorithms Chapter 3 With Question/Answer Animations
Objective of This Course
Algorithm Discovery and Design
CSCI 1250 Information Technologies
Understanding Problems and how to Solve them by using Computers
Chapter 10: Algorithm TECH Prof. Jeff Cheng.
Introduction to Algorithms
What's The Plan?: Algorithmic Thinking
What's The Plan?: Algorithmic Thinking
What's The Plan?: Algorithmic Thinking
Presentation transcript:

Chapter 10 Algorithmic Thinking

Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm Use the Intersect Alphabetized List algorithm to do the following: –Follow the flow of the instruction execution –Follow an analysis to pinpoint assumptions Demonstrate algorithmic thinking by being able to do the following: –Explain the importance of alphabetical order on the solution –Explain the importance of the barrier abstraction for correctness

The Letter Algorithm Bauby was paralyzed and could communicate only by blinking one eyelid An assistant would say or point to a letter and Bauby would indicate if it was the right one Point to letters until the correct one is reached Repeat to spell words and sentences

The Letter Algorithm This process is an algorithm: A precise, systematic method for producing a specified result We invent algorithms all the time An algorithm need not use numbers The agent running an algorithm may be a human being, rather than a computer There are better and poorer versions of this algorithm

The Letter Algorithm Making the process faster ₋ Completion: The assistant can guess a word before it is all spelled out ₋ Ask the letters in frequency order, and work from the most-frequently-used letter downward

Programs are Algorithms programs: algorithms that have been specialized to a specific set of conditions and assumptions –usually written in a specific programming language usually the words program and algorithm are used interchangeably

Algorithms we have learned Placeholder technique –protect “good” letter sequences by replacing them with a placeholder –edit the “bad” letter sequences –restore the “good” letter sequences Binary to Decimal Conversion –if there is a 1, write down the place value for its position in decimal –add up those place values Binary Addition –add as in decimal but limit digit positions to two

Algorithms vs. Heuristic Processes not all processes given in the book are algorithms the process to find information on the web using a search engine was not an algorithm –not systematic –not guaranteed to find it (process could fail) –called a heuristic process: helpful procedure for finding a result

Algorithm Properties An algorithm must have five properties: 1.Input specified 2.Output specified 3.Definiteness 4.Effectiveness 5.Finiteness

1. Input Specified The input is the data to be transformed during the computation to produce the output What data do you need to begin to get the result you want? Input precision requires that you know what kind of data, how much and what form the data should be

2. Output Specified The output is the data resulting from the computation (your intended result) Frequently the name of the algorithm contains the output: –“Algorithm to compute batting average” Output precision also requires that you know what kind of data, how much and what form the output should be (or even if there will be any output at all!)

3. Definiteness Algorithms must specify every step and the order the steps must be taken in the process Definiteness means specifying the sequence of operations for turning input into output Details of each step must be spelled out (including how to handle errors)

4. Effectiveness For an algorithm to be effective, each of its steps must be doable The agent must be able to perform each step without any outside help or extraordinary powers

5. Finiteness The algorithm must stop, eventually! Stopping may mean that you get the expected output OR you get a response that no solution is possible Finiteness is not usually an issue for non- computer algorithms Computer algorithms often repeat instructions with different data and finiteness may be a problem

Query Evaluation

Makes an ordered list of the pages after a search query Not written in a programming language, instead just everyday English –Does use “tech speak” Writing in English instead of a programming language allows them to omit details They are writing for people, not computers

Algorithm Fact #1 1.Algorithms can be specified at different levels of detail –Algorithms use functions to simplify the algorithmic description –These functions (such as scan) may have their own algorithms associated with them

Algorithm Fact #2 2.Algorithms always build on functionality previously defined and known to the user –Assume the use familiar functions and algorithms –For example, “scan through” would use the Intersecting Alphabetized Lists (IAL) from Chapter 5

Algorithm Fact #3 3.Different algorithms can solve the same problem differently, and the different solutions can take different amounts of time (or space)

Intersecting Lists Here is the Intersecting Alphabetized Lists (IAL) algorithm from Chapter 5 1.Put a marker at start of each list 2.If all markers show the same URL, save it 3.Advance the marker(s) for the alphabetically-earliest URL 4.Repeat steps 2-3 until some marker reaches the end

No Alphabetized Lists 1. Arrange lists left to right on the page 2. Put a marker at the start of each list 3.If all markers show same URL, save it 4.Starting from the right, find each list whose marker is at the end, and move the marker to the front 5.When you first find a marker not at the end, advance it and go to step 3. 6.Stop when all markers return to start

How Not To Match ●IAL and NAL are different algorithms ●IAL and NAL accomplish the same thing ●NAL is much slower ●For 5 lists of 10 URLs: -IAL: = 50 steps -NAL: 10×10×10×10×10 = 100,000 steps

How Do We Know it Works? Algorithm solution is clear and simple and efficient Then, how do we know it works? If there is no loop, the program runs, gets to an end, and we can check the result What if there is a loop? –Programs with loops cannot be absolutely verified…there are too many possible cases

Then, what? The way to know that an algorithm works is to know why it works… Strategy for knowing why it works: –Find one or more properties that ensure the algorithm works –Explain, using the program, why they make it work.

Why IAL Works If a URL appears is all lists, it forms a barrier Pointers that haven’t reached the barrier move sooner than ones that have When they all reach the barrier, the URL is recorded None can pass the next barrier until they all reach it Etc.

Correctness anyone who creates an algorithm needs to know why it works –finding the algorithm's correctness-preserving properties and explaining why they do the job

Summary We use algorithms daily, and we continually create them as we instruct other people in how to do something Everyday algorithms can be sometimes be unclear because natural language is imprecise Algorithms have five fundamental properties

Summary Algorithms can be given at different levels of detail depending on the abilities of the agent Problems can be solved by different algorithms in different ways Algorithms always finish—either they give the answer, or say no answer is possible—and they are evaluated on their use of resources such as space and time

Summary Intersect Alphabetized Lists algorithm is used in Web search, and is preferred over other solutions Two properties of the Intersect Alphabetized Lists algorithm tell us why it works: the Alpha-Ordering and Barrier properties