You are on page 1of 21

e-DAC Centre for Development of Advanced Computing

Session 1

Problem Solving &


Computational Thinking
e-DAC Centre for Development of Advanced Computing

Objective
• To understand the essence of problem
solving
• To understand the notion of an
Algorithm

1.2
e-DAC Centre for Development of Advanced Computing

Essential Requirements to
solve a Problem
• What does it require from you ?
– In-depth Understanding
– Thinking
– Planning
– Logical Precision
– Persistence
– Attention to detail

1.3
e-DAC Centre for Development of Advanced Computing

Essential Requirements to
solve a Problem
• That said, it can be
– Challenging
– Exciting
– Satisfying

1.4
e-DAC Centre for Development of Advanced Computing

Problem-Solving Aspects
• Problem Definition
– Understand the problem
– What must be done (Forget about how to do it,
initially)
– Try to extract a set of precisely defined tasks
– Example Sq. root
• Getting Started
– “The sooner you start coding your program, the
longer it is going to take” is usually true
– Do not be too concerned with the details of
implementation, initially
© 2021, C-DAC, Bangalore 1.5
e-DAC Centre for Development of Advanced Computing

Problem-Solving Aspects
• Use of Specific examples
– Pick a specific example and try to work out the
mechanism that will allow us to solve it
– It is easier to start solving this way
– It helps to focus on details that are not so apparent
when the problem is considered abstractly
– However, the solution to the specific problem may
not be the solution to the general problem
– Therefore, this method should not be abused

1.6
e-DAC Centre for Development of Advanced Computing

Problem-Solving Aspects
• Similarities among problems
– Try to bring in your experience, by looking
for similarities that you are aware of
– However, experience is not always useful
– Develop the skill to view the problem from
a variety of angles

1.7
e-DAC Centre for Development of Advanced Computing

Problem-Solving Aspects
• Working backwards from the solution
– Use this strategy, when you don’t know where to
start
– Take / Guess a solution to the problem and work
backward (Example Square root)
• General Points
– Write down the various steps and explorations
made
– Once a problem is solved, consciously reflect back
on the path followed for discovering the solution

1.8
e-DAC Centre for Development of Advanced Computing

General Problem Solving


Strategies
• Divide-and-Conquer
– Divide the original problem into two or more sub-
problems
– Used in sorting, selection and searching
algorithms
• Dynamic Programming
– Good solution to a large problem can be
sometimes built up from good solutions to smaller
problems
– Greedy search, backtracking, and branch-and-
bound evaluations are all variations of this
1.9
e-DAC Centre for Development of Advanced Computing

Algorithms
• Primary goal of computer problem-
solving
• A finite set of well-defined rules
yielding a solution to the problem in
finite number of steps
• A step-by-step procedure used for
solving a problem

1.10
e-DAC Centre for Development of Advanced Computing

Top-down Design
• Humans can focus only on a very
limited span of logic, at a time
• Top-down Design or Stepwise
refinement accommodates this limitation
• Solution is started with a vague outline
and evolved to a precisely defined
algorithm in a stepwise fashion

1.11
e-DAC Centre for Development of Advanced Computing

Data Structures
• All programs operate on data
• Data structures is concerned with the
way data is organized, stored and
retrieved
• They do have a significant influence
on the algorithm and therefore are
usually linked to one another

1.12
e-DAC Centre for Development of Advanced Computing

Choosing a data structure


• How can intermediate results be arranged to
allow fast access
• Can the data structure be easily searched
• Can the data structure be easily updated
• Is it possible to retrieve the earlier state in
computation
• Does the data structure involve excessive use
of storage
• Can the problem be formulated in terms of one
of the common data structures (e.g., array,
queue, stack)
1.13
e-DAC Centre for Development of Advanced Computing

Construction of Loops
• Iterative constructs, or loops or
structures that are conditionally
executed are the essence of
implementations

1.14
e-DAC Centre for Development of Advanced Computing

Implementation of Algorithms
• Modularization
– Identifying those sections of the steps that
• Related and perform a single function
• Needs to be repeated
– To provide
• Clarity
• Ease of understanding
• Reusability etc…

1.15
e-DAC Centre for Development of Advanced Computing

Implementation of Algorithms
• Choice of Variable names
– Have meaningful names
– Each variable should have only one role in a given
program
• Documentation of Programs
– Give brief and accurate comments for all major
sections of the code
• Debugging Programs
• Testing
1.16
e-DAC Centre for Development of Advanced Computing

Core Strategies and Sample


Problems
• Fundamentals
– Exchanging the values of two variables
• Iterative Techniques
– Summation of a set of numbers
– Factorial Computation
– Fibonacci Sequence
– Base(Octal, Hexadecimal) Conversion

1.17
e-DAC Centre for Development of Advanced Computing

Core Strategies and Sample


Problems
• Factoring Methods
– Greatest Common Divisor of two integers
– Computing the Prime factors of an integer
• Array Techniques
– Array Order Reversal
– Finding the maximum number in a set
• Merging Sorting and Searching

1.18
e-DAC Centre for Development of Advanced Computing

Core Strategies
• Text Processing and Pattern Matching
• Dynamic Data Structures
• Recursive Algorithms

1.19
e-DAC Centre for Development of Advanced Computing

Summary
• So far, We have learnt about the
– Essence of Problem-Solving
– General Problem-Solving Strategies
– Algorithms and Data Structures
– Core Strategies and examples

1.20
e-DAC Centre for Development of Advanced Computing

References
• “How to solve it by computer”,
R.G.Dromey, PHI, 1990

1.21

You might also like