Lecture 2 Introduction to Computer Science (continued)

Slides:



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

CPSC 171 Introduction to Computer Science Efficiency of Algorithms.
1 CS1000 Introduction to Computer Science Instructor Soufiane Noureddine Lectures Tu/Th: 12:15-13:30 (B650) Office Hours Tu/Th: 11:00-12:00 (C520)
CMPUT101 Introduction to Computing(c) Yngvi Bjornsson & Jia You1 Algorithm Discovery and Design Chapter 2 Topics: Representing Algorithms Algorithmic Problem.
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.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Chapter 2: Algorithm Discovery and Design
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Chapter 2 The Algorithmic Foundations of Computer Science
Chapter 2: Algorithm Discovery and Design
Chapter 11: understanding randomness (Simulations)
1 Chapter 1 Basic Computer Concept 國立雲林科技大學 資訊工程研究所 張傳育 (Chuan-Yu Chang ) 博士 Office: EB 212 TEL: ext. 4337
Chapter 1 An Introduction to Computer Science
Copyright © 2010 Pearson Education, Inc. Unit 3: Gathering Data Chapter 11 Understanding Randomness.
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems.
1 Invitation to Computer Science 6 th Edition Chapter 1 An Introduction to Computer Science.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
CPSC 171 Introduction to Computer Science More Algorithm Discovery and Design.
1 Section 2.1 Algorithms. 2 Algorithm A finite set of precise instructions for performing a computation or for solving a problem.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik.
Algorithms JPC and JWD © 2002 McGraw-Hill, Inc. 2 Algorithms 2 An Algorithm is a finite set of precise instructions for performing a computation or for.
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
Statistics 11 Understanding Randomness. Example If you had a coin from someone, that they said ended up heads more often than tails, how would you test.
Computer Systems Architecture Edited by Original lecture by Ian Sunley Areas: Computer users Basic topics What is a computer?
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesTuring.
Theory of Computation. Introduction We study this course in order to answer the following questions: What are the fundamental capabilities and limitations.
CSE15 Discrete Mathematics 03/06/17
The Acceptance Problem for TMs
Recursion Topic 5.
Algorithms and Problem Solving
CSIS 104 –Intro. To Computer Science
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 3
Python: Control Structures
CSE 311 Foundations of Computing I
Introduction to Computational Thinking
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 3
Understanding Randomness
Algorithm and Ambiguity
Enough Mathematical Appetizers!
Lecture 2: Introduction to Algorithms
COMS W1004 Introduction to Computer Science and Programming in Java
Foundations of Computer Science
A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 13 (Reed) - Conditional.
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Data Structures Review Session
Algorithm Discovery and Design
Applied Discrete Mathematics Week 6: Computation
Discrete Mathematics CMP-101 Lecture 12 Sorting, Bubble Sort, Insertion Sort, Greedy Algorithms Abdul Hameed
Algorithm Discovery and Design
Algorithm and Ambiguity
Understanding Randomness
Guest Lecture by David Johnston
Basics of Recursion Programming with Recursion
Chapter 10: Algorithm TECH Prof. Jeff Cheng.
Algorithms and Problem Solving
Lecture 6 Architecture Algorithm Defin ition. Algorithm 1stDefinition: Sequence of steps that can be taken to solve a problem 2ndDefinition: The step.
Lecture 3 Pseudocode (S&G, §2.2)
Basic Concepts of Algorithm
Understanding Randomness
Computer Science 101 Survey of Computer Science
A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 13 (Reed) - Conditional.
Early Midterm Some Study Reminders.
Presentation transcript:

Lecture 2 Introduction to Computer Science (continued) 11/15/2018 Lecture 2 Introduction to Computer Science (continued) 11/15/2018 CS 100 - Lecture 2 CS 100

Ways Algorithms can be Constructed Lecture 2 11/15/2018 Ways Algorithms can be Constructed Sequential construction Conditional construction Iterative construction 11/15/2018 CS 100 - Lecture 2 CS 100

Sequential Construction Lecture 2 11/15/2018 Sequential Construction first do this then do this After showing this observe: If we have two or more operations, we can either do: ALL of them (AND), or ONE of them (OR) If we do ALL of them, we can either: do them one at a time (as above) do them all at once (parallel execution, which we won’t discuss) If we are only going to do ONE of them, we must decide which… 11/15/2018 CS 100 - Lecture 2 CS 100

Conditional Construction Lecture 2 11/15/2018 Conditional Construction test something either do this or do this It is also possible to have choices between more than two alternatives Also, if one alternate is “do nothing” then in effect we have the choice of whether to do something or not (We could pick which to do by tossing a coin, but that sort of non-decision can be reduced to this form) continue 11/15/2018 CS 100 - Lecture 2 CS 100

Iterative Construction Lecture 2 11/15/2018 Iterative Construction do something if not, repeat test if done This is a sort of combination of the previous two: we do something AND then we decide to do it again OR not Note that this is not the only kind of iterative operation This form does the operation at least once if done, continue 11/15/2018 CS 100 - Lecture 2 CS 100

Developing an Algorithm Lecture 2 11/15/2018 Developing an Algorithm Often good to begin by investigating how a person would do it Control structures: Shows how to order the steps Reveals what different conditions may occur Data structures: Shows how to organize information Reveals what additional information is required 11/15/2018 CS 100 - Lecture 2 CS 100

Developing Decimal Addition Algorithm: Example Lecture 2 11/15/2018 Developing Decimal Addition Algorithm: Example 1 carry 15 5 1 04 4 4 1 1 8 1 4 7 7 2 9 5 We could have two cases, carry or no-carry, but it’s simpler to always add in the carry and make it either 1 or 0. 14 12 2 11/15/2018 CS 100 - Lecture 2 CS 100

Developing Decimal Addition Algorithm: More General Case Lecture 2 11/15/2018 Developing Decimal Addition Algorithm: More General Case carry cc3 c3 c cc2 c2 c c1 c c0 c c4 a3 a2 a1 a0 b3 b2 b1 b0 Note that we make the first column like the others by setting the initial carry to 0 cc1 cc0 11/15/2018 CS 100 - Lecture 2 CS 100

Algorithm for Adding Two m-Digit Numbers Lecture 2 11/15/2018 Algorithm for Adding Two m-Digit Numbers Note, we always must be clear about what inputs our algorithm should work on. Numbers of at least one digit? AT least 2? Is there a maximum? 11/15/2018 CS 100 - Lecture 2 CS 100

Algorithm Set value of c (carry) to 0. Lecture 2 11/15/2018 Algorithm Set value of c (carry) to 0. Set value of i (column number) to 0. Repeat steps (a) – (d) until i > m–1. Set ci to c + ai + bi. If ci < 10, then set c to 0, otherwise set c to 1 and reset ci to ci – 10. Add 1 to i. Set cm to value of c. Print answer cmcm–1…c1c0. Note that this is very slightly different from the book (p. 7) for greater clarity. 11/15/2018 CS 100 - Lecture 2 CS 100

Importance of Algorithms Lecture 2 11/15/2018 Importance of Algorithms If you can specify an algorithm to solve a problem, then you can automate its solution 11/15/2018 CS 100 - Lecture 2 CS 100

Requirements for Automated Computation Lecture 2 11/15/2018 Requirements for Automated Computation Ability to make device to do basic operations Ability to make control device for sequencing and conditional tests Technology not available until early 20th century 11/15/2018 CS 100 - Lecture 2 CS 100

Algorithmic Problem Solving Lecture 2 11/15/2018 Algorithmic Problem Solving Are there algorithmic solutions for all problems? No! Gödel discovered algorithmically unsolvable problems in 1930s Can algorithmically solvable problems be solved efficiently? No! They are inherently hard problems Even for problems that are efficiently algorithmically solvable, efficient algorithms may be difficult to find These are some of the issues addressed by computer scientists 11/15/2018 CS 100 - Lecture 2 CS 100

Non-Algorithmic Information Processing Lecture 2 11/15/2018 Non-Algorithmic Information Processing “Cognitive inversion”: many things that are easy for people are hard for computers, and vice versa e.g., face recognition vs.calculating Suggests that computers & brains work in very different ways Much research in non-algorithmic information processing in neural networks Note it took several days to get the Mars Rover past the blocked ramp. 11/15/2018 CS 100 - Lecture 2 CS 100

Definition of “Algorithm” Lecture 2 11/15/2018 Definition of “Algorithm” An algorithm is a well-ordered collection of unambiguous and effectively computable operations that produces a result and halts in a finite amount of time …a well-ordered collection… …of unambiguous and effectively computable operations… …that produces a result… …and halts in a finite amount of time well-ordered collection: we know the order in which the operations should be performed of unambiguous and effectively computable operations: unambiguous: we have to know what we are supposed to do depends on computing agent (context) the most basic operations are called primitive operations effectively computable: an operation performable by a computing agent that produces a result: generally algorithms are used to get answers in some cases, algorithms control devices, etc., so “result” must be taken broadly and halts in a finite amount of time: we can’t wait forever some algorithms are designed to run forever (or indefinitely), but they must do their work along the way in finite time 11/15/2018 CS 100 - Lecture 2 CS 100

Definition of CS Reconsidered Lecture 2 11/15/2018 Definition of CS Reconsidered Computer Science is the study of algorithms, including: Their formal and mathematical properties Their hardware realizations Their linguistic realizations Their applications 11/15/2018 CS 100 - Lecture 2 CS 100

Organization of Text fig. from Schneider & Gersting 11/15/2018 Lecture 2 11/15/2018 Organization of Text fig. from Schneider & Gersting 11/15/2018 CS 100 - Lecture 2 CS 100

Reading Read one chapter of S&G per week unless I say otherwise Lecture 2 11/15/2018 Reading Read one chapter of S&G per week unless I say otherwise Read ch. 2 for the next class 11/15/2018 CS 100 - Lecture 2 CS 100