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

Unit 1 Problem Solving

Computer Science 9th Class Notes Chapter 1

Uploaded by

JAMIA QASIM
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)
419 views

Unit 1 Problem Solving

Computer Science 9th Class Notes Chapter 1

Uploaded by

JAMIA QASIM
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/ 6

Unit No.

1 Problem Solving Computer Science 9th

Q.1. What is Problem Solving? Ans: Something unexpected or unplanned is called candid.
Ans: Finding solution of a problem in a systematic way is For example, if you are asked to find the number of
called problem solving‫۔‬ students of cricket player in your school you can estimate
Q.2. What is Defining a Problem? by counting cricket players in your class and then multiply
Ans: A well-defined problem is the one that does not have it by the total number of classes in your school. This
any ambiguities. It has clear goal and easy to understand. answer is candid solution. Candid solution helps to save
Q.3. What are the strategies to define a problem? time but it may not be actual solution.
Ans: Different strategies can be used to define a problem Q.12. Explain Selecting the Best Solution?
like I. Gain Background knowledge: we have to Ans: A best solution among all possible solutions is that
identify a state / situation in which a problem is one which has less number of steps or the solution which
happening. II. Use Guesses: On the basis of past is achieved in less
experience by using of right guesses unknown information amount of time. For
collected. III. Draw a Picture: By drawing the picture Example you have to
fill the undefined information. find a name of student
Q.4. Define Problem Analysis with Example. on a website. It can be
Ans: Problem analysis helps to understand a given done by.
problem. Problem analysis I. Look at each name
is the process to find out on website one by
the 5 Ws from the problem one until the name is found or list is over.
statement II. Search the name after printing the list.
For example teacher asks III. Put all data in Excel Sheet and sort it in alphabetic
student to prepare the list order and find the name.
of students in the school IV. Just Press Ctrl+F in browser type name and press
whose name start with letter „A‟ for preparing an enter system will find it.
alphabetic directory of all students in one week. Q.13. What is Flowchart?
Q.5. What are 5 Ws in Problem Analysis? Ans: It is a pictorial / graphical
Ans: Understanding of a problem usually includes representation of the steps to
identification of the 5 Ws (What, Who, When, Where, and solve a problem. Various
Why). In above problem identification of 5 Ws are as interconnected symbols are used
follow What: List of students‟ names starting with letter for it.
„A‟ Who: Students Why: To prepare the directory of Q.14. What is Importance of
students. When: within a week Where: school Flowchart?
Q.6. What is meant by Planning a Solution? Ans: Importance of Flowchart is
Ans: It includes to find out the right strategy to solve the as follow
problem these strategies are Divide and Conquer, Guess, I. It is used to plan a solution.
Check & Improve, Act it Out, Prototype (Draw). II. It helps to understand a way of problem solution
Selection of a particular strategy is depends upon the quickly.
nature of problem. III. It helps to verify the correctness of solution
Q.7. What is Divide and Conquer Strategy? quickly.
Ans: Dividing a complex problem into smaller problem is IV. It is a good way to communicate the problem
called Divide and Conquer Strategy. solution to other people.
Q.8. What is Guess, Check & Improve Strategies? Q.15. Determine the Requirements for Flowchart.
Ans: In this Strategy a designer guesses a solution of Ans: Following requirements are necessary for flowchart.
problem and then checks its correctness. If it is not I. Inputs: it means taking data from the user. Number
according to expectation then he/she refines it. of inputs and types of inputs must be known.
Q.9. What is Act it Out Strategy?
Ans: In this Strategy the designer prepare a “to-do” list of
tasks.
Q.10. What is Prototype (Draw) Strategy?
Ans: In this Strategy pictorial representation of the
solution is prepared.
Q.11. What is Candid Solution?

Abdul Rehman S.S.T(I.T)


Govt. Jamia Qasim-Ul-Uloom H/S Sargodha 1
Unit No. 1 Problem Solving Computer Science 9th

II. Processing: It means performing the operation or


calculation on the inputs and storing it.
III. Decision Making: It means checking a statement is
true or false and taking appropriate step accordingly.
IV. Outputs: it means the result of input after processing 6. Anoter Solution of
it. Problem 5.
Q.16. What are the Symbols of Flow Chart?
Ans: Symbols are special shapes. These are used to
explain the actions
/ steps clearly in a
process.

Symbol Name Description


It is used to determine the
Flow line
flow of steps in a flowchart
It indicate start and end of
Terminal 7. To
flowchart
assign
It represents operations to grade
Process
change values to a
It shows conditional operation subjec
that determines which one of t based on total marks and
Decision the two paths to take. obtained marks
Operation is commonly yes /
no question or true / false test.
It indicate the input of data
Input /
from user or display results to
Output
user
It is used to connect parts of a
Connector flowchart on different pages if
it is not fit on single page

Q.17. Give Some Examples of Flowcharts.


Ans: 1.To convert Celsius to Fahrenheit temperature.

2. To find acceleration of a moving object with given


mass and the force applied.
3. To find the Volume of cube.

4. To determine whether a given no is odd or even.

5. To Display the larger one out of the three given unequal


number

Abdul Rehman S.S.T(I.T)


Govt. Jamia Qasim-Ul-Uloom H/S Sargodha 2
Unit No. 1 Problem Solving Computer Science 9th

The word "algorithm" comes from the name of Arabic


writer Muhammad Bin Musa al-Khwarizmi.
Q.19. What is Role of Algorithm on Problem Solving?
Ans: An algorithm has a vital role in problem solving as
I. It provides a step-by-step guide to the problem
solver.
II. It is a complete description of the solution.
III. Usually a computer programmer first writes an
algorithm and then moves towards the further
steps but sometimes vice versa.

Q.20. What are the Notions (Keywords) of an


Algorithm?
Ans: Some notions / keywords are as follows.
I. Start: It is the starting point of an algorithm.
Every algorithm must have one starting (entry)
7. To determine name of a week day from a given number point.
where weekdays are assumed from Monday to Sunday II. Input: It is used to get input from a user and store
and their respective numbers from 1 to 7. it in computer memory with some name.
III. Set: It is used to give name to data in computer
memory or update the value of existing data.
IV. If, else: It is used to check the condition.
V. Goto: It is used to transfer control to a certain step
of an algorithm. It is usually required in loops.
VI. Output: It is used to display values / results.
VII. Stop: It is the termination point of an algorithm.
Q.21. Write Some Examples of Algorithm.
Ans: 1. To find the sum, product and average of five
given numbers.
Step 1. Start
Step 2. Input numbers, n0, n1, n2, n3, n4
Step 3. Set sum to n0 + n1 + n2 + n3 + n4.
Step 4. Set product to n0 X n1 X n2 X n3 X n4
Step 5. Set average to
Step 6. Output sum, product, average
Step 7. End
2. To find acceleration of a moving object with given
Q.18. Define Algorithm. mass and the applied force.
Ans: An algorithm is a set of steps written in a natural Step 1. Start
language to solve a problem. It is easily understandable by Step 2. Input numbers, mass, force
humans For example; to solve the problem of preparing Step 3. Set acceleration to
tea we can follow the following steps
Step 4. Output acceleration
a) Start
Step 5. End
b) Take a kettle
3. To find the volume of a cube.
c) Pour water in it.
Step 1. Start
d) Put the kettle on fire.
Step 2. Input number, side
e) Add sugar and milk.
Step 3. Set volume to side X side X side.
f) Wait till it boils.
Step 4. Output volume
g) Remove the kettle from fire.
Step 5. End
h) End.
Abdul Rehman S.S.T(I.T)
Govt. Jamia Qasim-Ul-Uloom H/S Sargodha 3
Unit No. 1 Problem Solving Computer Science 9th

4. To find the area of a parallelogram. Step 8. End


Step 1 Start 9. Find even numbers in integers ranging from n1 to
Step 2 Input numbers, base, height n2 (where n2 is greater than n1).
Step 3. Set area to base X height Step 1. Start
Step 4. Output area Step 2. Input numbers, nl, n2
Step S. End Step 3. if (n1<_ n2){
5. To display the larger one out of the three given Step 4. if (n1 mod 2 equal 0) Output n1
numbers. Step 5. Set n1 to n1 + 1
Step 1 Start Step 6. go to Step 3
Step 2 Input numbers, n0,n1,n2 }
Step 3. Set large to n0 Step 7. End
Step 4. if n1 > large Set large to n1 How to Measure the Efficiency of an Algorithm?
Step 5. if n2 > large Set large to n2 Ans: Efficiency of an algorithm is measured on the basis
Step 6. Output large of two metrics,
Step 7. End I. Number of steps: An algorithm is considered more
6.To assign grade to a subject based on the achieved efficient if it has less number of steps.
marks. II. Space used in computer memory: An algorithm is
Step 1. Start considered more efficient if it is using less memory.
Step 2. Input numbers, obtained_marks, total_marks For example: 1+2+3+4+5+…+99
obtained marks It has different solution.
Step 3. Set percentage to ( )
Step 4. if percentage > 80 Set grade to A+
else
if percentage > 70 Set grade to A
Q.22. Differentiate between Algorithm & Flowchart.
else
Ans:
if percentage > 60 Set grade to B
Flowchart Algorithm
else
1. Flowchart is a graphical 1. Algorithm is writing the
if percentage > 50 Set grade to C representation of the same steps in a human
else process to solve a problem. understandable language.
if percentage > 40 Set grade to D 2. Easy to draw. 2. Easy to write.
else 3. Easy to understand 3. Easy to understand
if percentage > 33 Set grade to E problem solving. problem solving.
else 4. Easy to identify errors (if 4. To solve a large problem,
any). algorithms are helpful.
Set grade to F.
5. Easy to observe flow 5. Difficult to observe flow
Step 5. Output grade from one step to the other. from one step to the other.
Step 6. End 6. More time is required to 6. Less time is required to
7. To find the interest on an amount. draw a flowchart. draw an algorithm
Step 1. Start 7. Modifying a flowchart is 7. Modifying an algorithm
Step 2. Input numbers, amount, rate, years not very easy every time. is not very easy every time.
8. It is not suitable for very 8. Usage of goto makes it
Step 3. Set plain_ interest to( )
large problems. difficult to identify errors.
Step 4. Output plain_interest Q.23. What is meant by Test Data?
Step 5. End Ans: After solving a problem, we need to test whether the
8. To convert Celsius to Fahrenheit temperature and solution is correct or not, and for testing, we need "Test
vice versa. Data". For example, if we want to test the algorithm
Step 1. Start (discussed earlier) to find the largest among three given
Step 2. Input number, celsius numbers n0, n1, and n2, then we need three values. These
Step 3. Set fahrenheit to values can be positive, negative or zero, e.g., (n0 = 5, n1 =
Step 4. Output fahrenheit 15, n2 = 3), (n0 = 27, n1 = —6, n2 = 35 ), (n0 = 24, n1 =
Step 5. Input number, fahrenheit 0,n2 = 11), etc. So, for thinking about testing, we also
need to think about test data.
Step 6. Set celsius to ( )
Q.24. What is the Importance of Testing?
Step 7. Output celsius
Abdul Rehman S.S.T(I.T)
Govt. Jamia Qasim-Ul-Uloom H/S Sargodha 4
Unit No. 1 Problem Solving Computer Science 9th

Ans: It is vital to point out the defects or errors. It helps in logical means algorithm is providing wrong result. For
improving a solution. Correctness of solution depends identification of error trace table is used.
upon the testing. Q.33. What is Trace Table?
Q.25. Explain Types of Test Data? Ans: The multi-column, multi-row table used to test
Ans: Different solutions require different types of data. algorithm for identification of logical errors. Each column
Proper test data is required to improve the quality of shows name of data and each row showing values of data
solution. These types are Valid Test Data, Invalid Test at each step. For example;
Data, Boundary Test Data Values, Wrong Data Formats, Algorithm
and Absent Data. Step1 number = 3
Q.26. What is Valid Test Data? Step 2 PRINT number
Ans: The data that fulfills the input requirements of Step 3 FOR i from 1 to 3:
algorithm. If an algorithm is supposed to take a numeric Step 4 number = number + 5
value between 1 and 100 as input, then any value between Step 5 PRINT number
1 and 100 is a valid test data. Step 6 PRINT “ ? ”
Trace Table
Line number i output
Q.27. What is Invalid Test Data? 1 3
Ans: Improper or unexpected data that give wrong output 2 3
or show messages to notifying the user for incorrect. If an 3 1
4 8
algorithm requires your age in number of days but you
5 8
give date of birth as input then the algorithm may not
3 2
work properly. 4 13
Q.28. What are Boundary Test Data Values? 5 13
Ans: A solution is tested on extreme values, For example, 3 3
to calculate interest we can consider principal amount as 0 4 18
or a very huge amount. 5 18
Q.29. What is Wrong Data Formats? 6 ?
Ans: It is wise to check how the system reacts on entering
data in an inappropriate format. For example; giving an Q.34. What is meant by Testing Using Invalid Data?
alphabet as input when a numeric value is expected. Ans: To handle unexpected data inputs algorithm is tested
Q.30. What is Absent Data? by giving invalid data.
Ans: It is also important to study that the solution still EXERCISE
works if less number of inputs are given than expected. Choose the correct option.
For example, if someone enter ID card number in less
1) Which solutions are not reached through proper
than 14 digits how the system reacts in such situations. algorithms work planning?
Q.31. Differentiate between Verification & i Prepared solution ii Candid solution
Validation. iii Strategized solution iv Best solution
Ans: Verification means to test if the solution is actually 2) _________is a graphical representation of an
solving the same problem for which it was designed. For algorithm
example, if you are asked to give a solution for calculating
compound interest then verification means to know that it i Matrix ii Graph
iii Flowchart iv Solution
is giving results for compound interest not for the plain
3) Which symbol in the flowchart is used to either
interest. start or end the flowchart?
Validation means to test whether the solution is correct or i Terminal ii Connector
not. For example, if you are asked to give a solution for iii Process iv decision
calculating compound interest then validation means to 4) _______means to test if the required solution is
know whether it is finding the correct compound interest there.
or not. If a solution is verified, then it is validated with the i Verification ii Algorithm
help of test data. iii Validation iv Flowchart
5) In _______ error, the solution is working but not
Q.32. What is Identification & Correction of Errors?
giving required results
Ans: It is important to identify the root cause of failure of
i Random error ii Logical error
algorithm during verification. Sometime the error is iii Syntax error iv Runtime error

Abdul Rehman S.S.T(I.T)


Govt. Jamia Qasim-Ul-Uloom H/S Sargodha 5
Unit No. 1 Problem Solving Computer Science 9th

Fill in the blanks.


1) Before problem solving, we need to first___________
a problem.
2) An algorithm produces a defined set of ___________
3) A flowchart utilizes various___________
and___________to map out the order of steps.
4) In flowcharts symbol is used to show a__________
5) ___________is used to test the solutions.

Draw the flowcharts for the following problems.

1) Input two numbers n1 and n2. Determine whether n1


divides n2 or not.

2) Input a year and determine whether it is a leap year or


not.
3) Input a number and calculate its factorial.
4) Find LCM (Least Common Multiple) of two numbers.
5) Input a number and display its factors.
6) Design a flowchart to calculate fine amount for
Pakistan motorway. Fine is imposed according to the
following coding scheme. Input a code and display the
respective output.
Penalty
Code Offence Imprisonment
(Rs.)
Driving when
A20 1000 Up to 6 Months
disqualified
Obtaining or
Applying for a
driving license 500-
A21 Up to 6 Months
without disclosing 1000
particulars of
endorsement
Offence relating to
construction of 500-
A22 Up to 6 Months
vehicle 1000

Offence relating to 1000-


A23 Up to 6 Months
permits 2000
Overloading of goods
15 % in excess of 1000-
A24 Up to 1Month
permissible limits. 2000

Overloading of
passengers 30 % in 1000-
A25 Up to 1 Month
excess of permissible 5000
limits

Abdul Rehman S.S.T(I.T)


Govt. Jamia Qasim-Ul-Uloom H/S Sargodha 6

You might also like