Ms. Amna Altaf Unit 2: Computational Thinking & Algorithms Computer Sc.
Chapter # 2:
Computational thinking & Algorithms
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.
a. Does a given binary string have an even number of zeros? Counting+ Decision
b. Flipping a coin results ion head or tail. I flip a coin 20 times, how many different sequences of heads and tails are
possible? Counting Problem
c. Does a certain Java program say “yes” to an empty input? Decision Problem
d. How many ways can the letters of the word “TRIANGLE” be arranged? Counting Problem
e. N-Queens problem: Where the goal is to place eight queens on a chess board such that no queens attacks any
other. Counting Problem
Q2. A student can take one course of physics one of science and one of mathematics. He/She may choose one of three
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:To determine how many ways the student can select one course from each of the three subjects, you can use the
principle of multiplication (also known as the counting principle).
Here's how it works for this problem:
• The student has 3 choices for the Physics course (P1, P2, P3).
• The student has 2 choices for the Science course (S1, S2).
• The student has 2 choices for the Mathematics course (M1, M2).
To find the total number of ways the student can select one course from each subject, you multiply the number of
choices for each subject:
Total number of ways=(Number of Physics choices)×(Number of Science choices)×(Number of Mathematics choices)
Substitute the numbers:
Total number of ways=3×2×2
Calculate:
Total number of ways=12
So, the student can select the three courses in 12 different ways.
Q2. Create an IPO chart which will accept the ages of four boys and their total age and average age. The program
must display both the total age & average age.
Chapter # 2:
Computational thinking & Algorithms
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.
a. Does a given binary string have an even number of zeros? Counting+ Decision
b. Flipping a coin results ion head or tail. I flip a coin 20 times, how many different sequences of heads and tails are
possible? Counting Problem
c. Does a certain Java program say “yes” to an empty input? Decision Problem
d. How many ways can the letters of the word “TRIANGLE” be arranged? Counting Problem
e. N-Queens problem: Where the goal is to place eight queens on a chess board such that no queens attacks any
other. Counting Problem
Q2. A student can take one course of physics one of science and one of mathematics. He/She may choose one of three
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:To determine how many ways the student can select one course from each of the three subjects, you can use the
principle of multiplication (also known as the counting principle).
Here's how it works for this problem:
• The student has 3 choices for the Physics course (P1, P2, P3).
• The student has 2 choices for the Science course (S1, S2).
• The student has 2 choices for the Mathematics course (M1, M2).
To find the total number of ways the student can select one course from each subject, you multiply the number of
choices for each subject:
Total number of ways=(Number of Physics choices)×(Number of Science choices)×(Number of Mathematics choices)
Substitute the numbers:
Total number of ways=3×2×2
Calculate:
Total number of ways=12
So, the student can select the three courses in 12 different ways.
Q2. Create an IPO chart which will accept the ages of four boys and their total age and average age. The program
must display both the total age & average age.