Notes

Unit 2: Computational Thinking & Algorithms

Unit 2: Computational Thinking & Algorithms

Write answers of the following short response questions.

1. Consider 3 boys and 3 girls want to team up as pair for the 14th August related student performance at the school. Find the total no. of ways these pairs could be formed using Counting Principle Problems.

Answer:

Each boy can be paired with any of the 3 girls.
So, using the Multiplication Principle:
→ 3 boys × 3 girls = 9 possible pairings

Total number of ways = 9

2. Suppose you have selected black pant to attend school function and have three options of shirt to choose. Find the total no. of ways you can dress up using Counting Principle Problems.

Answer:

You are choosing 1 pant (fixed) and 1 out of 3 shirts.

→ 1 × 3 = 3 ways to dress up

Total number of ways = 3

3. You are sitting at a study table doing homework. The penholder on the table contains 2 blue pens, 1 black pen, and 2 lead pencils. How many options do you have for writing?

Answer:

Use Addition Principle because you can use only one item at a time.
→ 2 (blue pens) + 1 (black pen) + 2 (pencils) = 5 options

Total number of writing options = 5

4. For a race on sports day activities, a group of 20 students are given a race lane at random. There are six students selected for the first race. How many different orders of the six lanes for students may be chosen?

Answer:

This is a permutation problem where order matters.

→ Use the formula:

                P(n,r) = (n!)/(n-r)!

Where:
n = 20 students, r = 6 selected

P(20,6)= ​20!/(20-6)! = 20×19×18×17×16×15=27,907,200

Total number of different orders = 27,907,200

Write answers of the following extended response questions.

1. Ejaz, Javeria, Liaqat, and Zainab are standing in a line. Here are the clues to determine their positions:

a) Javeria is standing directly behind Ejaz.

b) Zainab is not next to Liaqat.

c) Liagat is not at the end of the line.

d) Zainab is standing in the first position.

In which order are they standing?

Answer:

  • From clue (d): Zainab is in position 1.
  • Clue (a): Javeria is behind Ejaz, so Ejaz must be in front of Javeria.
  • Clue (b): Zainab is not next to Liaqat, so Liaqat cannot be in position 2
  • Clue (c): Liaqat is not at the end. So he cannot be in position 4

Based on these, one valid order is:
Zainab, Ejaz, Liaqat, Javeria

2. Provide students with a detailed map of their school. Ask them to create an abstract version, highlighting only the main buildings and pathways.

Answer:

3. Give students a problem that can be solved with a simple program. Encourage them to write functions to handle different parts of the problem, abstracting complex operations into manageable pieces.

Answer:

Example problem: Calculate the area of different shapes (circle, rectangle, triangle)

Break it into functions:

  • get_input() – gathers shape and dimensions
  • calculate_area(shape, parameters) – uses conditional logic to apply the correct formula
  • display_result(area) – shows the result to the user

This demonstrates modular design and abstraction:

  • Each function performs a clear task
  • Complexity is hidden in reusable modules
  • Easier to debug and scale the program later

4. Given the following web form inputs, identify any syntax errors and correct them

Form Inputs:

> Name: Amjad Ali          > Email: amjadali@gmail             > Date: 01/01/2024

Answer:

Syntax Error Identified:

  • Email is incomplete — missing .com at the end

Corrected Inputs:

  • Name: Amjad Ali
  • Email: amjadali@gmail.com
  • Date: 01/01/2024

5. You have developed a web application that takes the budget head and provides total. Analyze the following budget and identify any logical errors in the total amount.

Budget Example:

Rent: $1000

Utilities: $150

Groceries: $200

Total: $1000 + $150 + $200 = $1500

Answer:

Logical Error Identified:

  • Total is incorrect
  • Correct sum: $1000 + $150 + $200 = $1350

The application logic is flawed — either a calculation error or incorrect value assignment.

Select the best answer for the following MCQs.

1. Identify the activity that is based on personal preferences rather than algorithmic logic.

a) Sorting numbers in a list.

b) Deciding what to eat for dinner.

c) Determining if a number is a prime number.

d) Calculating the square root of a number.

2. Counting Principle Problems could easily be understood by the use of

a) Graph representation

b) Tree representation

c) Clock representation

d) Map representation

3. In how many ways can you choose 2 out of 5 different books to take on a trip? (Order does not matter)  

a) 10

b) 20

c) 15

d) 5

4. A committee of 3 members is to be selected from a group of 8 people. How many different committees can be formed?

a) 56

b) 84

c) 28

d) 120

5. You have 5 different shirts and 4 different pants. How many different outfits can you make by choosing one shirt and one pair of pants?

a) 9

b) 20

c) 15

d) 10

6. In how many ways can you select 3 different fruits from a basket of 7 different fruits? (Order does not matter)

a) 35

b) 21

c) 56

d) 84

7. The Pigeonhole Principle states that if more items are placed into containers than the number of containers, then:

a) Some containers must be empty

b) At least one container must hold more than one item

c) All containers will be full

d) Each item will be placed in a different container

8. In a set of 50 students, 30 have completed a math project, 25 have completed a science project, and 15 have completed both. How many students have completed at least one project?

a) 35

b) 40

c) 45

d) 50

9. Which property of an algorithm ensures that it produces at least one output after the calculations?

a) Input  

b) Output

c) Definiteness

d) Finiteness

10. Which property ensures that an algorithm will eventually end after a finite number of steps?

a) Input

b) Finiteness

c) Effectiveness

d) Generality

Unit 2: Computational Thinking & Algorithms

Muhammad Hussain

Recent Posts

Unit 8: Entrepreneurship in Digital Age

Unit 8: Entrepreneurship in Digital Age Write answers of the following short response questions. Q.1.…

1 month ago

Unit 7: Digital Literacy

Unit 7: Digital Literacy Write answers of the following short response questions. Q.1. Differentiate between…

1 month ago

Unit 6: Impacts of Computing

Unit 6: Impacts of Computing Write answers to the following short response questions. Q1. List…

1 month ago

Unit 5: Applications of Computer Science

Unit 5: Applications of Computer Science Write answers of the following short response questions. Q1.…

2 months ago

Unit 4: Data and Analysis

10th Computer Science Unit 4 Data and Analysis Write answers of the following short response…

3 months ago

Unit 3: Programming Fundamentals

10th Computer Unit 3: Programming Fundamentals Unit 3: Programming Fundamentals Write answers of the following…

3 months ago