Unit-I: 1. Define Algorithm
Unit-I: 1. Define Algorithm
1. Define algorithm.
Program=algorithm +data
It is another way to describe the algorithm. Pseudo means false or imitation and code is
the programming language. Pseudo code consists of short, readable and formally styled English
languages used for explain an algorithm.
3. Define flowchart.
4.Notation Of Algorithm
Pseudo code
Flowchart
Programming Language
5. Characteristics of algorithm:
Uniqueness
Finiteness
Input
Output
generality
7. Properties of Algorithms
1
Should be written in simple English
Each and every instruction should be precise and unambiguous.
Instructions in an algorithm should not be repeated infinitely.
Algorithm should conclude after a finite number of steps.
Should have an end point.Derived results should be obtained only after the algorithm
terminates.
8. Advantages of flowchart:
Communication
Effective analysis
Proper documentation
Efficient Coding
Proper Debugging
Efficient Program Maintenance
9. Disadvantages of flowchart:
Complex logic
Alterations and Modifications
Reproduction
Cost
BEGIN,END: Begin is the first statement and end is the last statement.
INPUT, GET, READ: The keyword is used to inputting data.
COMPUTE, CALCULATE: used for calculation of the result of the given expression.
2
ADD, SUBTRACT, INITIALIZE used for addition, subtraction and initialization.
OUTPUT, PRINT, DISPLAY: It is used to display the output of the program.
IF, ELSE, ENDIF: used to make decision.
WHILE, ENDWHILE: used for iterative statements.
FOR, ENDFOR: Another iterative incremented/decremented tested automatically
16. Recursion:
A function that calls itself is known as recursion.
Recursion is a process by which a function calls itself repeatedly until some specified
condition has been satisfied.
It involves executing one or more steps for a number of times and it can be implemented using
while and for loop. These loops execute one or more steps until some condition is true.
18. Write the algorithm, pseudo code and flowchart for the following :
Instruction action/sequence
State/selection decision
Control flow/iteration repetition/loop
Functions
Instruction/ Sequence:
Sequence is the specific order in which the instructions are performed in an algorithm.
Step 1
4
Step 2
Step n
State/Selection:
Selection is a decision or question . state is the result of selection either true or false.
condition
false true
Action y Action x
Recursion:
6
4. Tower of Hanoi: (refer page number:19,20,21)
Rules:
Only one disk can be moved among the towers at any given time
Only top disk can be moved
No Larger disk can sit over smaller disk
Draw the diagram one by one
Write the algorithm(refer pg no:20) algorithm 1.4
Draw flowchart(refer pg no:21) flowchart1.4
5. Define flowchart? Explain the rules with its advantages and disadvantages.
6. Write the algorithm and pseudo code for finding the minimum in a list.
7. Write the algorithm and pseudo code for inserting a card into a list of sorted cards.
8. Write the algorithm and pseudo code for find the random number in a given range.