Algorithms 10 IST – Topic 6.

Slides:



Advertisements
Similar presentations
Lecture 7: Software Design (Part II)
Advertisements

CS101: Introduction to Computer programming
More on Algorithms and Problem Solving
ITEC113 Algorithms and Programming Techniques
Program Design and Development
Pseudocode and Algorithms
Chapter 2: Algorithm Discovery and Design
The Program Design Phases
Fundamentals of C programming
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Selection Control Structures Simple Program Design Third Edition A Step-by-Step Approach 4.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Repetition & Loops. One of the BIG advantages of a computer: ­It can perform tasks over and over again, without getting bored or making mistakes (assuming.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Chapter 2 Problem Solving On A Computer 2.1 Problem Solving Steps Solving a problem on a computer requires steps similar to those followed when solving.
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.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
ITEC113 Algorithms and Programming Techniques
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding the Three Basic Structures Structure: a basic unit of programming logic Any program.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Algorithms and Pseudocode
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Programming Logic and Design Fourth Edition, Introductory Chapter 2 Understanding Structure.
PROGRAMMING: What’s It All About?
Introduction to programming
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
GC211Data Structure Lecture2 Sara Alhajjam.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms and Flowcharts
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Transition to Code Upsorn Praphamontripong CS 1110
Introduction To Flowcharting
Introduction to Computer Programming
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Flow Charts What are they good for?.
Programming Fundamentals
Algorithm and Ambiguity
Software Design and Development
MSIS 655 Advanced Business Applications Programming
Structured Program
Understanding the Three Basic Structures
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
3 Control Statements:.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Introduction to Algorithms and Programming
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Faculty of Computer Science & Information System
Algorithm and Ambiguity
Instructor: Luong Tran Hy Hien
Understanding Problems and how to Solve them by using Computers
Computer Science Core Concepts
ICT Programming Lesson 3:
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Presentation transcript:

Algorithms 10 IST – Topic 6

What is an algorithm? “a series of detailed instructions or steps that will solve a problem in a set amount of time”

Common examples of algorithms Appliance Instructions a logical set of steps to operate an appliance

Common examples of algorithms Recipes a logical set of steps to cook an item

Common examples of algorithms Directions a logical set of steps to arrive at a location

Common examples of algorithms Repair Manual a logical set of steps to repair an item

Advantages of using algorithms solve problems in a logical step-by-step process avoiding vague “blundering-in-the-darkness” finite – always has an end methods are standardised language is standardised problems are described in the same way terminology is uniform

Representing algorithms Pseudocode precise form of English that uses keywords and rules of structure Flowcharts a pictorial method of describing algorithms using a set of symbols, connecting lines and arrows.

Pseudocode Keyword Meaning BEGIN END to start a program to finish a program INITIALISATION END INITIALISATION to set any values at the start of a program to end the values section BEGIN SUBPROGRAM END SUBPROGRAM to start a subprogram to finish a subprogram IF <condition> THEN ELSE ENDIF to allow selection or choice for another choice (may not be needed) to end the choice CASEWHERE <condition> OTHERWISE ENDCASE to allow for many choices to end the choices WHILE <condition> ENDWHILE to begin a loop at the start of a sequence REPEAT UNTIL <condition> to begin a loop at the end of a sequence

Pseudocode Rules Keywords are written in CAPITALS Basic keywords come in pairs … for every BEGIN there is an END Indenting is used to show structure Names of subprograms are underlined

Flowcharts

Flowchart Rules There is only ever ONE WAY into a flowchart structure and ONE WAY out. A single flowchart should fit on one page If larger than one page … use subprograms

Control Structures there are 3 basic control structures to show the order in which statements are carried out: sequencing (or steps) selection (or choice) repetition (or loops)

Sequencing most common each step is carried out in order of its position each step is done only once.

Selection Binary selection allows the choice between 2 possible paths if one condition is met then one path is taken, otherwise the other path is taken

Selection Case or Multi-way selection allows the choice between 3 or more possible paths if the condition is met (TRUE) then one path is taken, otherwise one of the other paths is taken

Repetition carries out a particular action any number of times until a condition is met a loop is created to return the program to a point where the repetition starts and continues until the condition is met the loop must have a terminating (ending) condition that is… tested at some time during each repetition updated during each repetition

Repetition Pre-test Repetition (While Loop / Guarded Loop) the condition is tested at the start of the loop if the condition is false the first time the processes will NEVER be carried out. Pre-test loops end when the condition is false. Uses WHILE … ENDWHILE

Repetition Post-test Repetition (Repeat-Until Loop / Unguarded Loop) the condition is tested at the end of the loop after the loop has been run through Post-test loops end when the condition is true Uses REPEAT … UNTIL

Repetition For-Next Repetition The body of the loop is executed a set number of times. A counter variable is given a starting value which is incremented each time the loop is executed until a given final value is reached