CPSC 171 Introduction to Computer Science More Algorithm Discovery and Design.

Slides:



Advertisements
Similar presentations
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
Advertisements

THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
CPSC 171 Introduction to Computer Science Efficiency of Algorithms.
1 Algorithms Algorithm A set of unambiguous instructions for solving a problem or subproblem in a finite amount of time using a finite amount of data Why.
Top-Down Design CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
Chapter 1: An Introduction to Computer Science Invitation to Computer Science, C++ Version, Third Edition.
What is an algorithm? Informally: An Algorithm is a step by step method for solving a problem. It’s purpose is to break a larger task down so that each.
Efficiency of Algorithms
Chapter 2: Algorithm Discovery and Design
Lecture 14 Go over midterm results Algorithms Efficiency More on prime numbers.
Chapter 2: Algorithm Discovery and Design
Early Term Test Some Study Reminders. General Topics Sources for information to be tested are –My slides and classroom presentations of slides –Chapter.
Chapter 2 The Algorithmic Foundations of Computer Science
CHAPTER 2 CS
Chapter 2: Design of Algorithms
Algorithms and Efficiency of Algorithms February 4th.
CHAPTER 2 ANALYSIS OF ALGORITHMS Part 2. 2 Running time of Basic operations Basic operations do not depend on the size of input, their running time is.
1 Reducibility. 2 Problem is reduced to problem If we can solve problem then we can solve problem.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Week 7 - Programming II Today – more features: – Loop control – Extending if/else – Nesting of loops Debugging tools Textbook chapter 7, pages
New Mexico Computer Science For All Introduction to Algorithms Maureen Psaila-Dombrowski.
Great Theoretical Ideas in Computer Science.
Great Theoretical Ideas in Computer Science.
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
CSCI 101 Introduction to Software Development and Design.
COMPSCI 101 S Principles of Programming Lecture 1 – Introduction.
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
Chapter 12Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 12 l Basics of Recursion l Programming with Recursion Recursion.
计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院
Chapter 11Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 11 l Basics of Recursion l Programming with Recursion Recursion.
Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems.
Algorithms and Algorithm Analysis The “fun” stuff.
Lecture 5: Developing Procedural Thinking (How to think like a programmer) B Burlingame 30 Sept 2015.
MA/CSSE 474 Theory of Computation Enumerability Reduction.
CPSC 171 Introduction to Computer Science Algorithm Discovery and Design.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Part 1 – Pages COMPUTABILITY THEORY.
1 Section 2.1 Algorithms. 2 Algorithm A finite set of precise instructions for performing a computation or for solving a problem.
Subtracting Integers Subtracting Integers CCS: 6.NS.2: Understand subtraction of rational numbers as adding the additive inverse, p – q = p + (–q).
Analysis of Algorithms Algorithm Input Output An algorithm is a step-by-step procedure for solving a problem in a finite amount of time.
Computer Science 101 Theory of Computing. Computer Science is... The study of algorithms, with respect to –their formal properties –their linguistic realizations.
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Invitation to Computer Science 5 th Edition Chapter 2 The Algorithmic Foundations of Computer Science.
INVITATION TO Computer Science 1 11 Chapter 2 The Algorithmic Foundations of Computer Science.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Flowcharts C++ Lab. Algorithm An informal definition of an algorithm is: a step-by-step method for solving a problem or doing a task. Input data A step-by-step.
Lecture 3: Developing Procedural Thinking (How to think like a programmer) B Burlingame 16 Feb 2016.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
Welcome to PHY2170/2175 G. Bonvicini, Wayne State University –The purpose of the course –Web sites connected to course –Labs, old text books, etc. –How.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Low-Level Programming Languages, Pseudocode and Testing Chapter 6.
Topic: Introduction to Computing Science and Programming + Algorithm
Great Theoretical Ideas in Computer Science
Lecture 2: Introduction to Algorithms
COMS W1004 Introduction to Computer Science and Programming in Java
Lecture 2 Introduction to Computer Science (continued)
فصل سوم The Church-Turing Thesis
Algorithm Discovery and Design
Introduction to Algorithms and Programming
Problem Solving and Algorithm Design
CS150 Introduction to Computer Science 1
Discovery and Design of Algorithms
Computer Science 101 Survey of Computer Science
Presentation transcript:

CPSC 171 Introduction to Computer Science More Algorithm Discovery and Design

Reading Assignment 2 Chapter 2 in Textbook Homework Assignment 2 Due September 11, beginning of class Page 75, # 3,7,11,15,18,19,20 Also: Design an algorithm to always beat me in the game 21.

An Algorithm is A well-ordered collection of Unambiguous and Effectively computable operations that, when executed Produces a result and Halts in a finite amount of time Textbook definition

Summary of Operation Types for Algorithms Sequential operations to carry out computation, input, and output. Conditional operations. Iterative operations.

There is a theorem in theoretical computer science that proves that these operations are sufficient to represent ANY algorithm! Algorithms are used to do everything you see on a computer! Do word processing. Fly NASA probes to the planets. Run the international telephone switching system. Create CAT scan images. Process your pay checks. Run computer games. Etc. Powerful Algorithms!!

EXAMPLE OF AN ALGORITHM PROBLEM: Start with a collection of names N 1, N 2,..., N 10000, and corresponding telephone numbers T 1, T 2,..., T Given a name, Name, find and print the telephone number for that name if a match on an N i occurs; otherwise, print "Not Found". Given a problem, there are often many ways to provide an algorithm for solving the problem. Note: You must understand the methodology for solving the problem in order to write an algorithm for the solution!!!

First Try 1. Get values for N 1, N 2,..., N 10000, T 1, T 2,,,,, T 10000, and Name. 2. If Name is N 1, then print T 1 Stop 3. If Name is N 2, then print T 2. Stop. {a lot of tedious writing here that is being skipped} If Name is N 10000, then print T Stop Print "Not found" Stop.

Second Try 1. Get values for N 1, N 2,..., N 10000, T 1, T 2,,,,, T 10000, and Name. 2. Set the value of i to 1 and the value of Found to NO. 3. While Found is NO 4.If Name is equal to N i, then 5.Print the telephone number T i 6. Set the value of Found to Yes Else 7.Add 1 to the value of i 8. Stop.

Third Try 1. Get values for N 1, N 2,..., N 10000, T 1, T 2,,,,, T 10000, and Name. 2. Set the value of i to 1 and the value of Found to NO. 3. While Found is NO and i <= If Name is equal to N i, then 5.Print the telephone number T i 6. Set the value of Found to Yes Else 7.Add 1 to the value of i 8. If (Found is No) then 9.Print "Not found" 10. Stop.

Game Time Who can beat me in the game 21? Objective: Get your opponent to say the number 21. Rules: One player goes first starting counting from 1. On each turn a player may say one or two consecutive numbers. You must begin where your opponent left off. The first person to say the number 21 loses. There is a way to always beat me!