Computers is machine that not only use to develop the software. It is also used for solving various day-to-day problems. Computers cannot solve a problem by themselves. It solve the problem on basic of the step-by-step instructions given by us. Thus, the success of a computer in solving a problem depends on how correctly and precisely we –
Thus problem solving is an essential skill that a computer science student should know.
1. Analysing the problem
2. Developing an Algorithm
3. Coding
4. Testing and Debugging
The program created should be tested on various parameters.
Software Testing methods are
Debugging – The errors or defects found in the testing phases are debugged or rectified and the program is again tested. This continues till all the errors are removed from the program.
Algorithm is a set of sequence which followed to solve a problem.
Algorithm for an activity ‘riding a bicycle’:
Algorithm for Computing GCD of two numbers:
A finite sequence of steps required to get the desired output is called an algorithm. Algorithm has a definite beginning and a definite end, and consists of a finite number of steps.
Characteristics of a good algorithm
While writing an algorithm, it is required to clearly identify the following:
There are two common methods of representing an algorithm —
1. Flowchart — Visual Representation of Algorithms
A flowchart is a visual representation of an algorithm. A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows. Each shape represents a step of the solution process and the arrow represents the order or link among the steps. There are standardised symbols to draw flowcharts.
Question: Write an algorithm to find the square of a number.
Algorithm to find square of a number.
The algorithm to find square of a number can be represented pictorially using flowchart
2. Pseudocode
A pseudocode (pronounced Soo-doh-kohd) is another way of representing an algorithm. It is considered as a non-formal language that helps programmers to write algorithm. It is a detailed description of instructions that a computer must follow in a particular order.
Keywords are used in pseudocode:
Question : Write an algorithm to calculate area and perimeter of a rectangle, using both pseudocode and flowchart.
Pseudocode for calculating area and perimeter of a rectangle.
The flowchart for this algorithm
Benefits of Pseudocode
The flow of control depicts the flow of process as represented in the flow chart. The process can flow in
1. Sequence
In a sequence steps of algorithms (i.e. statements) are executed one after the other.
2. Selection
In a selection, steps of algorithm is depend upon the conditions i.e. any one of the alternatives statement is selected based on the outcome of a condition. Conditionals are used to check possibilities. The program checks one or more conditions and perform operations (sequence of actions) depending on true or false value of the condition.
Question : Write an algorithm to check whether a number is odd or even.
Pseudocode of the algorithm can be written as follows:
The flowchart representation of the algorithm
3. Repetition
Repetitions are used, when we want to do something repeatedly, for a given number of times.
Question : Write pseudocode and draw flowchart to accept numbers till the user enters 0 and then find their average.
Pseudocode is as follows:
The flowchart representation is
Once an algorithm is finalised, it should be coded in a high-level programming language as selected by the programmer. The ordered set of instructions are written in that programming language by following its syntax.
We need to translate the source code into machine language using a compiler or an interpreter so that it can be understood by the computer.
Decomposition
Decomposition is a process to ‘decompose’ or break down a complex problem into smaller subproblems. It is helpful when we have to solve any big or complex problem.
Once the individual sub-problems are solved, it is necessary to test them for their correctness and integrate them to get the complete solution.
84 videos|19 docs|5 tests
|
|
Explore Courses for Grade 11 exam
|