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.

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

PSEUDOCODE & FLOW CHART
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Chapter 2 - Problem Solving
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
 Control structures  Algorithm & flowchart  If statements  While statements.
Computer Science 101 Overview of Algorithms. Example: Make Pancakes Prepare batter Beat 2 eggs Add 1 tablespoon of brown sugar Add 1 cup of milk Add 2.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
ITEC113 Algorithms and Programming Techniques
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
What is an algorithm? Informally: An Algorithm is a step by step method for solving a problem. It’s purpose is to break a larger task down so that each.
Chapter 2: Algorithm Discovery and Design
Chapter 2 The Algorithmic Foundations of Computer Science
Chapter 3 Planning Your Solution
Review Algorithm Analysis Problem Solving Space Complexity
Adapted from slides by Marie desJardins
CSC103: Introduction to Computer and 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.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
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.
Algorithm Design.
1 Program Planning and Design Important stages before actual program is written.
CSCI-100 Introduction to Computing
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
1 Programming Tools Flowcharts Pseudocode Hierarchy Chart Direction of Numbered NYC Streets Algorithm Class Average Algorithm.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Data Structures & Algorithms CHAPTER 1 Introduction Ms. Manal Al-Asmari.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
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.
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.
Sesi 0607EKT120/4 Computer Programming Week 5 – Repetition / Loops.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Program Design & Development EE 201 C7-1 Spring
Pseudocode (pronounced SOO-doh-kohd)  is a detailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled.
Program design Program Design Process has 2 phases:
ALGORITHMS AND FLOWCHARTS
Introduction to Algorithms
Chapter 2: Input, Processing, and Output
GC211Data Structure Lecture2 Sara Alhajjam.
ALGORITHMS AND FLOWCHARTS
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Introduction to Computer Programming
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithm and Ambiguity
Unit# 9: Computer Program Development
Algorithm Discovery and Design
Introduction to Algorithms and Programming
Algorithm and Ambiguity
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
PROBLEM ANALYSIS.
WJEC GCSE Computer Science
Presentation transcript:

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 definition more closely an ordered sequence means that you can number the steps (it's socks then shoes!) unambiguous and well-defined instructions means that each instruction is clear, do-able, and can be done without difficulty performs some task halts in finite time (algorithms terminate!)

 Three Categories of Algorithmic Operations Algorithmic operations are ordered in that there is a first instruction, a second instruction etc. However, this is not enough. An algorithm must have the ability to alter the order of its instructions. An instruction that alters the order of an algorithm is called a control structure Three Categories of Algorithmic Operations: sequential operations - instructions are executed in order  conditional ("question asking") operations - a control structure that asks a true/false question and then selects the next instruction based on the answer  iterative operations (loops) - a control structure that repeats the execution of a block of instructions

 Unfortunately not every problem or task has a "good" algorithmic solution. There are unsolvable problems - no algorithm can exist to solve the problem (Halting Problem)  "hard" (intractable) problems - algorithm takes too long to solve the problem (Traveling Salesman Problem)  problems with no known algorithmic solution

 How to represent algorithms Use natural languages  too verbose  too "context-sensitive"- relies on experience of reader  Use formal programming languages  too low level  requires us to deal with complicated syntax of programming language  Pseudo-Code - natural language constructs modeled to look like statements available in many programming languages

 Pseudo-Code is simply a numbered list of instructions to perform some task. In this course we will enforce three standards for good pseudo code Number each instruction. This is to enforce the notion of an ordered sequence of... operations. Furthermore we introduce a dot notation (e.g. 3.1 come after 3 but before 4) to number subordinate operations for conditional and iterative operations  Each instruction should be unambiguous (that is the computing agent, in this case the reader, is capable of carrying out the instruction) and effectively computable (do-able).  Completeness. Nothing is left out.

 Example #1 Computing Sales Tax : Pseudo-code the task of computing the final price of an item after figuring in sales tax. Note the three types of instructions: input (get), process/calculate (=) and output (display) get price of item  get sales tax rate  sales tax = price of time times sales tax rate  final prince = price of item plus sales tax  display final price  halt  Variables: price of item, sales tax rate, sales tax, final price

 Example #2 Computing Weekly Wages: Gross pay depends on the pay rate and the number of hours worked per week. However, if you work more than 40 hours, you get paid time-and-a- half for all hours worked over 40. Pseudo-code the task of computing gross pay given pay rate and hours worked. get hours worked  get pay rate  if hours worked ≤ 40 then  gross pay = pay rate times hours worked  else  gross pay = pay rate times 40 plus 1.5 times pay rate times (hours worked minus 40)  display gross pay  halt  variables: hours worked, ray rate, gross pay

 Computation/Assignment set the value of "variable" to :"arithmetic expression" or "variable" equals "expression" or "variable" = "expression"

 Input/Output get "variable", "variable",... display "variable", "variable",...

 Conditional (dot notation used for numbering subordinate statements) if "condition"  (subordinate) statement 1  etc...  else  (subordinate) statement 2  etc...

 Iterative (dot notation used for numbering subordinate statements) while "condition"  (subordinate) statement 1  etc...

 1 Request the number of students;  2 Get the grade for each student;  3 Process the average grade for the whole school;

 Application start;  02 Declare an integer variable numberOfStudents;  03 Declare an integer variable counter;  04 Declare an integer variable sum;  05 Declare a decimal variable average;  06  07 Set the numberOfStudents value to 0;  08 Set the counter value to 0;  09 Set the sum value to 0;  10  11 Request the number of students (numberOfStudents);  12  13 If the entered number of students is 0 then  14 Exit the application  15 Else  16 While the counter is less or equal to the number of students  17 Get the student grade  18 Add the student grade to the sum variable  19 Increment the counter by 1.  20 Get the next student information  21  22 When the student information is entered, set the average variable to the result of the division (sum divided by the number of students).  23 Show the result.  24 Application end.

 Get into your assigned group  As a group you will take 5 minutes and assign group members to a task.  As a group you will choose what your Algorithm will accomplish. What is your program. Take 15 min.  Task choice 1. Time Keeper: 1 person will use Microsoft Excel to create a timeline for groups completion and implement each completed task on a Power Point Presentation. 2. Designer: 2 students will create 2 flow charts in Microsoft Excel first flowchart describes each group members role and responsibility. 2 nd flowchart will consist of description of Pseudocode. 3. Coders: 2 students will create the Pseudocode and Algorithm. Friday we will present and implement code. We will view C++ and JAVA