PROBLEM ANALYSIS.

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

College of Information Technology & Design
PROBLEM SOLVING TECHNIQUES
Subject: Information Technology Grade: 10
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
ALGORITHMS Algorithm: Is an ordered set of unambiguous, executable steps defining a terminating process Unambiguous:during the execution of an algorithm,
©Brooks/Cole, 2003 Chapter 8 Algorithms. ©Brooks/Cole, 2003 The Origins of “Algorithm”
Pseudocode and Algorithms
The Origins of “Algorithm”. The Origins of the Term “Algorithm”
Chapter 2: Algorithm Discovery and Design
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
ALGORITHMS AND FLOWCHARTS
Adapted from slides by Marie desJardins
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.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Invitation to Computer Science, Java Version, Second Edition.
©Brooks/Cole, 2003 Chapter 8 Algorithms. ©Brooks/Cole, 2003 Understand the concept of an algorithm. Define and use the three constructs for developing.
Software Life Cycle What Requirements Gathering, Problem definition
Chapter 8 Algorithms. Understand the concept of an algorithm. Define and use the three constructs for developing algorithms: sequence, decision, and repetition.
ALGORITHM CHAPTER 8. Chapter Outlines and Objectives  Define an algorithm and relate it to problem solving.  Define three construct and describe their.
PSEUDOCODE C Programming Technique – Firdaus-Harun.com.
1 The Programming Layer 2 Outline Concepts –Definition –How to develop an algorithm –Essential features Three Constructs Algorithm Representation –Pseudocode.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Chapter 2: General Problem Solving Concepts
Procedural Programming. Programming Process 1.Understand the problem 2.Outline a general solution 3.Decompose the general solution into manageable component.
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
Algorithms & FlowchartsLecture 10. Algorithm’s CONCEPT.
Algorithms Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin,
ALGORITHMS.
Chapter 8 Algorithms.
1 MODULAR DESIGN AND ABSTRACTION. 2 SPECIFYING THE DETAILS OF A PROBLEM INTO A RELATED SET OF SMALLER PROBLEMS.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2012 Sanghyun Park.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
©Brooks/Cole, 2003 Chapter 8 Algorithms. ©Brooks/Cole, 2003 CONCEPTCONCEPT 8.1.
Examples of Flow Charts Pseudocodes
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
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.
Program design Program Design Process has 2 phases:
Applied Discrete Mathematics Week 2: Functions and Sequences
GC101 Introduction to computers and programs
INTRODUCTION TO PROBLEM SOLVING
Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased.
Unit 3: ALGORITHMS AND FLOWCHARTS
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
Chapter 4 C Program Control Part I
for Repetition Structures
Data Structures and Algorithms
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
Selection Structures (Part 1)
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Chapter 4: Control Structures
Algorithm development
Algorithm and Ambiguity
ALGORITHMS AND FLOWCHARTS
Problem Solving Techniques
ALGORITHMS AND FLOWCHARTS
Programming in Pseudocode
ALGORITHMS AND FLOWCHARTS
ME 142 Engineering Computation I
Algorithm and Ambiguity
Algorithms and Problem Solving
Introduction to Programming
Teori Bahasa dan Automata Lecture 13: Algorithm
Presentation transcript:

PROBLEM ANALYSIS

The Origins of “Algorithm”

The Origins of the Term “Algorithm”

CONCEPT

Informal definition of an algorithm Figure 8-1 Informal definition of an algorithm used in a computer

Generalization of FindLargest Figure 8-5 Generalization of FindLargest

8.2 THREE CONSTRUCTS

Figure 8-6 Three constructs

8.3 ALGORITHM REPRESENTATION

Flowcharts for three constructs Figure 8-7 Flowcharts for three constructs

Pseudocode for three constructs Figure 8-8 Pseudocode for three constructs

Write an algorithm in pseudocode that finds the average of two numbers Example 1 Write an algorithm in pseudocode that finds the average of two numbers Solution See Algorithm 8.1 on the next slide.

Algorithm 8.1: Average of two AverageOfTwo Input: Two numbers Add the two numbers Divide the result by 2 Return the result by step 2 End

Write an algorithm to change a numeric grade to a pass/no pass grade. Example 2 Write an algorithm to change a numeric grade to a pass/no pass grade. Solution See Algorithm 8.2 on the next slide.

Algorithm 8.2: Pass/no pass Grade Pass/NoPassGrade Input: One number if (the number is greater than or equal to 70) then 1.1 Set the grade to “pass” else 1.2 Set the grade to “nopass” End if Return the grade End

Write an algorithm to change a numeric grade to a letter grade. Example 3 Write an algorithm to change a numeric grade to a letter grade. Solution See Algorithm 8.3 on the next slide.

Algorithm 8.3: Letter grade LetterGrade Input: One number 1. if (the number is between 90 and 100, inclusive) then 1.1 Set the grade to “A” End if 2. if (the number is between 80 and 89, inclusive) then 2.1 Set the grade to “B” Continues on the next slide

Letter grade (continued) Algorithm 8.3: Letter grade (continued) 3. if (the number is between 70 and 79, inclusive) then 3.1 Set the grade to “C” End if 4. if (the number is between 60 and 69, inclusive) then 4.1 Set the grade to “D” Continues on the next slide

Letter grade (continued) Algorithm 8.3: Letter grade (continued) 5. If (the number is less than 60) then 5.1 Set the grade to “F” End if 6. Return the grade End

See Algorithm 8.4 on the next slide. Example 4 Write an algorithm to find the largest of a set of numbers. You do not know the number of numbers. Solution See Algorithm 8.4 on the next slide.

Algorithm 8.4: Find largest FindLargest Input: A list of positive integers Set Largest to 0 while (more integers) 2.1 if (the integer is greater than Largest) then 2.1.1 Set largest to the value of the integer End if End while Return Largest End

Write an algorithm to find the largest of 1000 numbers. Example 5 Write an algorithm to find the largest of 1000 numbers. Solution See Algorithm 8.5 on the next slide.

Algorithm 8.5: Find largest of 1000 numbers FindLargest Input: 1000 positive integers Set Largest to 0 Set Counter to 0 while (Counter less than 1000) 3.1 if (the integer is greater than Largest) then 3.1.1 Set Largest to the value of the integer End if 3.2 Increment Counter End while Return Largest End

8.4 MORE FORMAL DEFINITION

8.5 SUBALGORITHMS

Concept of a subalgorithm Figure 8-9 Concept of a subalgorithm

Algorithm 8.6: Find largest FindLargest Input: A list of positive integers Set Largest to 0 while (more integers) 2.1 FindLarger End while Return Largest End

Subalgorithm: Find larger FindLarger Input: Largest and current integer if (the integer is greater than Largest) then 1.1 Set Largest to the value of the integer End if End

8.6 BASIC ALGORITHMS

Figure 8-10 Summation

Figure 8-11 Product

Developing Algorithm Using Stepwise Refinement Read the problem statement carefully Rewrite it in your own words if it is not clear Highlight the nouns and look for data items Highlight the verbs to determine the work that needs to be done Write the initial algorithm that just describes the inputs, outputs and work to be done

Stepwise Refinement Now go back to each step in the initial algorithm and refine it to describe how it will be implemented The Key steps are: Rewrite the statement if not clear Nouns==>Data, Verbs==>Action Initial Algorithm(WHAT) Final Algorithm(HOW)

Algorithm Development Exercise Problem 1 A Sunoco gas station offers 5 cents per gallon discount each Sunday. If a person fills up 20 gallons every week, how much money will that person save in X weeks?

Algorithm Development Exercise Problem 2 Given the radius of a circle, develop an algorithm that computes the area and circumference

Algorithm Development Exercise Problem 3 Write a cash register algorithm that will compute 7 percent sales tax at the price of an item and then add the tax to the price to obtain the final price

Properties of Algorithms Simplicity Precision Various Levels of Abstraction

Information Information means knowledge about something Data is a specific representation of information

Components of An Algorithm Data Structures Data Manipulation Instructions Conditional Expressions (if price greater than my_limit then don’t buy) Control Structures (while (condition) do statement Modules