STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.

Slides:



Advertisements
Similar presentations
Algorithms 10 IST – Topic 6.
Advertisements

CS101: Introduction to Computer programming
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
Chapter 2: Problem Solving
PSEUDOCODE & FLOW CHART
Program Design Tool. 6 Basic Computer Operations Receive information Put out information Perform arithmetic Assign a value to variable (memory location)
ITEC113 Algorithms and Programming Techniques
Program Design and Development
Pseudocode and Algorithms
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
Chapter 2: Algorithm Discovery and Design
Pseudocode.
Chapter 3 Planning Your Solution
The Program Design Phases
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Fundamentals of C programming
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
U NDERSTANDING P ROBLEMS AND HOW TO S OLVE THEM BY USING C OMPUTERS.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 4: Control Structures I (Selection)
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
A step-by-step procedure for solving a problem in a finite number of steps.
Flowcharts.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Visual Basic Programming
ITEC113 Algorithms and Programming Techniques
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
 Software Development Life Cycle  Software Development Tools  High Level Programming:  Structures  Algorithms  Iteration  Pseudocode  Order of.
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,
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Algorithms and Pseudocode
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Lecture 3: Developing Procedural Thinking (How to think like a programmer) B Burlingame 16 Feb 2016.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
 Problem Analysis  Coding  Debugging  Testing.
Algorithms and Flowcharts
Program design Program Design Process has 2 phases:
Learning outcomes 5 Developing Code – Using Flowcharts
REPETITION CONTROL STRUCTURE
PROGRAM CONTROL STRUCTURE
Lecture 2 Introduction to Programming
Introduction To Flowcharting
Algorithm Algorithm is a step-by-step procedure or formula or set of instruction for solving a problem Its written in English language or natural language.
Introduction to Computer Programming
Programming Fundamentals
Unit# 9: Computer Program Development
1) C program development 2) Selection structure
Introduction to Algorithms and Programming
` Structured Programming & Flowchart
Understanding Problems and how to Solve them by using Computers
ICT Programming Lesson 3:
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Flowcharts and Pseudo Code
ICT Gaming Lesson 2.
Basic Concepts of Algorithm
Presentation transcript:

STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.

WHAT IS AN ALGORITHM? An algorithm is a sequence of precise instructions for solving a problem in a finite number of steps.

Algorithms must: be precise (clearly defined), be unambiguous, be logically sequenced (flow of control from one process to another), give the correct solution in all cases, and eventually end ( a general solution to the problem in a finite number of steps). Algorithms must: be precise (clearly defined), be unambiguous, be logically sequenced (flow of control from one process to another), give the correct solution in all cases, and eventually end ( a general solution to the problem in a finite number of steps). Properties of well-written algorithms:

Sequence - the ability of the program to execute instructions in a step-by-step manner. Selection - the ability of the computer to make decisions and alter the course of the algorithm. Example: IF statement Iteration (repetition or looping) - the ability of the computer to repeat a block of instructions until a condition is met. Example: WHILE, FOR and DO-WHILE loops. Sequence - the ability of the program to execute instructions in a step-by-step manner. Selection - the ability of the computer to make decisions and alter the course of the algorithm. Example: IF statement Iteration (repetition or looping) - the ability of the computer to repeat a block of instructions until a condition is met. Example: WHILE, FOR and DO-WHILE loops. Algorithm design generally has three structural components: Conditional

Sequence The sequence control structure is used when you have instructions to be carried out in a particular order. Example: » Start » Get 2 numbers » Add the number and store it in Answer » Display Answer » Stop

Selection The Selection control structure is used in problems with instructions to be carried out if a certain condition is met. The choice of option will be dependent on if the condition is true or false. Example » Start » Accept score » If score is more than 59 then display ‘the student has passed’ else display ‘the student has failed’ » stop

Iteration/ repetition/ loop Iteration or Repetition control structures are used to repeat a certain process a number of times. Suppose you want to accept 100 numbers from the user and find their sum, it will be wise to repeat the process of getting the numbers 100 times rather than writing 100 instructions to accept the numbers. Commonly used iteration statements are: » For………….end for » While………end while » Repeat…….until

Algorithms are normally written in (i)pseudocode or pseudo-English or (ii)represented by a flowchart. A pseudocode is an algorithm that resembles the programming language. It however cannot be executed by the computer. A flowchart is a pictorial representation of an algorithm. These are diagrams that help us to visualize the sequence of algorithms.

Algorithmic structure Header: Algorithm’s name or title Declaration: Brief description of algorithm and variable used. i.e. A statement of purpose as well as the initialization of variables Body: Sequence of steps Terminator: An end statement PSEUDOCODE

Write an algorithm that prompts a student to enter his/her name and age, accepts the name and age and then display a welcoming message on the screen such as “Hello Michael! You are 16 years old!” Identify the header, declaration, body and terminator. Problem

Algorithm Student_data {Header} This algorithm displays a student’s name and age on the screen. {declaration} START PRINT “Enter your name:” READ Namebody PRINT “Enter your age:” READ Age PRINT “Hello”, Name PRINT “You are”, Age, “years old” STOP{Terminator} Algorithm Student_data {Header} This algorithm displays a student’s name and age on the screen. {declaration} START PRINT “Enter your name:” READ Namebody PRINT “Enter your age:” READ Age PRINT “Hello”, Name PRINT “You are”, Age, “years old” STOP{Terminator}

Flowcharts are diagrams that arrange the components of a problem in a logical sequence. Flowcharts must use special geometrical objects that designate the basic steps of a program. The objects are linked using arrowed lines that point to the next step in the sequence. Flowcharts are diagrams that arrange the components of a problem in a logical sequence. Flowcharts must use special geometrical objects that designate the basic steps of a program. The objects are linked using arrowed lines that point to the next step in the sequence. FLOWCHARTS

Flowchart symbols

Create a flowchart to solve the above problem Problem

Pseudocode is more concise, closely resembles programming language and there are no symbols to learn Flowchart gives good view of the structure and flow of the logic Beginners tend to follow the logic easier when using flowcharts rather than pseudocode Longer, more complex solutions are better represented using pseudocode. Pseudocode uses less paper to document FLOWCHARTS VS. PSEUDOCODE