Poriyaan - Problem Solving and Python Programming (2 Marks) PDF - Bin-1
Poriyaan - Problem Solving and Python Programming (2 Marks) PDF - Bin-1
/
in
ALGORITHMIC PROBLEM SOLVING
n.
PART-A
aa
1. What is an algorithm?
riy
Algorithm is a step-by-step procedure/description for solving a task or a
problem. The steps must be ordered, unambiguous and finite in number. Algorithm is
an ordered sequence of finite, well defined unambiguous instructions for completing a
o
task it is an English-like representation of the logic which is used to solve the problem.
.p
2. Write an algorithm to accept two numbers compute the sum and print the
result.
w
w
Algorithm:
Step 1: Start
//w
Algorithm:
Step 1: Start
Step 2: Read the limit of list as ‘n’
Step 3: Read the elements of list A
Step 4: Assign min=A[0]
Step 5: for i=1 to n repeat step 6 and step 7
Step 6: Check if A[i]<min
Step 7: Then assign min=A[i]
Step 8: Print the value of min
Step 9: Stop
4. Distinguish between algorithm and program
Algorithm Program
Algorithm is finite. Program need not be finite.
It is a step-by-step procedure to solve a It is an exact code to solve a problem.
/
problem.
in
It is written using natural language or It is written using a specific programming
n.
algorithmic language. language.
aa
5. List the building blocks of algorithm.
riy
• Statements
• State
o
• Control flow
➢ Sequence
.p
➢ Selection or Conditional
➢ Repetition or Iteration
w
• Functions
w
Two types:
tp
➢ Simple Statement
➢ Compound Statement
ht
Control flow (or flow of control) is the order in which individual statements,
instructions or function calls of a program are executed or evaluated. A control flow
statement is a statement which execution results in a choice being made as to which
of two or more path to follow.
A Control flow statement is a statement which execution results in a choice being made
as to which of two or more paths to follow.
Step 1: Start
Step 6: Stop
/
9. What is a function?
in
A function is a set of related instructions that are used to perform a specified
task which repeatedly occurs in the main program. Functions usually “take in” data,
n.
process it, and “return” a result.
aa
10. Define a pseudocode?
Pseudo means limitation or false and code refers to the instructions written in any
iy
programming language. It is also called Program Design Language (PDL). It is somewhat
halfway in between English and a Programming Language.
or
11. Give the rules of writing Pseudocode.
.p
➢ Write one statement per line.
➢ Keywords must be capitalized
w
➢ Steps must be understandable
➢ It must be concise
w
12. Write the pseudocode to calculate the sum and product of two numbers and
display it.
s:
BEGIN
READ TWO NUMBERS num1, num2
tp
COMPUTE sum=num1+num2
COMPUTE product=num1*num2
ht
13. Give the difference between flowchart and pseudocode (or) Distinguish between
pseudocode and flowchart.
Flowchart Pseudocode
A flowchart is a diagrammatic Pseudo means imitation or false and
representation of an algorithm. code refers to the instructions written in
any programming language.
It follows a standard format. Unlike a flowchart, it uses a written
format.
It uses different shapes of boxes to It can be written in ordinary English, and
represent the processes involved in the with some keywords.
problem
14. Define a flowchart.
A flowchart is a diagrammatic representation of an algorithm. In which the steps
are represented in the form of different shapes of boxes and logical flow is indicated
by interconnecting arrows. The purpose of drawing the flowchart is to help the
programmer in understanding the logic the program.
/
in
15. List the symbols used in drawing the flowchart?
Symbols Name
n.
aa
Terminal
iy
Input/Output
or
Processing
.p
w
Decision
w
//w
Connector
s:
16. List the categories of Programming Languages. (or) Point out any 5-
tp
programming language.
/
different set of binary machine language before
in
instruction for different to their execution using a
types of computer system software compiler.
n.
systems.
aa
18. List out the simple strategies to develop an algorithm (or) Discover the steps of
simple strategies for developing algorithms.
iy
Algorithm development process consists of five major steps.
or
Step 1: Obtain a description of the problem
Step 2: Analyze the problem
.p
Step 3: Develop a high-level algorithm
Step 4: Refine the algorithm by adding more details
w
Step 5: Review the algorithm
w
Recursion Iteration/Repetition
Function calls itself again and Executing the processes until the
s:
https://www.poriyaan.in/