Download presentation
Presentation is loading. Please wait.
Published byUrsula Lewis Modified over 8 years ago
1
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step at a time Complex “Human” Algorithms must be broken down into simple step-by-step instructions BEFORE they can be translated into computer code
2
Algorithm Definition: An algorithm is a procedure consisting of a finite set of unambiguous rules (instructions) which specify a finite sequence of operations that provides the solution to a problem, or to a specific class of problems for any allowable set of input quantities (if there are inputs). In other word, an algorithm is a step-by-step procedure to solve a given problem
3
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 3 Computer Program A computer program may also be called: – Project – Application – Solution
4
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 4 Program Development Cycle Software refers to a collection of instructions for the computer The computer only knows how to do what the programmer tells it to do Therefore, the programmer has to know how to solve problems
5
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 5 Performing a Task on the Computer Determine Output Identify Input Determine process necessary to turn given Input into desired Output INPUTPROCESS OUTPUT
6
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 6 Problem-solving: Approach like algebra class How fast is a car traveling if it goes 50 miles in 2 hours? Input: the distance and time the car has traveled Process: speed = distance / time Output: a number giving the speed in miles per hour
7
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 7 Pictorial representation of the problem solving process
8
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 8 Program Planning A recipe is a good example of a plan Ingredients and amounts are determined by what you want to bake Ingredients are input The way you combine them is the processing What is baked is the output
9
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 9 Program Planning Tips Always have a plan before trying to write a program The more complicated the problem, the more complex the plan must be Planning and testing before coding saves time coding “Program in Haste - debug forever.”
10
Programming Task A typical programming task can be divided into two phases: Problem solving phase – produce an ordered sequence of steps that describe solution of problem i.e. an algorithm Implementation phase – implement the program in some programming language
11
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 11 Program Development Cycle 1. Analyze: Define the problem. 2. Design: Plan the solution to the problem. 3. Choose the interface: Select the objects (text boxes, buttons, etc.). 4. Code: Translate the algorithm into a programming language. 5. Test and debug: Locate and remove errors. 6. Complete the documentation: Organize all the materials that describe the program.
12
Expressing the Algorithms A “Standard” way of describing an algorithm must exist if we expect our solution to be understood by others easily There are three main standards in programming: – PSEUDOCODE – FLOWCHARTS – PROGRAMMING LANGUAGE
13
Pseudocode Pseudocode is a generic way of describing an algorithm without use of any specific programming language syntax. “Pseudo” means “pretend” or “false” Pseudo Code is pretend or false computer code; generic English-like terms that are somewhat like computer code Pseudo Code is not as standardized as flowcharts, and does not facilitate the breaking down of problems as well as a flowchart does
14
Pseudocode Example Problem Statement: Obtain a number from the user, then display twice this number back to the user. 1.display prompt to user 2.read number 3.result = number * 2 4.display result
15
Pseudocode Advantages – Almost as easy to learn as expressing the Algorithm in English – Easier to translate into a programming language than stating the solution in English – The pseudo-code statements closely resemble most procedural programming languages Disadvantages – This technique relies on your understanding of the procedural programming languages. For someone learning their first programming language, this can be frustrating.
16
Flowcharts A Flowchart is a Visual Representation of an algorithm A Flowchart uses easy-to-understand symbols to represent actions on data and the flow of data Flowcharts aid in breaking down a problem into simple steps
17
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 17 Flowchart symbols
18
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '08 18 Flowchart Symbols (continued)
19
Example Problem Statement: Obtain a number from the user, then display square of this number back to the user.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.