Fundamentals of Algorithms MCS - 2 Lecture # 3. Representation of Algorithms.

Slides:



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

CS101: Introduction to Computer programming
1 CS101 Introduction to Computing Lecture 17 Algorithms II.
JAVA Coursework (the same for 2A and 2B). Fundamental Information The coursework is 30 marks in your O’Level = 15% of the exam Must be word processed.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
Fundamentals of Algorithms MCS - 2 Lecture # 4
1 Pseudocode For Program Design. 22 Rules for Pseudocode Write only one statement per line Capitalise initial keyword Indent to show hierarchy and structures.
ITEC113 Algorithms and Programming Techniques
Chapter 2- Visual Basic Schneider
Pseudocode.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Pseudocode.
Chapter 3 Planning Your Solution
Review Algorithm Analysis Problem Solving Space Complexity
PRE-PROGRAMMING PHASE
Fundamentals of C programming
Chapter 2: Problem Solving
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.
U NDERSTANDING P ROBLEMS AND HOW TO S OLVE THEM BY USING C OMPUTERS.
CIS Computer Programming Logic
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Lecture 4 Introduction to Programming. if ( grade ==‘A’ ) cout
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
By the end of this session you should be able to...
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.
Software Life Cycle What Requirements Gathering, Problem definition
CPS120 Introduction to Computer Programming The Programming Process.
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.
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.
4. The process specification (プロセス仕様) You will learn: (次の内容を学び) The concept of process specification (プロセス 仕様の概念) Notations for process specification (プロセス.
PROGRAMMING PAPER 2 AS Algorithms.
Control Structures CPS120: Introduction to Computer Science Lecture 5.
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.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
Pseudocode An Introduction. Flowcharts were the first design tool to be widely used, but unfortunately they do not reflect some of the concepts of structured.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Introduction to Computing Dr. Nadeem A Khan. Lecture 2.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
 In this chapter you will learn about:  Introduction to Problem Solving  Software development method (SDM)  Specification of needs  Problem analysis.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Fundamentals of Algorithms MCS-2 Lecture 1 Introduction.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
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.
Programming Fundamentals Introduction to Problem Solving  Programming is a problem solving activity. When you write a program, you are actually writing.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
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.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
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.
 Problem Analysis  Coding  Debugging  Testing.
PROGRAM CONTROL STRUCTURE
Introduction To Flowcharting
Numbering System TODAY AND TOMORROW 11th Edition
Programming Fundamentals
Unit# 9: Computer Program Development
Algorithms & Pseudocode
Understanding Problems and how to Solve them by using Computers
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Flowcharts and Pseudo Code
Basic Concepts of Algorithm
WJEC GCSE Computer Science
Presentation transcript:

Fundamentals of Algorithms MCS - 2 Lecture # 3

Representation of Algorithms

Representing algorithms  Algorithms may be specified in many forms  called representations or notations.  The representation of an algorithm is extremely important  It must rapidly convey the algorithm’s meaning with the least amount of effort by the reader.  No one representation is suitable for all algorithms.  It is worth getting familiar with a number of alternative forms.  The best representation for one algorithm may be the worst for another.

Representation of Algorithms Algorithms are generally represented by either  Verbal  The algorithm is expressed in words, sentences and paragraphs.  Usually very verbose, long, and often inaccurate.  Algebraic  The algorithm is expressed mathematically with symbols and formulas.  This is usually a very concise representation.  Tabular  The algorithm is represented by one or more rectangular grids (tables, arrays or matrices) with entries in the grids.  This method is useful for summarizing large selections.

Representation of Algorithms  Hierarchical  The algorithm is presented as a break-out diagram.  Data Flow Diagram  The algorithm is shown as a set of boxes that show the actions to be performed.  Flow chart  The algorithm is represented in the form of a diagram with action boxes linked by lines.  Pseudo code  The algorithm is presented as a set of instructions written using a mixture of natural language and mathematical notation.

Pseudo code  It is a mixture of  natural language and mathematical notation  independent of any programming language.  Reflects the fact “short-term communication” between members working on a specific project  The code itself and other documents are used for long-term archival purposes.  Pseudo code can be written in very formal constructs. It can be used almost like a free- verse description of what the program needs to do.  What the input is?  What the output should be?

Rules for Pseudo code No strict rules exist. Write only one statement per line Capitalize initial keyword Indent to show hierarchy End multi-line structures Keep statements language independent

A Recommended Pseudo code Format  Documentation Keyword  Action Keywords  Flow Control Keywords

Documentation Keyword Documentation keywords describe what needs to be done or provides information about why something is being done.  TASK  TASK statement is something that the program must perform.  REM  REM statement is merely a remark or comment.

Action Keywords Action keywords are the lines that actually do the work  Common Action Keywords  Input: READ, OBTAIN, GET  Output: PUT, PRINT, DISPLAY, SHOW  Compute: COMPUTE, CALCULATE, DETERMINE  Initialize: SET, INIT  Add one: INCREMENT, DECREMENT

Flow Control Keywords  Sequence Calculate Pay – sequence Begin input hours input rate pay = hours * rate print pay End Sum of 2 Numbers – sequence Begin input x, y sum = x + y print sum End

Flow Control Keywords  Selection IF (test condition) Statement(s) to be executed if test condition is TRUE ELSE Statement(s) to be executed if test condition is FALSE Calculate Pay with Overtime - selection Begin input hours, rate if hours  40 then pay = hours * rate else pay = 40 * rate + (hours – 40) * rate * 1.5 print pay End IF amount < 1000 interestRate =.06 // the “yes” or “true” action ELSE interestRate =.10 // the “no” or “false” action ENDIF

Flow Control Keywords  Repetition - Case 1  LOOP WHILE (test condition) Statement(s) to be executed if test condition is TRUE  Repetition - Case 2  LOOP Statement(s) to be executed if test condition is TRUE WHILE: (test condition) Average of 10 Numbers – iteration with a for loop Begin sum = 0 for i = 1 to 10 input x sum = sum + x avg = sum / 10.0 print avg End

Flow Control Keywords  Repetition - Case 3  LOOP UNTIL (test condition) Statement(s) to be executed if test condition is FALSE  Repetition - Case 4  LOOP Statement(s) to be executed if test condition is FALSE UNTIL (test condition)

Good Luck ! ☻