Computer Notes 7th Class Unit No.3

UNIT NO.3

Computational Thinking

(Solved Exercise)

Tick (✓) the correct option.
Answers are given at the end of book.

Briefly answer the following question:
1. Define computational thinking in your words.
Answer:
Computational Thinking (CT) involves a set of problem-solving skills and techniques we use to solve a problem.

2. Enlist techniques of computational thinking.
Answer:
i. Decomposition
ii. Pattern Recognition
iii. Generalization and Abstraction
iv. Algorithm Design

3. What do you mean by Decomposition?
Answer:
Breaking a task or problem into steps or parts is known as Decomposition

4. Elaborate generalization and abstraction.
Answer:
Abstraction
Abstraction helps us learn to identify the details that are relevant to solving the problem and ignoring the details that are not relevant to the problem we are solving.
Generalization
Discover the principles that cause the patterns in a problem is called Generalization. Generalization allows us to create generic idea of what the problem is and how to solve it.

5. Define Algorithm in your words.
Answer:
An algorithm is a set of instructions for solving a problem or accomplishing a task. In simple words we can say that an algorithm is a sequence of instructions or steps that can be followed by humans and computers to complete a specific task.

6. Enlist the characteristics of an algorithm.
Answer:
i. Clear and Unambiguous
ii. Well-Defined Inputs
iii. Finite-ness
iv. Language Independent

7. Differentiate between recursive and brute force algorithm.
Answer:
Brute Force Algorithm: It is the simplest approach to solve a problem. Brute Force Algorithm goes through all possible solutions until required solution is found.
Recursive Algorithm: In this algorithm, a problem is broken into several sub-parts and called the same procedure again and again.

8. Differentiate between searching and sorting algorithm.
Answer:
Searching Algorithm: Searching algorithm are used for searching elements or groups of elements from a particular data.
Sorting Algorithm: The algorithms which help in arranging a group of data in a particular manner are called searching algorithms.

9. What are loops? Discuss its types.
Answer:
Loops
In problem solving, a loop is a sequence of instructions that is executed again and again until a certain condition is true. If the condition becomes false, the statements outside the branches the loop are executed.
Types of Loops
There are two most common types of loops:
• Finite loops
• Infinite loops
Finite Loops
The most common type of loop is finite loop. There type of loops have explicit end and these loops execute their bodies for a fixed number of times. A finite loop stops when the condition is false.
Infinite Loops
An infinite loop, have doe not an explicit end. It runs for an infinite time because its condition remains true for iterations.

10. Enlist advantages and disadvantages of flowcharts.
Answer:
Advantages of Flowchart
• Easy to make
• Easy to understand
• Mistake can be easily identified
• Debugging becomes possible
• Logics can be easily understand
Disadvantages of Flowchart
• Difficult to present complex programs
• modification is difficult
• Time consuming
• Difficult to understand for people who don’t know the flowchart symbols

Answer the following questions in detail.

1. Define pattern reorganization in your words.
Answer:
Pattern recognition
Pattern recognition is looking for patterns in the problem and determining if there could be any of the problems or solutions we have faced in the past cab be applied here. It may also involve recognition shapes, sounds or simages.
Example:
Pattern Recognition is used to identify similarities between decomposed problems. If we are developing a game, we can recognize similar objects, patterns, and actions. Finding these allows us to apply the same, or slightly modified, approach which makes our solution more efficient.

2. Write an algorithm to find sum of three numbers.
Answer:
Algorithm to add 3 numbers and print their sum:
1. START
2. Declare 3 integer variables num1, num2 and num3.
3. Take the three numbers, to be added, as inputs in variables num1, num2, and num3 respectively.
4. Declare an integer variable sum to store the resultant sum of the 3 numbers.
5. Add the 3 numbers and store the result in the variable sum.
6. Print the value of the variable sum
7. END

3. Write the algorithm to find whether given number is even or odd.
Answer:
Algorithm to find whether given number is even or odd
1. START
2. Declare an integer variable num1.
3. Take the number, to be checked, as inputs in variables num1.
4. Declare an integer variable remainder to store the resultant remainder by 2 of the number.
5. Remainder = num1 %2(% operator is used to get remainder).
6. Check IF remainder =0, then print ” number is even’, Otherwise print “number is Odd’
7. END

4. Write down rules of writing a flowchart.
Answer:
Rules for Drawing Flowcharts
We should follow the following rules while drawing a flowchart:
1. Use conventional flowchart symbols.
2. Every flow chart must have the start and End points.
3. Each symbol should have one exit point except the decision symbol.
4. Flow lines should not cross each other.
5. The flow lines coming out of the decision symbol should be labeled properly.

5. Why don’t we consider memory in measuring efficiency of an algorithm?
Answer:
Memory is not considered a primary factor in measuring the efficiency of an algorithm because memory is not a big constraint for modern computer systems. The efficiency of an algorithm is primarily determined by the number of steps or operations that need to be executed to solve the problem. Therefore, a solution which takes fewer steps to solve a problem is considered more efficient. However, it is still important to consider memory usage when designing algorithms, especially in resource-constrained environments.

6. Draw a flowchart to find the sum of three numbers.
Answer:

7. Draw a flowchart to find whether given number is even or odd.
Answer:

8. How can we measure the efficiency of a solution?
Answer:
Efficiency of a Solution: There can be more than one solution for one problem and one solution can be more efficient than others. The efficiency of a solution is measured by the following parameters:
(1) Number of steps executed by the solution to solve the problem.
(2) Memory consumed by the solution.
So, we can say that the efficiency of a solution is always measured in terms of no. of steps taken by the solution. The solution which solves a problem in less number of steps is considered more efficient than that which takes more steps to solve because memory is not an issue for computer systems now.
Example: Let us see the following example:
Write an algorithm to find the largest number from three numbers
Solution 1:
Step 1: START
Step 2: Take three unique numbers in A, B, C
Step 3: Set A= largest
Step 4: Check if B is greater than largest, set B = largest
Step 5: Check if C is greater than largest, set C is largest
Step 6: Print largest
Step 7: END
Solution 2:
1. START
2. Input three unique numbers A,B and C
3. Check If A is greater than B, then go to step 6
4. Check If B is greater than C, then print B is largest and go to step 8
5. Print C is largest and go to step 8
6. Check If A greater than C, then print A is largest and go to step 8
7. Print C is largest
8. END
Analysis
We can see that solution1 and solution2 are solving the same problem. Solution 1 is solving the problem in seven steps and using four variables A, B, C and largest while Solution2 is solving the same problem in 8 steps and it is using three variables A, B, C. As solution1 solves problem in less No. of steps we can say that solution1 is more efficient than Solution2 although it consumed less memory.