9th Computer
9th Computer
3- Planning a solution
In this phase , we formulate a plan that may lead us towards the solution of a problem.
This phase includes finding the right strategy for problem solving. Some of strategies are :
1- Divide and conquer
2- Guess Check and improve
3- Act it Out
4- Prototype (Draw)
1- Divide and conquer
3- Act it Out
In this strategy the designer defines the list of “to do” tasks.
Afterwards he performs the task.
4- Prototype (Draw)
Oval is used to represent the start or end of the flowchart. It is also called Terminal.
2- INPUT / OUTPUT
3- PROCESS
4- FLOWLINES
Arrows are used to represent the direction of flow in the flowchart .
There are four flow lines.
1- up arrow
2- Down arrow
3- Right arrow
4- Left arrow
5- DECESION
Diamond symbol is used to represent decision step in the flowchart.
Condition is given in the diamond box.
Flow of control from diamond box may go in two possible
direction.
If condition is TRUE or YES go to one direction.
If ondition is FALSE or NO go to other direction.
6- CONNECTOR
Connector is used to connect different lines.
It is used when different flow lines come from
different directions and move to one direction.
1.3 Algorithm :
2- To find acceleration of a moving object with given mass and the applied force.
Step 1 : Start
Step 2 : Input numbers, mass, force
Step 3 : Set acceleration to Force
mass
Step 4 : Output acceleration
Step 5 : End
3- To find the volume of a cube.
Step 1 : Start
Step 2 : Input numbers, side
Step 3 : Set volume to side x side x side.
Step 4 : Output
volume
Step 5 : End
Step 1 : Start
Step 2 : Input numbers, r ,h
Step 3 : Set volume of Sphere to 4/3 x π r3
Step 3 : Set volume of cylinder to π r2h
Step 4 : Output volume
Step 5 : End
Lecture No. 14 :
Algorithm
Example No.4
Example No.5
Activity No. 1.8
1- Area of Triangle
Step 1 : Start
Step 2 : Input numbers, base, height
Step 3 : Set area to 1/2 x base x height
Step 4 : Output area
Step 5 : End
2- Area of rhombus
Step 1 : Start
Step 2 : Input numbers, p,q
Step 3 : Set area to p x q
2
Step 4 : Output area
Step 5 : End
3- Area of trapezium
Step 1 : Start
Step 2 : Input numbers, base , height
Step 3 : Set area to 1/2 ( base + height) x h
Step 4 : Output area
Step 5 : End
Lecture No. 15 :
Algorithm
Example No.6
Example No.7
9- Find even numbers in integers ranging from n1 to n2 (where n2 is greater than n1).
Step 1 : Start
Step 2 : Input numbers, n1 , n2
Step 3 : if (n1 <= n2)
{
Step 4 : if ( n1 mod 2 equal 0) output n1
Step 5 : Set n1 to n1 + 1
Step 5 : go to step 3
}
Step 6 : End
Lecture No. 17 :
Algorithm
Efficiency of Algorithms
1.3.5 : Efficiency of Algorithms
There can be more than one algorithms to solve the same problem.
Which one is better, depends upon the efficiency of the available solution algorithms.
Efficiency of an algorithm is measured on the basis of two metrics.
1. Number of steps: An algorithm is considered more efficient if it takes less number of
steps to reach the results.
2. Space used in computer memory: We have observed in algorithms that some data is
stored in computer memory which is latter used to give results. An algorithm using less
space in computer memory is considered more efficient with respect to memory space
Lecture No. 18
Algorithm
Activity No. 1.9
Lecture No.19 :
Difference between an Algorithm and a Flowchart
Advantages of Flowchart
Disadvantages of Flowchart.
Advantages of Algorithm
Disadvantages of Algorithm
FLOWCHART ALGORITHM
The symbols are used to draw flowchart. Simple English is used to write algorithm.
Flowchart is more time consuming. Algorithm is less time consuming.
It is difficult to modify. It is easy to modify.
It is graphical representation. It is a step by step procedure.
It is a movie. It is a story.
Advantages of Flowchart :
Easy to draw.
Easy to understand problem solving.
Easy to identify errors (if any).
Easy to observe flow from one step to the other.
Disadvantages of Flowchart :
More time is required to draw a flowchart.
Modifying a flowchart is not very easy every time
Advantages of Algorithm :
Easy to write.
Techniques to write an algorithm are easy to understand.
To solve a large problem, algorithms are helpful.
Disadvantages of Algorithm :
Modifying an existing algorithm is not very easy every time.
Showing the flow from one step to the other is not very easy.
Usage of goto makes it difficult to identify errors.
Lecture No. 20 :
Test Data
Activity No. 1.10
Importance of Testing
If an algorithm is supposed to take a numeric value between 1 and 100 as input, then
any value between 1 and 100 is a valid test data.
2- Invalid test data:
It is the data that does not comply with the input requirements of the algorithm.
It is necessary to make sure that the solution correctly works for invalid values, shows
the relevant messages notifying the user that the provided input values are
improper.
3- Boundary test data values:
A solution is tested on extreme values.
For example, to calculate interest we can consider principal amount as 0 or a very huge
amount.
4- Wrong data formats :
It is wise to check how the system reacts on entering data in an inappropriate format.
For example, giving an alphabet as input when a numeric value is expected.
5- Absent data :
It is also important to investigate that the solution still works if less number of inputs
are given than expected.
For example, if a system asks to enter driving license number, then every one cannot
provide this information.
It is important to see how the system reacts in such situations.
1.5 Verification and Validation
Verification :
Verification means to test if the solution is actually solving the same problem for which
it was designed.
For example, if you are asked to give a solution for calculating compound interest then
verification means to know that it is giving results for compound interest not for the plain
interest.
Validation :
Validation means to test whether the solution is correct or not.
For example, if you are asked to give a solution for calculating compound interest then
validation means to know whether it is finding the correct compound interest or not.
If a solution is verified, then it is validated with the help of test data .
Example no.1 of Verification and Validation
Let's assume that you go to a pizza shop
and order a chicken pizza.
You state your requirement that it should be less spicy.
You also expect that it would taste good.
When the pizza arrives,
you can observe that it is a chicken pizza.
This is called verification.
Now, when you eat the pizza,
you can check whether it is less spicy or not,
it tastes good or not. This is called validation.
Lecture No. 23 :
Activity No. 1.11
Solve Exercise No.1 to 7
Lecture No. 24
Solve MCQ’s
Solve Fill in the Blank
Solve Exercise 1.4