01 Problem Solving and Algorithm Design
01 Problem Solving and Algorithm Design
01 Problem Solving and Algorithm Design
teachcomputerscience.com
2
Lesson Objectives
teachcomputerscience.com
1.
Content
teachcomputerscience.com
4
Introduction
To program a computer, certain sets of logical instructions need to be
provided.
Sets of logical instructions for a computer can be designed only when the
programmer thinks in the same way that a computer processes the
instructions.
Computational thinking is a thought process involved in formulating a
problem and expressing its solution in such a way that computers can
effectively carry it out.
teachcomputerscience.com
6
Software development
Developing a software is a complex process as it involves:
• Innovative thinking process. It is quite difficult to create a new software which
has not been done ever before.
• Complex testing procedures to check the functionality of software. Software do
not obey physical laws and to determine its properties, its developer must test
it under different conditions.
Software engineering describes structured methodology and techniques to
develop a new software. Testing software is now made a disciplined process too.
teachcomputerscience.com
7
Computational thinking
Computational thinking is beneficial in many ways and has changed
the way computer scientists look at the software developed process to
a more structured process.
Using this, a complex problem is understood by breaking into various
modules that be further solved individually. The solution obtained may
involve a computer, a human or both.
teachcomputerscience.com
8
Computational thinking
The components of computational thinking are:
Abstraction
Decomposition
Algorithm design
teachcomputerscience.com
9
4. Check for
2.
errors and look
Construct a
1. Understand the 3. Apply for
plan to
problem the plan improvements
solve the
in the current
problem
plan
teachcomputerscience.com
10
teachcomputerscience.com
11
teachcomputerscience.com
12
teachcomputerscience.com
13
teachcomputerscience.com
14
Abstraction
teachcomputerscience.com
15
Abstraction
For example: It is enough for a
driver to understand the use of the
accelerator and breaks, etc. He need
not know the inner mechanism
behind the accelerator and brakes.
This is hiding the details that are not
essential. Data abstraction
therefore reduces the complexity
and time.
teachcomputerscience.com
16
Abstraction: Examples
▪ Using symbols to represent physical quantities during a physics
experiment is an example for abstraction.
▪ Similarly, variables are used in programming. You must be familiar with
functions in maths.
▪ Similarly, functions in programming helps us to simply a solution.
▪ In networking, layers are separated according to functionality.
▪ This separation allows network professionals to work on each layer
separately.
teachcomputerscience.com
17
Decomposition
A large problem is broken down into
smaller chunks that can then be solved
using computing.
teachcomputerscience.com
18
Decomposition: Example
▪ Let us take an example of designing an online airline ticket booking
system.
▪ Many programmers work together. Each programmer is assigned a
particular job.
▪ One creates the database related to the airline, like time schedule,
number of seats and cost of the tickets.
▪ One programmer designs the interactive page that takes input from the
user.
▪ One programmer designs the online banking interface.
teachcomputerscience.com
19
Pattern recognition
Patterns in a problem simplify developers work.
Similar problems can be solved by the same solutions.
Reusing these solutions saves effort and time.
For example: For creating an online application to read magazines, the
program for creating user accounts, subscriptions and banking details
are be recreated using similar programs that are already in use by
other applications.
teachcomputerscience.com
20
Algorithm
A problem is broken into a series of logical steps called an
algorithm.
For example: to design a program to multiply two numbers,
logical steps have to be provided. Repeated addition is the
widely used logic behind multiplication.
teachcomputerscience.com
21
Algorithm design
Flowchart Pseudocode
A flowchart depicts the steps and order Pseudocode is a method of representing
to be followed to perform a task. an algorithm using simple words and
mathematical operators.
teachcomputerscience.com
22
Flowchart: Example
This flowchart checks whether a
number is odd or even.
A decision box is used to check
whether the remainder of a
number divided by 2 is 0 or not.
This decision box has one entry
point and two exit points.
Sometimes a decision box may
have more than two exit points.
teachcomputerscience.com
23
Pseudo code:
Example
INPUT Num
IF Num MOD 2 = 0
THEN PRINT Num, “is an even number”
ELSE PRINT Num, “is an odd number”
ENDIF
teachcomputerscience.com
24
A large problem is broken A problem is broken into a series A flowchart depicts the steps and
down into smaller chunks of logical steps called an order to be followed to perform
that can then be solved using algorithm. a task.
computing. Pseudocode is a method of
representing an algorithm using
simple words and mathematical
operators.
teachcomputerscience.com
2.
Activity
teachcomputerscience.com
26
Activity-1
Duration: 15 minutes
teachcomputerscience.com
3.
End of topic questions
teachcomputerscience.com
28
teachcomputerscience.com