Lecture 13: 10/10/2002CS149D Fall 20021 CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.

Slides:



Advertisements
Similar presentations
Problem Solving and Algorithm Design
Advertisements

CS107 Introduction to Computer Science Lecture 2.
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
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.
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.
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Algorithms and Problem Solving-1 Algorithms and Problem Solving Mainly based on Chapter 6: “Problem Solving and Algorithm Design” from the Book: “Computer.
This set of slides is provided by the author of the textbook1 Introductory Topics (Continued) l Computer Components l Basic Control Structures l Problem.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
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 6 Problem Solving and Algorithm Design Nell Dale John Lewis.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
Computer Science 1620 Programming & Problem Solving.
Chapter 2: Algorithm Discovery and Design
6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Computer Programming Basics. Computer programs are a detailed set of instructions given to the computer They tell the computer: 1. What actions you want.
Chapter 1 Pseudocode & Flowcharts
Software Engineering 1 (Chap. 1) Object-Centered Design.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
Computer Programming 12 Lesson 2 - Organizing the Problem By Dan Lunney.
Lecture 17: 10/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
General Programming Introduction to Computing Science and Programming I.
Muhammad Adnan Talib Lec#4 27 th Sep,2012 Computer Science Department COMSATS Institute of Information Technology Sahiwal Introduction to Computer Programming.
Invitation to Computer Science, Java Version, Second Edition.
Problem Solving and Algorithm Design. 2 Problem Solving Problem solving The act of finding a solution to a perplexing, distressing, vexing, or unsettled.
1 Chapter 4 Program Input and the Software Design Process.
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.
CSEB114: Principle of programming
CS 1308 Computer Literacy and The Internet Software.
Lecture 18: 10/31/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
1 Special Programming Workshop CSIT-120 Fall 2000 Workshop Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming.
CSIS 123A Lecture 9 Recursion Glenn Stevenson CSIS 113A MSJC.
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.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Lecture 11: 10/1/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
1 CS161 Introduction to Computer Science Topic #9.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
Software Engineering CS103 February 13, How Do You Solve Big Problems? Thousands of programmers Thousands of programmers Months or years of coding.
1 MODULAR DESIGN AND ABSTRACTION. 2 SPECIFYING THE DETAILS OF A PROBLEM INTO A RELATED SET OF SMALLER PROBLEMS.
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Algorithms and Flowcharts
Lecture 24: 12/3/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
GC101 Introduction to computers and programs
BTEC NCF Dip in Comp: Unit 01 Principles of Computer Science Lesson 01 – Computational Thinking Mr C Johnston.
CS149D Elements of Computer Science
CS149D Elements of Computer Science
Programming Fundamentals (750113) Ch1. Problem Solving
Problem Solving and Algorithm Design
Problem Solving and Algorithm Design
Programming We have seen various examples of programming languages
Programming Fundamentals (750113) Ch1. Problem Solving
Life is Full of Alternatives
Introduction to Programming
CS149D Elements of Computer Science
Programming Fundamentals (750113) Ch1. Problem Solving
CS149D Elements of Computer Science
CS149D Elements of Computer Science
Presentation transcript:

Lecture 13: 10/10/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 13: 10/10/2002

CS149D Fall Outline Problem Solving techniques An example to apply problem solving techniques First look at a C++ program

Lecture 13: 10/10/2002CS149D Fall Problem Solving Techniques You follow algorithms every day in your life We need to learn how to design algorithms not simply follow them Some Strategies to solve problems  Ask questions  Look for things that are familiar  Means-Ends Analysis  Divide and Conquer

Lecture 13: 10/10/2002CS149D Fall Strategies: Ask Questions When you are given a problem, you ask questions (What, Why, When, and Where?) In the context of programming What do I have to work with (What is my data)? What do the data items look like? How much data is there? How will I know when I have processed all the data? What should my output look like? How many times is the process going to be repeated? What special error conditions might come up?

Lecture 13: 10/10/2002CS149D Fall Strategies: Look for Familiar Things Never reinvent the wheel If a solution exists  USE IT Finding the daily high and low temperatures is really the same problem as Finding the highest and lowest grades on a test Both problems can be abstracted as being Find largest and smallest values in a set of numbers

Lecture 13: 10/10/2002CS149D Fall Strategies: Means-Ends Analysis Beginning state and End state are often given You need to define a set of actions that can be used to get from one to the other Once you have a set of actions, you need to work out the details Translated to computer programming  Begin by writing down what the input is? (Beginning state)  What the output should be? (End state)  What actions can be performed to obtain results from input data?

Lecture 13: 10/10/2002CS149D Fall Strategies: Divide and Conquer Break up large problems into smaller problems that are easier to handle (Top-Down approach) Hard problem Easy subproblem Hard subproblem Easy subproblem

Lecture 13: 10/10/2002CS149D Fall An Example 1/3 Compute the area of a circle Problem statement We need an interactive program (user will input data) that computes the area of a circle. Given the circle radius, the circle area should be displayed on the screen Input/Output description Input  Circle radius Output  Circle area Algorithm development (set of steps, decomposition outline) 1.Read value of circle radius (r) 2.Compute circle area as pi* r 2 3.Print the value of circle area How do we represent more complex algorithms Pseudocode, flowcharts (will introduce flowcharts later)

Lecture 13: 10/10/2002CS149D Fall An Example 2/3 A divide and conquer block diagram of our problem Circle area Read radiusPrint circle areaCompute area Pseudocode Prompt the user for the circle radius (put a message on the screen) Read radius Assign Circle area the value pi * radius 2 Write Circle area on the screen Stop

Lecture 13: 10/10/2002CS149D Fall An Example 3/3 Convert algorithm into a C++ program #include void main () { float pi = f; float radius, area; cout << "Enter the radius of the circle: "; cin >> radius; area = pi* radius * radius; cout << "The area of the circle is: " << area << endl; } Let’s look at that program in Microsoft Visual C++ environment