Slides:



Advertisements
Similar presentations
6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Advertisements

Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 1: An Introduction to Computer Science Invitation to Computer Science, C++ Version, Third Edition.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Chapter 2: Algorithm Discovery and Design
Program Design and Development
Application architectures
Chapter 2: Input, Processing, and Output
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Chapter 1 Principles of Programming and Software Engineering.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 1 Program Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 2: Algorithm Discovery and Design
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
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.
Neal Stublen Computer Systems Hardware Display Keyboard Mouse Microphone Memory Chips Microprocessor.
Application architectures
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 13 Slide 1 Application architectures.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Introduction CSE 1310 – Introduction to Computers and Programming
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 2.
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.
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.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Top-Down Design and Modular Development. The process of developing methods for objects is mostly a process of developing algorithms; each method is an.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
CCSB223/SAD/CHAPTER131 Chapter 13 Designing the System Internals.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
1 Pertemuan 25 Bahasa-bahasa Pemrograman Matakuliah: T0604-Pengantar Teknologi Informasi Tahun: 2008 Versi: 2.0/0.0 Williams, B.K, Stacy C. Sawyer (2007).
Program Development C# Programming January 30, 2007 Professor J. Sciame.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 7 What Can Computers Do For Me?. How important is the material in this chapter to understanding how a computer works? 4.
The Hashemite University Computer Engineering Department
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
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 Principles of Programming and Software Engineering.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
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.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Low-Level Programming Languages, Pseudocode and Testing Chapter 6.
Your Interactive Guide to the Digital World Discovering Computers 2012 Chapter 13 Computer Programs and Programming Languages.
Principles of Programming & Software Engineering
Every step in an algorithm has two basic components:
Algorithm and Ambiguity
Algorithm and Ambiguity
Algorithms and Problem Solving
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Programming Logic and Design Eighth Edition
Presentation transcript:

Chapter 6: Problem Solving and Algorithm Design In general, how are problems solved on a computer? Analysis & Specification Understand the problem Specify what the program needs to do Algorithm Development Formulate sequence of steps for solving problem Test that the steps work for certain key cases Implementation Translate the algorithm into a programming language Test whether the program produces correct results Maintenance Deliver the program and have real users use it Debug and upgrade the program as needed Chapter 6 Problem Solving and Algorithm Design Page 56

Problem Solving and Algorithm Design Algorithms An algorithm is an ordered set of unambiguous, executable steps that ultimately terminate if followed. Ambiguous: Not executable: Lather Chapter 6 Problem Solving and Algorithm Design Page 57 No termination: Rinse Repeat

Problem Solving and Algorithm Design Computer Algorithms In computer programming, an algorithm is the sequence of steps (i.e., the “recipe”) for accomplishing a task. Every step in an algorithm has two basic components: Semantics: The meaning of the step Syntax: The format of the step Semantics Get a value from the user Double that value Return the result to the user Syntax Program DoubleIt; var x, y integer; begin write(“Input your number: ”); read(x); y = 2*x; writeln(“The doubled number is ”, y); end. Chapter 6 Problem Solving and Algorithm Design Page 58

Pseudocode Pseudocode is an informal notation for expressing an algorithm. Procedure Sat1231A Set year to 2001 Set month to January Set day to first Saturday in January 2001 While (year < 2021) Do { Increment day by 7 If date is New Year’s Eve Then display year as having a Saturday New Year’s Eve If day > (number of days in month) Then Adjust day by subtracting the number of days in month If month is December Increment year by 1 } Else Increment month by one Example: Which years in 2001-2020 have New Year’s Eve on Saturday? Chapter 6 Problem Solving and Algorithm Design Page 59

Problem Solving and Algorithm Design Algorithm Alternatives It’s possible to devise many algorithms to solve the same problem. Procedure Sat1231B Set day_of_week to 12/31/2000 Set year to 2001 While (year < 2021) Do { If year is a leap year Then increment day_of_week by 2 Else increment day_of_week by 1 If day_of_week is Saturday Then display year as having a Saturday New Year’s Eve Increment year by 1 } Alternative pseudocode to determine which years in 2001-2020 have New Year’s Eve on Saturday. Both algorithms work, but which is better? Which is easier to code? Which runs more efficiently? Chapter 6 Problem Solving and Algorithm Design Page 60

Networking Capability Artificial Intelligence Program Modularity The software development process usually involves a team of developers, so the software is often designed as a hierarchical system of modules, which can be viewed as easily modified interdependent entities. Video Game Networking Capability Data Security Server Access Customer Billing Game Play Animation Character Animation Special Effects Backgrounds Artificial Intelligence Sound Music Voice Sound Effects Chapter 6 Problem Solving and Algorithm Design Page 61

Problem Solving and Algorithm Design Advantages of Modular Programming Modifiability It’s easier to alter or upgrade the program if changes can be segregated to particular modules Debuggability It’s easier to diagnose and pinpoint problems with the program if it’s split into logically distinct modules Reusability Generic modules can be developed and then reused in other programs, eliminating the need to “reinvent the wheel” Readability It’s easier to read someone else’s program or refresh you memory about your own program if it’s broken into self-contained units Chapter 6 Problem Solving and Algorithm Design Page 62

Computer Graphics Modularity Example Initially, set the program up to calculate the scene with simple lighting. Replace the simple lighting with more sophisticated reflective surfaces. Add a module to smooth out the silhouettes of objects. main generate polygons torus cube teapot sphere cone draw shade polygon pixels main generate polygons torus cube teapot sphere cone draw blend compute reflect pixels main generate polygons torus cube teapot sphere cone draw blend compute reflect pixels curved surfaces Chapter 6 Problem Solving and Algorithm Design Page 63

Top-Down Design One common approach for designing programs is the top-down methodology. Design a high-level solution to the programming problem. Consider each complicated subproblem as a separate programming problem. Return to step #1 with each subproblem. Process Payroll Get Input Data Retrieve Timecard Data Retrieve Salary Information Retrieve Dependent Records Retrieve Retirement Plans Retrieve Tax Rates Perform Calculations Compute Gross Pay Compute Deductions Produce Output Generate Paychecks Update YTD Records This approach lends itself to modularity. However, it may impose an artificial hierarchy on the tasks being performed. Chapter 6 Problem Solving and Algorithm Design Page 64

Bottom-Up Design A newer approach for designing programs is the bottom-up methodology. Separate each major task in the overall problem into an individual programming problem. Develop cooperative programming solutions to the separate problems. Video Game Engine Physics Engine Fluid Dynamics Engine Particle Systems Engine Collision Detection Engine Math Engine Rotational Calculation Engine Fractal Engine Artificial Intelligence Engine Intelligent Agent Engine Behavior Prediction Engine This approach produces reusable modules. However, those modules may prove difficult to cobble together to solve bigger problems. Chapter 6 Problem Solving and Algorithm Design Page 65