Review Algorithm Analysis Problem Solving Space Complexity

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

CS 240 Computer Programming 1
ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
PSEUDOCODE & FLOW CHART
ALGORITHMS AND FLOWCHARTS
CS 240 Computer Programming 1
INTRODUCTION TO PROGRAMMING
ITEC113 Algorithms and Programming Techniques
Chapter 2- Visual Basic Schneider
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
Chapter 3 Planning Your Solution
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Algorithm & Flowchart.
Fundamentals of C programming
Chapter 1 Pseudocode & Flowcharts
ALGORITHMS AND FLOWCHARTS
Computer Programming 12 Lesson 2 - Organizing the Problem By Dan Lunney.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
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.
CSC141 Introduction to Computer Programming
Chapter 2 - Algorithms and Design
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.
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.
Programming Concepts Chapter 3.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
Software Life Cycle What Requirements Gathering, Problem definition
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.
Flowcharts.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
1 Chapter 2 - Algorithms and Design print Statement input Statement and Variables Assignment Statement if Statement Flowcharts Flow of Control Looping.
Program Planning and Design. What is Program Planning and Design? Program planning and design is simply knowing what you want to do and how you want to.
1 Program Planning and Design Important stages before actual program is written.
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)
Concepts of Algorithms CSC-244 Unit Zero Pseudo code, Flowchart and Algorithm Master Prince Computer College Qassim University K.S.A.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
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. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Lecture 3 Computer Programming -1-. The main steps of program development to solve the problem: 1- problem definition : The problem must be defined into.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
 Problem Analysis  Coding  Debugging  Testing.
Algorithms and Flowcharts
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
GC101 Introduction to computers and programs
Introduction to Algorithms
Algorithm & Programming
Chapter 2- Visual Basic Schneider
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
Algorithms and Flowcharts
Introduction to Computer Programming
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
ALGORITHMS AND FLOWCHARTS
Algorithms & Pseudocode
1) C program development 2) Selection structure
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Introduction to Algorithms and Programming
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Flowcharts and Pseudo Code
Introduction to Programming
Presentation transcript:

Review Algorithm Analysis Problem Solving Space Complexity Time Complexity Classifying Functions by Their Asymptotic Growth

Pseudo Code and Flow Charts Basic elements of Pseudo code Basic operations of Pseudo code Flow Chart Symbols used in flow charts Examples

Pseudo Code and Flow Charts There are two commonly used tools to help to document program logic (the algorithm). These are Flowcharts Pseudocode. Generally, flowcharts work well for small problems but Pseudocode is used for larger problems.

Pseudo-Code Pseudo-Code is simply a numbered list of instructions to perform some task.

Writing 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 and effective. Completeness. Nothing is left out.

Pseudo-code Statements are written in simple English without regard to the final programming language. Each instruction is written on a separate line. The pseudo-code is the program-like statements written for human readers, not for computers. Thus, the pseudo-code should be readable by anyone who has done a little programming. Implementation is to translate the pseudo-code into programs/software, such as “C++” language programs.

Basic Elements of Pseudo-code A Variable Having name and value There are two operations performed on a variable Assignment Operation is the one in which we associate a value to a variable. The other operation is the one in which at any given time we intend to retrieve the value previously assigned to that variable (Read Operation)

Basic Elements of Pseudo-code Assignment Operation This operation associates a value to a variable. While writing Pseudo-code you may follow your own syntax. Some of the possible syntaxes are: Assign 3 to x Set x equal to 3 x=3

Basic Operations of Pseudo-code Read Operation In this operation we intend to retrieve the value previously assigned to that variable. For example Set Value of x equal to y Read the input from user This operation causes the algorithm to get the value of a variable from the user. Get x Get a, b, c

Basic Operations of Pseudo-code Print the output to the user Print x (This will print value of variable x) Print “Your mileage is” x Cary out basic arithmetical computations Set x to 10 Set y to x*x/3

Example: Pseudo-code of calculating area of circle 1. Begin 2. Input value for radius 3. Calculate area (pi x radius2) 4. Output radius and area 5. Quit THEN PROGRAM

Flow Chart Some of the common symbols used in flowcharts are shown. …

… With flowcharting, essential steps of an algorithm are shown using the shapes above. The flow of data between steps is indicated by arrows, or flowlines. For example, a flowchart (and equivalent Pseudocode) to compute the interest on a loan is shown below:

Note that the Pseudocode also describes the essential steps to be taken, but without the graphical enhancements. Another example of a flowchart and the equivalent Pseudocode is shown next.

Some Examples Write pseudo-code of a program that asks the user to enter two numbers and prints the sum, product, difference, and division of the two numbers. Write pseudo-code of a program that solves a quadratic equation ax2+bx+c by taking a, b and c as input from user.

Decision Making and Pseudo Code

Another Example

Pseudo Code

Loops and Pseudo Code

Draw the Flowchart 1. get hours worked 2. get pay rate 3.         if hours worked ≤ 40 then 3.1   gross pay = pay rate times hours worked 4.         else             4.1  gross pay = pay rate times 40 plus 1.5 times pay rate times (hours worked minus 40) 5.         display gross pay 6.         halt

Draw the Flowchart 1. get number of quizzes 2. sum = 0 3. count = 0 4.         while count < number of quizzes             4.1       get quiz grade             4.2       sum = sum + quiz grade             4.3       count = count + 1 5.         average = sum / number of quizzes 6.         display average 7.         halt

Summary Pseudo Code Basic elements of Pseudo code Basic operations of Pseudo code Flow Chart Symbols used in flow charts Examples