0% found this document useful (0 votes)
65 views40 pages

FCCS1013 Chapter 1

This document discusses problem solving and programming. It introduces the 7 steps of the program development process: 1) define the problem, 2) outline the solution, 3) develop an algorithm, 4) test the algorithm, 5) code the algorithm, 6) run the program, and 7) document and maintain the program. It also defines an algorithm as a set of instructions to produce an output from an input and mentions that pseudocode and flowcharts are other ways to represent algorithms.

Uploaded by

Lawrence Wong
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views40 pages

FCCS1013 Chapter 1

This document discusses problem solving and programming. It introduces the 7 steps of the program development process: 1) define the problem, 2) outline the solution, 3) develop an algorithm, 4) test the algorithm, 5) code the algorithm, 6) run the program, and 7) document and maintain the program. It also defines an algorithm as a set of instructions to produce an output from an input and mentions that pseudocode and flowcharts are other ways to represent algorithms.

Uploaded by

Lawrence Wong
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 40

FCCS1013 Problem Solving and Programming

Learning Outcomes
Define Problem Solving.
Recognize 6 steps in problem solving.
Recognize 7 steps in program development process.
Describe Procedural Programming Language.
Describe Program Development Tools (Techniques).
Problem Solving in Everyday Life
Problem-solving process (6 steps)

–Identify the problem What to do?

–Understand the problem Knowledge base required

–Identify alternatives Other acceptable methods

–Select the best way to solve the problem

–List the instructions All steps required

–Evaluate the solution Check to see if result is correct


Problem Solving in Everyday Life
Example : You are doing assignment at home, and
you are hungry
Identify problem : you are hungry
Understand the problem : you need food
Identify Alternatives :
 1.) look for mum
 2.) go to kitchen and look for some food

 3.) go to kitchen and prepare food yourself

 4.) make a food delivery order

 5.) go out to have a meal in restaurant / hawker center


Problem Solving in Everyday Life
Example (continued)
Select the best way
 Method 1 : you aren’t kid anymore 
 Method 2 : might be a good idea

 Method 3 : you might not have time since you are

doing assignment.
 Method 4 : might be expensive

 Method 5 : you might not have time since you are

doing assignment.

After some consideration, let say you choose method 2


Problem Solving in Everyday Life
Example (continued)
List out the instruction
 Go out from the room
 Go to kitchen

 Search the table, cabinet, refrigerator for food

 Consume the food

 evaluate the solution


 Is the solution help to solve the problem?
 Is the solution solve the problem efficiently?

 Should we follow the same solution next time?


Types of problem
Algorithmic solutions
Can be solved with a series of actions (algorithms)
 Buying a can drink from a vending machine
 Withdraw cash from ATM machine

Heuristic solutions (rule of thumb)


Based on knowledge & experience
Requires a process of trial and error
 Bake a cheese cake
 Create a new product
Types of problem – (cont)
6-steps can be used for both problems
But step 6 (for heuristic solutions)
 Correctness and appropriateness far less certain
 May need to iterate (repeat) many times

 Same solution may not work all the time

Most problems require a combination of the two


kinds of solutions
Driving a car
Fix a malfunction computer
Problem solving with computers
Computers built for dealing with algorithmic
solutions
Heuristic solutions requires (Artificial) intelligence
Need to transform into algorithmic format

Based on current technology


Human tackle heuristic solutions
Computer tackle algorithmic solutions
Difficulties with problem solving
A lot of “problems” about problem solving
Most people do not complete adequately the problem-
solving process
Problem-solving process requires time and practice
Problem with writing the instruction
 E.g. List 5 numbers and pick the largest one.
(Can you explain/list all the steps required?)
 Computer (a tool) can perform only task that user can
explain
 All steps must be in proper order
 Computer – an IGNORANT but efficient aid to problem
solving
7 Steps of Program Development Process
 Programming can be defined as the development of
a solution to an identified problem, and the setting
up of a related series of instructions that will
produce the desired results
Define the Problem
To help with initial analysis, the problem should be
divided into three separate components:
• the inputs
• the outputs
• the processing steps to produce the required
outputs
7 Steps of Program Development Process
1. Define the problem
2. Outline the solution
3. Develop an algorithm (based on the outline)
4. Test the algorithm (for correctness)
5. Code the algorithm (into a specific programming language)
6. Run the program (on the computer)
7. Document & Maintain the program
1 Define the Problem
To help with initial analysis, the problem should be
divided into three separate components:
• the inputs
• the outputs
• the processing steps to produce the required
outputs

Input -> Process -> Output


1 Define the Problem
Example:
Shop A is offering a 20% discount for all products.
Calculate the payment for the customers.
 Input
 Discount rate, original price of the products

 Output
 payment

 Process
 Payment = original price x (100% - discount rate)
2 Outline the Solution
This initial outline is usually a rough draft of the
solution and may include:
• The major processing steps involved
• The major subtasks (if any)
• The user interface (if any)
• The major control structures (e.g. repetition loops)
• The major variables and record structures
• The mainline logic
2 Outline the Solution
Example :
Get the price of product purchase by the customer
Get the discount rate
Calculate the discount amount
Calculate the payment after discount
Display the payment amount to the customer
3 Develop the Outline into an Algorithm
The solution outline developed in Step 2 is expanded
into an algorithm: a set of precise steps that describe
exactly the tasks to be performed and the order in
which they are to be carried out
4 Test the Algorithm for Correctness
This step is one of the most important in the
development of a program, and yet it is the step most
often forgotten

The main purpose of desk checking the algorithm is


to identify major logic errors early, so that they may
be easily corrected
5 Code the Algorithm into a Specific
Programming Language
Only after all design considerations have been met

should you actually start to code the program into


your chosen programming language
6 Run the Program on the Computer

This step uses a program compiler and programmer-

designed test data to machine test the code for syntax

errors and logic errors


7 Document and Maintain the Program
Program documentation should not be listed as
the last step in the program development process,
as it is really an ongoing task from the initial
definition of the problem to the final test result

Documentation involves both external


documentation and internal documentation that
may have been coded in the program
In this course, we use C Programming Language to
create a program.

C Programming Language is lingua-franca of all


programming languages.

C Programming Language is a type of procedural


programming language.
Procedural Programming
Procedural programming is based on a structured,
top-down approach to writing effective programs

The approach concentrates on ‘what’ a program has


to do and involves identifying and organizing the
‘processes’ in the program solution
Procedural Programming -Top Down approach
In the top-down development of a program design, a
general solution to the problem is outlined first

This is then broken down gradually into more


detailed steps until finally the most detailed levels
have been completed
Procedural Programming - Modular Design
Procedural programming also incorporates the
concept of modular design, which involves grouping
tasks together because they all perform the same
function

Modular design is connected directly to top-down


development
An Introduction to Algorithms and Pseudocode

A program must be systematically and properly

designed before coding begins

This design process results in the construction of an

algorithm
What Is an Algorithm?
An algorithm is like a recipe: it lists the steps
involved in accomplishing a task

It can be defined in programming terms as a set


of detailed, unambiguous and ordered
instructions developed to describe the process
necessary to produce the desired output from a
given input
Other Techniques
From algorithm, we also can have:
Pseudocode (more English-like)
Flowcharts
Nassi-Schneiderman diagrams

As all above are all popular ways of representing


algorithms
Learning Outcomes
Define Problem Solving.
Recognize 6 steps in problem solving.
Recognize 7 steps in program development process.
Describe Procedural Programming Language.
Describe Program Development Tools (Techniques).
Summary
 The steps in program development were introduced
and briefly described below:
1. Define the problem
2. Outline the solution
3. Develop the outline into an algorithm
4. Test the algorithm for correctness
5. Code the algorithm into a specific programming
language
6. Run the program on the computer
7. Document and maintain the program
Summary
An algorithm was defined as a set of detailed,
unambiguous and ordered instructions developed to
describe the processes necessary to produce the
desired output from the given input
Pseudocode is an English-like way of representing the
algorithm
Feb 2009 Q1(a) & (b)
Sept 2008 Q1(a)

You might also like