Algorithms CS139 – Aug 30, 2004. Problem Solving Your roommate, who is taking CS139, is in a panic. He is worried that he might lose his financial aid.

Slides:



Advertisements
Similar presentations
CHAPTER 2 ALGORITHM ANALYSIS 【 Definition 】 An algorithm is a finite set of instructions that, if followed, accomplishes a particular task. In addition,
Advertisements

CS107 Introduction to Computer Science Lecture 2.
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2 - Problem Solving
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.
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.
© Janice Regan Problem-Solving Process 1. State the Problem (Problem Specification) 2. Analyze the problem: outline solution requirements and design.
1 CENG 707 Data Structures and Algorithms Nihan Kesim Çiçekli Department of Computer Engineering Middle East Technical University Fall 2010.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Using Algorithms Copyright © 2008 by Helene G. Kershner.
Algorithms and Problem Solving
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Program Design and Development
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Chapter 6 Problem Solving and Algorithm Design Nell Dale John Lewis.
Programming Fundamentals (750113) Ch1. Problem Solving
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Chapter 2: Algorithm Discovery and Design
Design and Analysis of Algorithms
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
Simple Program Design Third Edition A Step-by-Step Approach
Chapter An Introduction to Problem Solving 1 1 Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
An Introduction to Programming with C++ Sixth 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.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
What does a computer program look like: a general overview.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 Section 2.1 Algorithms. 2 Algorithm A finite set of precise instructions for performing a computation or for solving a problem.
1 CS161 Introduction to Computer Science Topic #9.
CS139 – Algorithm Development Aug 23, 2004 WELCOME!
Advanced Engineering Mathematics, 7 th Edition Peter V. O’Neil © 2012 Cengage Learning Engineering. All Rights Reserved. CHAPTER 4 Series Solutions.
Chapter 10 Algorithmic Thinking. Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the.
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.
The Hashemite University Computer Engineering Department
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
WHAT IS THIS? Clue…it’s a drink SIMPLE SEQUENCE CONTROL STRUCTURE Introduction A computer is an extremely powerful, fast machine. In less than a second,
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Computer Systems Architecture Edited by Original lecture by Ian Sunley Areas: Computer users Basic topics What is a computer?
Algorithms and Flowcharts
Algorithms Sept 4, Tuesday’s Lab You developed an algorithm Input – an 8 ½ x 11 inch piece of paper Audience – Fellow classmates Process – Instructions.
Algorithms and Problem Solving
Topic: Introduction to Computing Science and Programming + Algorithm
Lecture 2 Introduction to Programming
Algorithm and Ambiguity
CS190/295 Programming in Python for Life Sciences: Lecture 1
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Programming We have seen various examples of programming languages
Algorithms and Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Basic Concepts of Algorithm
Presentation transcript:

Algorithms CS139 – Aug 30, 2004

Problem Solving Your roommate, who is taking CS139, is in a panic. He is worried that he might lose his financial aid if his GPA goes under 2.0 How can he figure out what his current GPA is? How can you build a process that any student can use to tell them what GPA they have based on grades provided thus far?

Algorithm Development Objectives  At the end of this unit the student will: define the term algorithm state 5 properties of a good algorithm from a given problem and stated audience, create an appropriate algorithm using the properties stated above. use the concept of abstraction and top-down design in creating an algorithm. begin to think about the kinds of problems that have a computing solution.

References for this lecture  Schaum’s Outline – Chapter 2

Problem Solving 1. Understand the problem (and the audience) 1. Are you making a pie? 2. Needing directions? 3. Putting together a piece of equipment? 4. Trying to solve a mathematical puzzle? 2. Devise a plan 1. Is this similar to something else? 2. Who is the audience for the solution? 3. What are the required steps?

Problem Solving ( Cont’d ) 3.Carry out the plan (implement) 1.Does it work? 2.Is each step correct? Necessary? 4.Is the solution accurate? (Correct) 1.Will it always lead to a solution

Algorithm Definition  A logical sequence of steps for solving a problem, …  From  Dale and Lewis:  a plan of solution for a problem  Algorithm – An unambiguous (and precise) set of steps for solving a problem (or sub-problem) in a finite amount of time using a finite amount of data.

Algorithm Definition, cont  Shackelford, Russell L. in Introduction to Computing and Algorithms – “An algorithm is a specification of a behavioral process. It consists of a finite set of instructions that govern behavior step-by-step.”

Notice  Notice the term finite. Algorithms should lead to an eventual solution.  Step by step process. Each step should do one logical action.

Algorithms  Algorithms are addressed to some audience. Consider: A set of instructions for building a child’s bicycle. A diagnostic checklist for a failure of some system on the space shuttle. The algorithm for what to do when a nuclear reactor begins to overheat. An algorithm that will run on a computer system to calculate student GPA’s.

Audience  Each audience will have its own “rules” that govern how we will address them, the language that they speak.  Each audience will have certain assumptions about what they know and don’t know.  An audience might include people or a computer.

Good vs. Bad Algorithms  All algorithms will have input, perform a process, and produce output.  A good algorithm should be: Simple - relative Complete – account for all inputs & cases Correct (Right) should have appropriate levels of Abstraction. – grouping steps into a single module Precise Mnemonic - SCRAP

Precision  Precision means that there is only one way to interpret the instruction. Unambiguous  Words like “maybe”, “sometimes” and “occasionally” have no business in a well developed algorithm.  Instead of “maybe”, we can specify the exact circumstances in which an action will be carried out.

Simplicity  Simple can be defined as having no unnecessary steps and no unnecessary complexity. ( You may lose points if your algorithm contains unnecessary steps )  Each step of a well developed algorithm should carry out one logical step of the process. Avoid something like: “Take 2 nd right after you exit at King Street”

It has Levels of Abstraction.  From the Oxford English Dictionary, abstraction is defined as: “The act or process of separating in thought, of considering a thing independently of its associations; or a substance independently of its attributes; or an attribute or quality independently of the substance to which it belongs.” Example: Add all the scores then divide the sum by the number of students to get the average.

Or in other words  The abstraction property lets us view an algorithm as a series of high level aggregate steps, with the detail hidden in a lower level.

Abstraction, cont.  Instead of approaching a problem and worrying about each and every thing you must do to solve the problem, you can begin to look at the major steps. (Top down design)  After the major steps, you can begin to fill in how you would accomplish the major step.  That fill in may lead to the need for additional levels to fill in those details, etc.  Top down design.

Diagrammatically Drive the car to school Get directions Start the car Follow the directions Get parking pass Drive to the destination Turn left out of your driveway At the next light, turn right. At the intersection with I- 66, take the on-ramp for I-66 West … Level 1 Level 2 Level 3 Find a place to park Stop the car

Other algorithm attributes  A good algorithm should be correct.  A good algorithm should be complete.  Shackelford again, “To be correct, an algorithm must produce results that are correct and complete given any and all sets of appropriate data.”  And to be correct, an algorithm must proceed through to a conclusion.

Steps from Schaum’s  Analyze the problem and develop the specification.  Design the solution Test the solution as part of the design steps.  Implement the program (code the program)  Test the program  Validate the program (further extensive testing) to insure it works under all circumstances.

In class exercise  In your group, create an algorithm to calculate a semester GPA. You may use a calculator.  Recall: GPA is based on the letter grade achieved in the class and the number of credit hours for the class. Generally QP’s – A = 4.0, B = 3.0, C=2.0, D=1.0, F=0.0 and a + adds.3 to the grade and a – subtracts.3 from the QP. The semester GPA is then the average QP for each credit hour attempted.

For example:  For example, a student is taking 4 classes: CS139 – 4 credits – C CS110 – 1 credit – A GWRIT103 – 3 credits – B+ GHIST101 – 3 credits – C-  What is the student’s semester average?  How did you figure it out?  How can you describe that process for others in the class?

Now trade papers with another group

Look at the GPA calculation algorithm  What properties does the testing algorithm display? Is is simple, precise, etc.  Test the solution using a couple of different test cases. Does the algorithm work for those different cases?  What happens if the grades are all F’s? All A’s (limits)?  What about different numbers of classes? One or 6?

Next up  You will create some other algorithms in lab.  Please be on time for your selected section.  Focus on the 5 principles as you are building your algorithms.  Tomorrow is the last day to bring in folders for credit. Check blackboard to see if you have given me a folder.  Be sure to read Chapter 2 in Schaum’s for Wednesday’s class.