Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.

Slides:



Advertisements
Similar presentations
Chapter 3: Modularization
Advertisements

ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Introduction to Programming, Algorithms & Flow Charts
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
Session Objectives# 24 COULD code the solution for an algorithm
Program Design Tool. 6 Basic Computer Operations Receive information Put out information Perform arithmetic Assign a value to variable (memory location)
Basics of Computer Programming Web Design Section 8-1.
Program Development Procedures 1.Program definition clearly define what the problem is. clearly define Input and output data (types, precision, units used)
ITEC113 Algorithms and Programming Techniques
Chapter 2- Visual Basic Schneider
Program Design and Development
Chapter 2: Input, Processing, and Output
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Chapter 1 Program Design
Chapter 4 Sec. 4.1, 4.2, 4.4 Procedures (User-defined)
Chapter 3 Planning Your Solution
BPC.1 Basic Programming Concepts
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
DCT 1123 Problem Solving & Algorithms
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Simple Program Design Third Edition A Step-by-Step Approach
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
INTRODUCTION TO PROGRAMMING, ALGORITHMS & FLOWCHARTS Programming in C2 CHAPTER 1.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 2.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Chapter 1 Introduction to Structured Design. Introduction  System  A combination of people, equipment, and procedures that work together to perform.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Programming at a high level. Developing a Computer Program Programmer  Writes program in source code (VB or other language) Compiler  Converts source.
ITEC113 Algorithms and Programming Techniques
1 Programming with MATLAB ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
5-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
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.
Programming at a high level. Developing a Computer Program Programmer  Writes program in source code (VB or other language) Compiler  Converts source.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
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.
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.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
 Problem Analysis  Coding  Debugging  Testing.
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Lecture 2 Introduction to Programming
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.
Introduction to Computer Programming
Programming Fundamentals
Unit# 9: Computer Program Development
Global Challenge Night Sensor Lesson 2.
Chapter 2- Visual Basic Schneider
Global Challenge Night Sensor Lesson 2.
Introduction to Algorithms and Programming
Chapter 2- Visual Basic Schneider
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Flowcharting & Algorithms
Global Challenge Night Sensor Lesson 2.
ICT Programming Lesson 3:
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
ICT Gaming Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Basic Concepts of Algorithm
Global Challenge Night Sensor Lesson 2.
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Presentation transcript:

Problem Solving Chapter 2

What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating

What does a programmer do? n Understand the problem specification n Develop a detailed logical plan (algorithm) for solving the problem at hand n Translate the algorithm into a programming language n Create test data to determine the correctness of their algorithm/program n Test & debug the algorithm/program n Document the program

Levels of algorithm development n Global - hierarchy diagram n Local - flowchart n Whatever you do…you MUST… RESIST THE URGE TO CODE!!!

Structured program design n Also called top-down or modular programming n Idea is: –sketch a global, modular solution hierarchy diagram or pseudocode –refine each module independently flowcharts or pseudocode n There are many advantages to this approach

In Visual Basic (or any language that supports building GUI’s) n An event procedure (or any user- defined procedure) is a module. n In development, the programmer’s focus is the GUI - its design drives all programming decisions & design

A well-written program is... n Modular (structured) n Well-designed (good algorithm) n Easy to follow –code is “clean” –simple –uses meaningful names & symbols –documented

Global design n Hierarchy diagrams

Local design - flowcharts Start/Stop block Processing block Decision block Input/Output block

Logical constructs n There are just three logical constructs used in well-designed flowcharts & structured programs: –sequence (Fig. 2.1, p. 36) –selection (Fig , p ) –iteration (Fig , p )

Sequential execution n A series of I/O & processing blocks, with the flow of execution passing straight from the top (start block) to the bottom (stop block) - no twists or turns n Why is this limiting?

Conditional branching n The flow of execution takes different turns, on the basis of certain conditions being met… n What is a condition?

start stop Read x,y x > y? yesno Write y Write x

Three types of if statements... n If - then - else –Compare two numbers x & y and display the larger of the two. n Null else –If y <> 0, divide x by y and put the quotient in z (otherwise, do nothing at all) n Nested –Make further comparisons

The assignment statement variable = expression n variable is a symbolic name that represents a memory location n expression is any combination of variables and/or constants connected by arithmetic operators +,-,*,/,**,^

Let’s do some examples…….