01 Problem Solving and Algorithm Design

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

Teach Computer Science

Problem solving and


algorithm design

teachcomputerscience.com
2

Lesson Objectives

Students will learn:


 How to think like a computer?
 Steps involved in solving a problem
 Software development process
 Components of computational thinking in detail

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

Problem solving: Steps

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

Problem solving: Step 1


Understand the problem
 To understand the problem we need all data to understand the problem.
 It is also important to check whether the problem is solvable.
 If it is solvable, a complex problem can be broken down into simpler
modules, that can be further solved individually.

teachcomputerscience.com
11

Problem solving: Step 2


Construct a plan to solve the problem
 To simply a developer work, he/she may check whether this type of problem
has been solved earlier.
 If yes, then that plan may be adapted to suit our needs. Some problems can
also be solved using mathematics.

teachcomputerscience.com
12

Problem solving: Step 3


Apply the plan
 The plan is carried out and it is important to check at every step that what we
are doing is correct.

teachcomputerscience.com
13

Problem solving: Step 4


Check for errors and look for improvements in the current plan
 The final step of problem-solving it to check whether the solution is correct.
The solution must be efficient and reusable in future.
 In case of errors, it has to be identified, then solved and the complete
solution is checked again.

teachcomputerscience.com
14

Abstraction

Abstraction is similar to generalisation.


In the study of objects or systems,
certain characteristics are removed so
that it is reduced to a simple set of
characteristics.

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

Let’s review some concepts


Computational thinking Problem-solving: Steps Abstraction
Understand the problem.
Computational thinking is a In the study of objects or
Construct a plan to solve the
thought process involved in systems, certain characteristics
problem.
formulating a problem and are removed so that it is reduced
Apply the plan.
expressing its solution in such a to a simple set of characteristics.
Check for errors and look for
way that computers can
improvements in the current
effectively carry it out.
plan.

Decomposition Algorithm Flowchart & Pseudocode

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

1. Deduce an algorithm to check whether a number is divisible by 6 or


not. Write down the logic used, flowchart and pseudocode.

teachcomputerscience.com
3.
End of topic questions

teachcomputerscience.com
28

End of topic questions


1. What are the components of computational thinking?
2. What are the various steps involved in problem-solving?
3. What is abstraction? Explain with an example.
4. How is decomposition helpful in software development?
5. How does pattern recognition save time and effort in software
development?
6. What is an algorithm? In what forms, is it represented?

teachcomputerscience.com

You might also like