0% found this document useful (0 votes)
171 views

Lecture 11 - Introduction To Computational Thinking and Problem Solving

This document discusses computational thinking and problem solving. It covers the key steps involved in solving problems computationally: analyzing the problem to understand the relevant details, designing a data representation and algorithmic solution, implementing the solution in a programming language, and testing and debugging the program. Two examples are provided to illustrate analyzing problems and capturing the relevant data. The document also discusses representing data in various formats like lists and tables, and describing algorithms at a high level.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views

Lecture 11 - Introduction To Computational Thinking and Problem Solving

This document discusses computational thinking and problem solving. It covers the key steps involved in solving problems computationally: analyzing the problem to understand the relevant details, designing a data representation and algorithmic solution, implementing the solution in a programming language, and testing and debugging the program. Two examples are provided to illustrate analyzing problems and capturing the relevant data. The document also discusses representing data in various formats like lists and tables, and describing algorithms at a high level.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Session 11

Introduction to Computational Thinking and Problem Solving


11.1 Computational Thinking
Computers are used in everyday life for solving problems of various kinds in various fields.
Computer programming is used for implementing the solutions to the problems. Although
programming is an essential activity in computer science, it is not the only activity involved in
solving a problem. Computer science is mainly about computational thinking or computational
problem solving. It is about learning how computers solve a problem or the way of orienting our
thought process in a way in which the computer solves a problem. Computational problem involves
the following processes.
 Analyzing the problem
 Designing the solution to a problem
 Implementing the solution
 Testing the solution
The above processes are the steps involved in solving a problem computationally.

• Clearly understand the problem


Analyze • Know what constitutes a solution

• Determine what type of data is needed


• Determine how data is to be structured
Describe Data
& Algorithms • Find and/or design appropriate algorithms

• Represent data within the programming language


Implement • Implement algorithms in programming language
Programs

• Test the program on a selected set of problem instances


Test and • Correct and understand the causes of any errors found
Debug

Fig. 1 Steps involved in Problem Solving


11.2 Phase I : Problem Analysis
The first phase in solving a problem computationally is problem analysis. Problem analysis
requires two things.
1. A representation that captures all the relevant aspects of the problem
2. An algorithm that solves the problem by using the representation.
Let us consider the Man, Cabbage, Goat, Wolf [MCGW] problem. There is a man who lives on
the east side of a river. He has a goat, a wolf and a cabbage with him. When he is there he will take
care that the goat would not eat the cabbage and the wolf would not eat the goat. He wishes to
bring the cabbage, goat and the wolf to the west side of the river for selling them. But he has a
goat which is large enough to carry himself and either the cabbage or the goat or the wolf. The
man cannot leave the cabbage alone with the goat because the goat will eat the cabbage. He cannot
leave the wolf alone with the goat because the wolf will eat the goat. How can he bring all of them
safely to the west side of the river?
An algorithmic approach for solving this problem is simply trying all possible combinations of the
items that can be taken back and forth across the river and then arriving at a correct solution. Trying
all possible solutions to a problem and finding a solution is known as Brute Force Approach.
Initially we have to find out the relevant aspects of the problem. When a problem is analyzed, there
may be relevant details as well as irrelevant details. For example in the MCGW problem, the
relevant details are
 What is the current location of the items? – On the east side of the river
 What is their destination? – On the west side of the river
 What are the items? – Man, Cabbage, Goat, Wolf
 How many items can travel in the boat? – Only two
But there may be irrelevant details like, the color of the boat, the width of the river, the name of
the man etc. These details are not required for our solution. Therefore, these details need not be
represented in our data representation. The process of hiding the irrelevant data and exposing only
the relevant data is known as data abstraction.
11.3 Capturing Relevant Aspects
Example 1:
Let us consider the MCGW problem. The relevant aspects of this problem are the four items i.e.
Man, Cabbage, Goat and Wolf and their locations at each step. The initial state of all the items is
that they are on the East side of the river. The goal state is that all items should be on the West
side. The other details are not required and they can be ignored. The sequence of steps which
converts the initial state to the goal state is the solution to the problem. The steps required to solve
a problem is called an algorithm. To solve the problem using a computer the algorithm has to be
transformed into a computer language and executed.
Example 2:
Let us see another example for finding relevant data. The problem is to display a calendar month
for any given month and year. The relevant details for this problem are:
 Month and year for which the calendar is to be displayed – This should be provided as
input by the user.
 Number of days in each month of the year
 Names of the days of the week
 Day of the week for the first day of the month.
To solve this problem, we have to determine the day of the week that a given date falls on. This
computation requires an algorithm. In essence, an algorithm is required to solve any problem. You
may use an existing algorithm or you may design your own algorithm for solving problems.
Standard problems can be solved using existing algorithms.
Solutions can be calculated in different ways.
 By direct calculation (Eg. Area of circle, calendar problem)
 By Brute Force Method (Eg. MCGW problem)
For solving complex problems. More efficient algorithms may be required. If there exists more
than one solution to a problem, choose the best solution. If there are multiple solutions to a
problem, a program might find a solution, an approximate solution, a best solution or all the
solutions. For example, MCGW problem has infinite number of solutions. So the best solution is
the one with the shortest number of steps. In travelling salesman problem, there is only one solution
(provided there is only one shortest route). For chess, there may be multiple solutions.
Example for multiple solutions:
Problem : How many times the number 8 goes into the number 100?
• Solution 1
count = 0;
number = 100;
while the number is greater than 8
subtract 8 from the number
add one to the count
end // start the while again
• Solution 2
count = 100 / 8
11.4 Phase II. Problem Design
Problem design involves two major tasks.
 Data Representation
 Algorithm Description
Data representation: An appropriate representation of data is a relevant aspect of computer
science. Single data can be represented as number, character or Boolean. Multiple data can be
represented using lists, tables or a combination of data types (using structure and class).
Algorithm Description: An algorithm is a set of steps to solve a problem.
Data Representation - Examples
Example 1:
Now, let us represent the relevant details in the MCGW problem. At each step, the location of the
items can be represented as the state of the problem.
Initial State: [M, C, G, W] [E, E, E, E]
Here, we use two lists for representing the initial state of the problem. The first list is the list of the
items. The second list is the respective location of each item. That is, Man is in the East side of the
river, Cabbage is in the East side of the river, Goat is in the East side of the river and Wolf is in
the East side of the river. Now, each step of the solution can also be represented with the same
representation.
Step 1: The man carries the goat to the West side of the river. So, this state would be
[M, C, G, W] [W, E, W, E]
Here, W indicates the West side of the river.
Step 2: The man leaves the goat on the West side and goes to the East side of the river.
[M, C, G, W] [E, E, W, E]
Step 3: The man takes the cabbage with him and goes to the West side of the river.
[M, C, G, W][W, W, W, E]
Step 4: The man leaves cabbage on the West side of the river and takes the goat to the East side of
the river.
[M, C, G, W][E, W, E, E]
Step 5: The man leaves the goat on the East side and takes the wolf to the West.
[M, C, G, W][W, W, E, W]
Step 6: Man leaves wolf on the west and goes to East
[M, C, G, W][E, W, E, W]
Step 7: Man takes goat to the West side
[M, C, G, W][W, W, W, W]
Step 7 is the goal state.
Example 2:
Calendar Problem
The relevant details for the calendar problem are
 Month and year for which the calendar is to be displayed
 The number of days in each month of the year
 The names of the days of the week
 Day of the week of the first day of the month
The data can be represented in lists as follows:
[month, year]
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
[‘Sun’, ‘Mon’, ‘Tue’, ‘Wed’, ‘Thu’, ‘Fri’, ‘Sat’]
The day of the week of the first day of the month can be represented using a string.
Example 3:
The Travelling Salesman Problem
The travelling salesman problem is a standard problem in computer science. It solves the problem
of visiting all cities allotted to him in an optimized way. The salesman has to visit all the cities
exactly in the shortest possible route and return to the starting point. The relevant details for this
problem are: the cities to be visited and the distance between a pair of cities. The data in the
travelling salesman problem can be represented as a table or as a list of lists.
Table Representation

List of Lists
[ [‘Atlanta’, [‘Boston’, 1110], [‘Chicago’, 718], [‘Los Angeles’, 2175], [‘New York’, 888],
[‘San Francisco’, 2473] ],
[‘Boston’, [‘Chicago’, 992], [‘Los Angeles’, 2991], [‘New York’, 215], [‘San Francisco’, 3106] ],
[‘Chicago’, [‘Los Angeles’, 2015], [‘New York’, 791], [‘San Francisco’, 2131] ],
[‘Los Angeles’, [‘New York’, 2790], [‘San Francisco’, 381] ],
[‘New York’, [‘San Francisco’, 2901] ] ]
Algorithm Description: The second major task in problem design is algorithm description. You
can choose either an existing algorithm or you may design a new algorithm for solving a problem.
For example, for the calendar problem, day of week algorithm already exists. For the travelling
salesman problem, many algorithms are available. Algorithms that work well in general, but are
not guaranteed to give the correct result for each specific problem are called heuristic algorithms.
11.5 Phase III : Program Implementation
The third phase in problem solving is program implementation. Once a problem is analyzed, the
data is represented and a suitable algorithm is identified, the next task is to implement the
algorithm. Choose a programming language and transform the algorithm into source code. This is
the task that is done by a developer or a programmer.
11.6 Phase IV: Program Testing
Once a program is developed, there may be errors. Programming errors are pervasive, persistent
and inevitable. Therefore, the program that is developed should be tested to ensure that it is free
from errors or program bugs. The process of testing a program or software is called as software
testing. Software testing is an essential part of software development. The program can be tested
with sample data sets.
11.7 Computational Thinking
Computational thinking is the thought process involved in formulating a problem and expressing
its solutions in such a way that a computer can effectively carry out. Computational thinking has
four elements.
• Decomposition: Breaking down data, processes, or problems into smaller, manageable
parts
• Pattern Recognition: Observing patterns, trends, and regularities in data
• Abstraction: Identifying the general principles that generate these patterns
• Algorithm Design: Developing the step by step instructions for solving this and similar
problems.
11.8 Creative Problem Solving
Creative problem solving is – looking at the same thing as everyone else and thinking something
different. The creative person uses information to form new ideas. The real key to creative problem
solving is what you do with the knowledge. Creative problem solving requires an attitude that
allows you to search for new ideas and use your knowledge and experience. Change perspective
and use knowledge to make the ordinary extraordinary and the usual commonplace. Creative
problem solving may face barriers like,
 Time
 Why change?
 Usually don’t need to be creative
 Habit
 Routine
 Haven’t been taught to be creative
Mental blocks are reasons or attitudes why we don’t think something different.
Mental blocks
1. The _______ answer.
2. That’s not _________.
3. __________ the rules.
4. Be ______________.
5. ________ is frivolous.
6. That’s not my _____.
7. ________ ambiguity.
8. Don’t be _________.
9. __________is wrong.
10. I’m not __________.
Mental Block 1
1. The right answer.
Mental Block 2
1. The right answer
2. That’s not logical
Mental Block 3
1. The right answer.
2. That’s not logical
3. Follow the rules
Why rules should be challenged?
1. We make rules based on reasons that make a lot of sense.
2. We follow these rules.
3. Time passes and things change.
4. The original reasons for the generation of these rules may no longer exist, but because the
rules are still in place, we continue to follow them.
Mental Block 4
1. The right answer.
2. That’s not logical.
3. Follow the rules
4. Be practical
Mental Block 5
1. The right answer
2. That’s not logical.
3. Follow the rules
4. Be practical
5. Play is frivolous.
Mental Block 6
6. That’s not my area
Mental Block 7
6. That’s not my area.
7. Avoid ambiguity
Mental Block 8
6. That’s not my area.
7. Avoid ambiguity
8. Don’t be foolish
Mental Block 9
6. That’s not my area.
7. Avoid ambiguity
8. Don’t be foolish
9. To err is wrong.
Mental Block 10
6. That’s not my area
7. Avoid ambiguity
8. Don’t be foolish
9. To err is wrong
10. I’m not creative
11.9 Creative Problem Solving Process
Step 1: State what appears to be a problem.
The real problem may not surface until facts have been gathered and analyzed. Therefore, start
with what you assume to be the problem that can later be confirmed or corrected.
Step 2: Gather facts, feelings and opinions.
Step 3: Restate the problem
Step 4: Identify alternative solutions.
Step 5: Evaluate alternatives
Step 6: Implement the decision
Step 7: Evaluate the results

11.10 Tools and Techniques

1. Brainstorming:
The process of generating creative ideas and solutions through intensive and freewheeling
group discussion. Brainstorming is a technique to generate a large number of ideas in a short period
of time.

Rules for more Brainstorming


Brainstorming is effective when there are more ideas. No idea is a bad idea. You can build
on one another’s idea. Display all the ideas.

Brainstorming Guidelines
Find out ways to motivate the members who participate in brainstorming. Clarify the
understanding. Once all the ideas have been generated, review the ideas that have been offered.
Combine items that are similar and eliminate duplicates.

2. Multivoting
Multivoting is a way to vote to select the most important or popular items (alternatives)
from a list. It is used to help a group of people to make a decision with which they are comfortable.

Steps for Multivoting


1. Generate a list of items and number each item.
2. If two or more items seem similar, they may be combined.
3. If necessary, renumber the items.
4. Write down the numbers of the items you feel are the major cause of the problem.
5. Share your votes by a show of hands.
6. Eliminate those items with the fewest votes.
7. Repeat steps 3 (renumber) through 6 on the list of remaining items. Continue this
process until only a few items remain. If a clear favorite does not emerge, the group
may discuss the items listed and make a choice.
3. Mind Mapping
Mind mapping is the visual picture of a group of ideas or concepts or issues. The
purpose of mind mapping is to unblock our thinking, see an entire idea or several ideas on
a single sheet of paper, see how ideas relate to one another, look at things in a different
way and look at an idea in depth.

Mind mapping exercise

 Over-sized blank sheet of paper.


 Select word, phrase or problem statement to serve as a focus for discussion.
 Print it in the middle of the paper. Enclose it in a box or oval.
 Let a word pop out of your mind. Print it anywhere on the paper.
 Underline it and connect the line with the problem statement (or key phrase or
word) you are working.
 Record the next idea and connect it to original focus point or the prior thought.
 Continue printing and connecting words

Example

Hints

 Keep your printing large and easy to read.


 Feel free to use symbols and or pictures.
 Have some fun using different colors.
Completed Map

 Draw over clusters of similar thoughts that are associated with the main focus point.
Have fun using a different color highlighter with each cluster of words.
 How do the variety of ideas relate to one another?
 Do you notice any common causes of the problem? What are the most important
causes?
 You are now ready to brainstorm solutions!

11.8 Activities
1. Write an algorithm to find the area of a circle.
2. Write an algorithm to find the greatest number among three numbers
3. Write an algorithm to find the factorial of a number.
4. Represent the following data in suitable formats
a. Seasons of a year
b. Colors of a rainbow
c. A unit matrix
d. Details of a book
5. Identify the modules in Library Management System
6. Group your class students based on some similarity
7. Identify the rules to join B.Tech. course in Karunya University.
8. What is the four-digit number in which the first digit is one-third the second, the third is
the sum of the first and second, and the last is three times the second?
9. The following verse spells out a word, letter by letter. "My first" refers to the word's first
letter, and so on. What's the word that this verse describes?

My first is in fish but not in snail


My second in rabbit but not in tail
My third in up but not down
My fourth in ice cream not in coffee
My fifth in tree you plainly see
My whole a food for you and me
10. How is it possible to cut a traditional circular cake into 8 equal size pieces, with only 3
cuts?

You might also like