0% found this document useful (0 votes)
25 views7 pages

Exercise 2

Uploaded by

Ahmad Tariq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views7 pages

Exercise 2

Uploaded by

Ahmad Tariq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Unit # 2

COMPUTATIONAL THINKING AND ALGORITHMS


EXERCISE (National Book Foundation)
Select the suitable answer for the following Multiple choice Questions (MCQs)
I For a problem, we face in real world situations. In what sequence we follow the steps:
I. Make some solution
II. Understand the real world problem
III. Instruct the computer to behave accordingly
A I, II, III B I, III, II C II, I, III D II, III, I
II Following are types of computing problems
I. Counting problems
II. Search problems
III. Decision problems
A I and II B I and III C II and III D I, II and III
III Computational thinking is
A Programming B Thinking like a C Coding D Logically solving
computer problems
IV To solve Search problems, we need to
A Provide the moves B Provide start state C Provide end state D A, B and C
V The eight queens puzzle is the problem of
A Sorting B Searching C Counting D Both A and B
VI Finding the location of the element with a given value is
A Search B Traversal C Sort D None of above
VII In I-P-O Charts, we have
A Input, Plan, Output B Input, Program, C Input, Process, D Input, Proceed,
Output Output Output
Give short answers to the following short response questions (SRQs)
(i) What is the major difference in solving simple problems and complex problems?
Ans Simple problems typically have straightforward solutions that can be easily understood and
implemented. They often involve clear and well-defined parameters, with known methods or
algorithms available to solve them.
On the other hand, complex problems are characterized by their complex nature, involving
multiple variables, uncertainties, and interdependencies. These problems may not have obvious
solutions, and solving them usually requires a combination of expertise, collaboration, and
innovative problem-solving approaches.
(ii) Why software designers prefer to use IPO charts?
Ans Software designers favor IPO (Input, Process, Output) charts for a couple of key reasons:
 Clarity and Communication: IPO charts break down a software function into its fundamental parts
- what data comes in (Input), what the program does with it (Process), and what the result is
(Output). This clear and concise format is easy for anyone to understand.
 Focus on Functionality: By separating the "what" from the "how," IPO charts help designers focus
on the core functionality of a software component.
While IPO charts are a simple tool, their clarity and focus make them valuable throughout the
software design process.
(iii) Differentiate between Computational thinking and Logical thinking
Ans Computational Thinking Logical Thinking
 A problem-solving methodology inspired  Focuses on reasoning and arriving at clear
by how computers work. conclusions based on facts and evidence.
 Involves breaking down problems into  Involves analyzing information, identifying
smaller, manageable steps. patterns, and drawing inferences.
 Relies on key concepts like decomposition,  Is a broader concept applicable to various
pattern recognition, abstraction, and aspects of life, from everyday decision-
algorithm design. making to complex scientific problems
 Leverages logical thinking to create clear  Engages deductive reasoning (general
and efficient algorithms rules to specific situations) and inductive
 More specific to solving problems that can reasoning (observations to general
be automated or involve computation. conclusions).
(iv) Write Four properties of Computational Thinking
Ans Decomposition: Breaking down the larger problems into smaller manageable ones and working
on them one by one. The smaller problems are referred as sub-problems. This way we simplify the
problem and solve it easily.
Abstraction: By removing the unnecessary details to solution, so you could be able to identify
essential information.
Pattern Recognition: Examine the problem for a pattern or similarities between previously solved
problems.
Algorithm Design: This is actual designing of solution. This involves creating step-by-step plan of
the problem solution.
(v) What are the methods used to design a solution?
Ans Once you have completely understood the problem, the next stage is to design a solution. In
solution design, you define how software will meet the requirements and objectives of a
problem. There are two methods that are used to design a solution i.e. Flowcharts and
Concept Maps
(vi) Which computational thinking technique breaks down the problem into smaller parts?
Ans Decomposition: Breaking down the larger problems into smaller manageable ones and
working on them one by one. The smaller problems are referred as sub-problems. This way
we simplify the problem and solve it easily.
(vii) Identifying three computing problems from other subjects that you are studying in your
class?
Ans1. Mathematics - Solving complex equations: Many areas of mathematics, especially higher-
level ones, involve solving equations that are too complex for humans to solve by hand in a
reasonable timeframe. Here, computers can be incredibly useful.
2. Physics - Simulating complex systems: Physics often deals with systems with many
interacting parts, like galaxies, weather patterns, or the behavior of particles in a collider.
Simulating these systems with traditional pen-and-paper methods becomes impractical.
Computational physics utilizes powerful computers and specialized software to model these
complex systems.
3. Chemistry - Quantum Mechanics: Understanding the behavior of atoms and molecules at
the quantum level is crucial in chemistry. However, the equations governing quantum
mechanics are mathematically complex. Computational chemistry utilizes computer
programs to solve these equations and model the behavior of molecules.
(viii) Why do we need to think computationally?
Ans Computational thinking encourages not only to reflect clearly on a problem they’re solving
but also to define a repeatable solution for it. While solving a problem, we don’t just want to
solve one instance of a problem. We want an auomized system that can solve all instances or
similar problem. Computational thinking can be thought of as an extension of logical
thinking.
(ix) The telephone numbers usually have 9 digits. Out of these 9, the first two digits represent
the area code and are it remained constant within a given area. The last 7 digits represent
the number, and it cannot begin with 0. How many different telephone numbers are
possible with a given area code?
Ans Total Digits: Phone numbers typically have 9 digits (by your information)
 Area Code: The first two digits represent the area code, which we'll consider constant for a
given area.
 Remaining Digits: This leaves 7 digits (9 total2 area code digits) for the phone number itself
 Restrictions: We cannot have leading zeros (0) for the remaining digits since you mentioned
that.
Here's how we can calculate the total possible numbers:
1. Possible Numbers per Digit: Since the leading digit can't be 0, there are 9 possibilities (1-9)
for each of the remaining 7 digits.
2. Total Combinations: We can multiply the possibilities for each digit to find the total
combinations: 9 (digit 1) x 9 (digit 2) x ... x 9 (digit 7) = 97
3. Accounting for Leading Zeros: However, phone numbers don't allow leading zeros. While
there are 10 possibilities (0-9) for the first digit after the area code in theory, we need to
subtract the combinations that start with 0 (which is 10,000 numbers).
Therefore, the total possible phone numbers with a given area code, considering leading
zero restrictions, is:
Total Numbers = 97 - 10,000 = 4,782,969 – 10, 000 = 4,772,969

(x) From city A to city B, there are 4 different roads and from city b to city C there are 2
different roads. Draw a map of given situation and identify how many possible routes are
there that someone can follow to reach from city A to city C passing by city B.
Ans Here's the map and the explanation for the possible routes:
Map:

Possible Routes:
There are 4 x 2 = 8 possible routes
someone can take to reach City C from
City A passing through City B.
 Explanation:
o There are 4 different roads from City A
to City B (represented by the four
lines).
o From each point where City B is
reached there are 2 different roads
leading to City C.
o Since we can choose any of the 4 roads from A to B and then any of the 2 roads from B to C
independently, we multiply the possibilities (4 x 2) to get the total number of routes (8).
Unit # 2
COMPUTATIONAL THINKING AND ALGORITHMS
LONG QUESTIONS
Give Long answers to the following extended response questions (ERQs)
Q1 Identify whether the given problems are Decision Problem, Counting Problem or Search
Problem. Write your answer in front of each problem given below:
(a) Does a given binary string have an even number of zeros?
(b) Flipping a coin result in Head or tails. I flip a coin 20 times, how many different
sequences of heads and tails are possible
(c) Does a certain Java program say “yes” to an empty input?
(d) How many ways can the letters of the word TRIANGLE be arranged?
(e) N-queens problem: where the goal is to place eight queens on a chessboard such that
no queen attacks any other
Ans:
(a) Does a given binary string have an even number of zeros?
Decision Problem: This problem asks for a yes/no answer (decision) based on the properties of
the input (binary string). It doesn't ask for counting the number of zeros or searching for a
specific string with even zeros.
(b) Flipping a coin result in Head or tails. I flip a coin 20 times, how many different sequences of
heads and tails are possible
Counting Problem: This problem asks for the total number of possible outcomes (sequences)
which is the stamp of a counting problem. It's not concerned with just deciding if a specific
sequence is possible (decision problem) or finding a specific sequence with some property
(search problem)
(c) Does a certain Java program say “yes” to an empty input?
Decision Problem: This problem asks for a yes/no answer based on the behavior of the Java
program with a specific input (empty input). It doesn't care about how many times it says "yes"
for different inputs (counting problem) or finding a specific input that makes it say "yes" (search
problem).
(d) How many ways can the letters of the word TRIANGLE be arranged?
Counting Problem: This problem asks for the total number of possible arrangements of the
letters in the word "TRIANGLE". It's concerned with the quantity of arrangements, not deciding
if a specific arrangement exists (decision problem) or finding a specific arrangement with some
property (search problem).
(e) N-queens problem: where the goal is to place eight queens on a chessboard such that no
queen attacks any other
Search Problem: The N-queens problem doesn't ask for a yes/no answer (decision) or the
number of solutions (counting). It asks you to find a valid arrangement (search) of queens on the
chessboard that meets the given criteria (no attacks). In this case, the search space is all possible
placements of queens, and the search aims to find a configuration that satisfies the no-attacking
condition.

Q2 A student has to take one course of physics, one of science and one of mathematics. He may
choose one of 3 physics courses (P1, P2, P3), one of 2 science courses (S1, S2) and one of 2
mathematics courses (M1, M2). In how many ways can this student select the three courses he
has to take?
Ans: The student can choose one physics course in 3 ways (P1, P2, or P3).
The student can choose one science course in 2 ways (S1 or S2).
The student can choose one mathematics course in 2 ways (M1 or M2).
Since these choices are independent of each other, we can multiply the number of ways to make each
choice to find the total number of possible selections.
Total ways = 3 (physics) x 2 (science) x 2 (mathematics) = 12 ways.
Therefore, the student can select the three courses in 12 ways.

Q3 Create an IPO chart which will accept the ages of four boys and calculate their total age and
average age. The program must display both the total age and the average age.
Ans: Here is an IPO chart for calculating the total age and average age of four boys:
Input (I)
 Age of boy 1 (integer)
 Age of boy 2 (integer)
 Age of boy 3 (integer)
 Age of boy 4 (integer)
Process (P)
1. Calculate the total age by adding the ages of all four boys.
2. Calculate the average age by dividing the total age by 4.
Output (O)
 Display the total age of the four boys.
 Display the average age of the four boys.
This IPO chart outlines the steps involved in the program. You can use this chart to write the code in any
programming language.

Q4 Create an IPO chart of a scenario that allows a user to enter in two numbers. The operation to
be performed is either addition, subtraction, multiplication or division and accordingly the
output should be given to the user.
Ans: IPO chart for Two-Number Calculator
Input (I)
 First number (numeric)
 Second number (numeric)
 Operation (+, -, *, /) (character)
Process (P)
1. Validate the input:
o Check if both entered values are numbers.
o Check if the operation entered is one of +, -, *, /.
2. If input is valid, perform the chosen operation on the two numbers.
3. If input is invalid, display an error message.
Output (O)
 Display the result of the operation on the two numbers.
 If the input was invalid, display an error message indicating the issue

Q5 The child wants to plan a birthday party for their friend:


(a) Draw an IPO chart of this chart
(b) Write down properties on computation thinking
Ans: (a) IPO chart for Birthday Party Planning
Input (I)
 Friend's name (string)
 Budget for the party (numeric)
 Guest list (list of names or number of guests) (string or integer)
 Desired party theme (string) (optional)
 Preferred location (string) (optional)
Process (P)
1. Venue Selection:
o If preferred location is provided, check availability and pricing based on guest list size and
budget.
o If no location preference, identify potential venues based on budget, guest list size, and theme
(if provided).
2. Activity Planning:
o Based on age group of guests and theme (if provided), brainstorm age-appropriate activities.
3. Food and Drinks:
o Consider budget and guest preferences when deciding on food and drinks.
4. Invitations:
o Design or purchase invitations with friend's name, party details (date, time, location), and RSVP
information.
5. Decorations:
o Choose decorations that match the party theme (if provided) and fit the venue.
Output (O)
Party Plan Summary:
o List of finalized details including:
 Friend's name and birthday
 Date, time, and location of the party
 Guest list
 Theme (if applicable)
 Activities
 Food and drinks menu
 Decorations plan
 Budget breakdown (optional)

(b) Write down properties on computation thinking


The child's birthday party planning scenario demonstrates several key properties of computational
thinking:
1. Decomposition: The child breaks down the complex task of planning a party into smaller, manageable
steps. This includes venue selection, activity planning, food and drinks, invitations, and decorations.
2. Abstraction: The child might create an abstract representation of the party, like a mind map or
checklist, to keep track of details and ensure all aspects are covered.
3. Pattern Recognition: The child may recognize patterns from past parties or use existing party themes
to guide their planning.
4. Algorithmic Design: The child develops a sequence of steps (algorithm) to follow for planning the
party. This could involve researching available venues, creating a guest list, brainstorming activities, and
comparing options based on budget and preferences.

You might also like