A-Level Revision Notes - 51 Computational Met

You might also like

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

Teach Computer Science

A-Level

Computational
Methods

teachcomputerscience.com
1.

Revision notes

teachcomputerscience.com
Problem-solving
A problem is said to be computable if there is an algorithm that can
solve every instance of it in a finite number of steps. Understanding
the problem is the first step to problem-solving. To understand the
problem, we need all the 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.
To simplify a developer’s 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. There are several methods to solve the problem.
Some of them are:
▪ Exhaustive search: In this method, all possible solutions are tried
until the correct one is found. Although this method is possible due
to the processing capacity of modern computers, the number of
possible solutions also increases drastically with the size of the
problem.
▪ Theoretical approach: Using a mathematical approach to solve a
problem. This is certainly faster than the exhaustive search
approach. Knowledge about the theory is essential to use this
method.
▪ Simulation: Simulation is the technique to create a computer
model based on the real system in order to understand its
behaviour. For example, the simulation of a car model to
understand its maximum speed, efficiency, and fuel consumption.
The strategies that may be used to solve a problem are:
▪ Top-down approach: In the top-down approach, a larger problem
is broken into several tasks, that are further broken to several
subtasks, until each subtask is manageable.
▪ Divide-and-conquer: The size of the problem is halved at every
iteration. For example, in binary search, at each iteration, the
sorted list is divided into halves, and the element is searched. The
half which does not contain the element is discarded. This process
continues until the element is found.

teachcomputerscience.com
▪ Problem abstraction: Certain details of a problem are removed
until the problem is reduced to such a level that it has already been
solved. An example using problem abstraction is given.
Consider a 3×3 chessboard with two black knights and two white
knights as given. What is the minimum number of moves by which the
places of knights can be swapped?

A knight moves two squares vertically and one square horizontally or


two squares horizontally and one square vertically. The movements
are in the shape of L. All the possible movements are given.
Numbering the blocks and unfolding the graph.

The answer to this problem is to move the knights in a clockwise or


counter-clockwise direction until the knights reach their diagonally
opposite position.
Using this method called graph-unfolding, the problem is reduced to a
simpler form.

teachcomputerscience.com
The abstracted model can be automated to be more realistic. For
example, you may create a model to predict the climatic conditions of
the world. The assumptions may include wind currents, water
currents, temperature and past climatic conditions. The model can
then be used to predict the future climatic conditions, may be after 50
years.

Halting problem
Unsolvable problems are problems that cannot be solved, even in
future with improved computing power and regardless of the amount
of time given to solve it. Given a program P and input I, we may raise a
question that: does P terminate or halt on input I? This question and
other questions related to this are known as the halting problem.

Yes
input I Does program P halt
on input I?
No
H
The halting problem is an example of an unsolvable problem. Alan
Turing proved that a machine H to solve the halting problem of all
possible programs and their inputs does not exist.

teachcomputerscience.com
Problem solving techniques
Some techniques that can be applied while solving problem are:
• Visualisation: The way the problem or data is represented must be
easier and simpler to understand. For example, expressing a tree
data structure in a flowchart form is more understandable when
compared to expressing it in a tabular form with arrays and
pointers.
• Backtracking: Sometimes, a series of decisions are taken to solve a
problem. In case there is not much information about each choice
or there may be more than one correct sequence, backtracking is
done to find out a solution. Backtracking is the method used to
consider different sequences until the most suitable solution is
found. We used backtracking in depth-first traversals of graphs.
• Data mining: Data mining is the automated or convenient
extraction of patterns in large data sets that are further analysed
using analytics tools to predict future trends. For example, by
looking at the sales of products, analysing customer feedback and
deciding about the price point a business can be improved.
• Heuristics: A problem is said to be intractable when there exists no
efficient algorithm to solve it. Usually, these problems are solved
by brute-force analysis. The time taken by a computer to solve
such problems will be quite long. For example, partition n integers
into two subsets such that the sum of the subsets are equal. As n
increases, the number of computations increases exponentially
because you divide the set into possible subsets and add.
Heuristics is a method to approach an intractable problem. This
method may not lead to a perfect answer, but an adequate
solution is obtained. Within a stipulated time frame, an acceptable
solution is obtained.

teachcomputerscience.com
• Pipelining: Microprocessors use pipelining to implement the fetch-
decode-execute cycle. In pipelining, the instruction required next is
placed in a queue so that it can be fetched next. The processor
need not wait for the current execution process to complete to
fetch the next instruction.
Similarly, pipelining can be implemented for problem-solving. A
task is divided into several subtasks and the processing of each of
the task is made to overlap.
• Performance modelling: The performance of a system can be
found out by testing in a real setup. Alternatively, a model of the
system could be simulated and the performance under different
conditions may be found out. For example, modelling a network
and evaluating its performance with maximum number of users.
Evaluating performance helps us to build a system according to
our requirements.
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
2.

Activity

teachcomputerscience.com
Activity-1
Duration: 15 minutes

1. Consider a 4×3 chessboard with three black knights and three


white knights as given. What is the minimum number of moves by
which the places of knights can be swapped?

teachcomputerscience.com
3.
End of topic
questions

teachcomputerscience.com
End of topic questions
What are the different methods to solve a problem? Explain in brief.
1. Exhaustive search= In this method, all possible solutions are tried until the
correct one is found
2. Theoretical approach= Using a mathematical approach to solve a problem.
Simulation is the technique to create a computer model based on the real system
in order to understand its behaviour.
3. List the different strategies used to solve a problem. Explain in brief.
▪ Top-down approach= In the top-down approach, a larger problem is broken into
several tasks, that are further broken to several subtasks, until each subtask is
manageable.
▪ Divide-and-conquer= The size of the problem is halved at every iteration
Problem abstraction= Certain details of a problem are removed until the problem is
reduced to such a level that it has already been solved
1. What is data mining? State its applications.
Data mining is the automated or convenient extraction of patterns in large data sets
that are further analysed using analytics tools to predict future trends. Its used in things
such as marketing and customer relationship management
2. Explain the backtracking algorithm briefly with an example of its application.
a series of decisions are taken to solve a problem. Backtracking is the method used to
consider different sequences until the most suitable solution is found. It is used in
depth-first traversals of graphs.
3. When is heuristics applied to a problem?
Within a stipulated time frame.

teachcomputerscience.com

You might also like