Students can Download Computer Science Chapter 7 Composition and Decomposition Questions and Answers, Notes Pdf, Samacheer Kalvi 11th Computer Science Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.
Tamilnadu Samacheer Kalvi 11th Computer Science Solutions Chapter 7 Composition and Decomposition
Samacheer Kalvi 11th Computer Science Composition and Decomposition Text Book Back Questions and Answers
PART – 1
I. Choose The Correct Answer
Question 1.
Suppose u, v = 10, 5 before the assignment. What are the values of u and v after the sequence of assignments?
1. u : = v
2. v : = u
(a) u, v = 5, 5
(b) u, v = 10, 5
(c) u, v = 5, 10
(d) u, v = 10, 10
Answer:
(a) u, v = 5, 5
Question 2.
Which of the following properties is true after the assignment (at line 3?
1. – – i + j = 0
2. i, j : = i + 1, j – 1
3. – – ?
(a) i + j > 0
(b) i + j < 0
(c) i + j = 0
(d) i = j
Answer:
(c) i + j = 0
Question 3.
If C1 is false and C2 is true, the compound statement
(a) S1
(b) S2
(c) S3
(d) none
Answer:
(b) S2
Question 4.
If C is false just before the loop, the control flows through
(a) S1 ; S3
(b) S1 ; S2 ; S3
(c) S1 ; S2 ; S2 ; S2 ; S3
(d) S1 ; S2 ; S2 ; S2 ; S3
Answer:
(a) S1 ; S3
Question 5.
If C is true, S1 is executed in both the flowcharts, but S2 is executed in
(a) (1) only
(b) (2) only
(c) both (1) and (2)
(d) neither (1) nor (2)
Answer:
(a) (1) only
Question 6.
How many times the loop is iterated?
i : = 0
while i ≠ 5
i : = i + 1
(a) 4
(b) 5
(c) 6
(d) 0
Answer:
(b) 5
PART – 2
II. Short Answers
Question 1.
Distinguish between a condition and a statement.
Answer:
Question 2.
Draw a flowchart for a conditional statement.
Answer:
Question 3.
Both conditional statements and iterative statements have a condition and a statement. How do they differ?
Answer:
- A conditional statement is executed only if the condition is true. Otherwise, nothing is done.
- An iterative statement repeatedly evaluates a condition and executes a statement as long as the condition is true.
Question 4.
What is the difference between an algorithm and a program?
Answer:
Algorithm:
- An algorithm is for human readers to understand.
- Knowledge of English is needed.
- Easy to understand.
Program:
- The program is for the computers to execute directly.
- Knowledge of programming language is required.
- It is difficult to understand.
Question 5.
Why is a function an abstraction?
Answer:
A function is like a sub-algorithm. A function is specified by its own input property, and the desired input-output relation. So, other things are not required. So it is abstract.
Question 6.
How do we refine a statement?
Answer:
In a refinement, each statement is repeatedly expanded into more detailed statements in the subsequent levels.
PART – 3
Explain in Brief
Question 1.
For the given two flowcharts write the pseudo code.
Answer:
- Enter A,B
- Initialise Q = 0, r = A
- If r > B, then do Q = Q + 1; r = r – B else r, q
- Exit
Question 2.
If C is false in line 2, trace the control flow in this algorithm.
- S1
- – – C is false
- if C
- S2
- else
- S3
- S4
Answer:
S1 ; S2 ; S4
Question 3.
What is case analysis?
Answer:
Case analysis splits the problem into an exhaustive set of disjoint cases. For each case, the problem is solved independently.
If C1, C2, and C3 are conditions, and S1, S2, S3 and S4 are statements, a 4-case analysis statement has the form,
i) case C1
ii) S1
iii) case C2
iv) S2
v) case C3
vi) S3
vii) else
viii) S4
Question 4.
Draw a flowchart for -3 case analysis using alternative statements.
Answer:
Question 5.
Define a function to double a number in two different ways:
- n + n
- 2 x n
Answer:
Function to double a number in a first way using d = n + n
i) double(n)
ii) – – inputs: n is a real number
iii) – – outputs : d is a real number
d = n +n
Function to double a number in first way using d = 2 x n
i) double(n)
ii) — inputs: n is a real number
iii) – – outputs : d is a real number
d = 2 x n
PART – 4
IV. Explain in Detail
Question 1.
Exchange the contents: Given two glasses marked A and B. Glass A is full of apple drink and glass B is full of grape drink. Write the specification for exchanging the contents of glasses A and B, and write a sequence of assignments to satisfy the specification.
Answer:
Let the variables a, b, c represent Glass A, Glass B and Glass C and a, b, c can store values APPLE, GRAPE or EMPTY.
Specification:
- exchange (a, b)
- – – inputs: a, b : = APPLE, GRAPE
- – – outputs: a, b : = GRAPE, APPLE
Algorithm:
Question 2.
Circulate the contents: Write the specification and construct an algorithm to circulate the contents of the variables A, B, and C as shown below: The arrows indicate that B gets the value of A, C gets the value of B and A gets the value of C.
Specifications:
- circulate
- – – inputs: a, b, c: = A, B, C
- – – outputs: a, b, c: = C, A, B
Algorithm:
- circulate (a, b, c)
- – – a, b, c: = A, B, C
- temp : = c
- c : = b
- b : = a
- a : = temp
- – – a, b, c: = C, A, B
Question 3.
Decanting problem. You are given three bottles of capacities 5, 8, and 3 liters. The 8L bottle is filled with oil, while the other two are empty. Divide the oil in an 8L bottle into two equal quantities. Represent the state of the process by appropriate variables. What are the initial and final states of the process? Model the decanting of oil from one bottle to another by assignment. Write a sequence of assignments to achieve the final state.
Answer:
(a)
Let a, b, c be the variables whose maximum values are 8L, 5L, and 3L respectively.
Initial State:
a, b, c: = 8, 0, 0
Final State:
a, b, c: = 4, 4, 0
Specifications:
- decant
- – – inputs: a, b, c : = 8, 0, 0
- – – outputs: a, b, c : = 4, 4, 0
Algorithm:
Let us assume that a: = b denotes oil in b is poured into a bottle until either “a” is full or “b” becomes empty.
- decant (a, b, c)
- – – a, b, c : = 8, 0, 0
- b : = a
- – – a, b, c : = 3, 5, 0
- c : = b
- – – a, b, c : = 3, 2, 3
- a : = c
- – – a, b, c : = 6, 2, 0
- c : = b
- – – a, b, c : = 6, 0, 2
- b : = a
- – – a, b, c : = 1, 5, 2
- c : = b
- – – a, b, c : = 1, 4, 3
- a : = c
- – – a, b, c: = 4, 4, 0
Question 4.
Trace the step-by-step execution of the algorithm for factorial(4).
factorial(n)
– – inputs: n is an integer, n ≥ 0
– – outputs : f = n!
f, i : = 1,1
while i ≤ n
f, i : = f x i, i + 1
Answer:
Samacheer Kalvi 11th Computer Science Composition and Decomposition Additional Questions and Answers
PART – 1
I. Choose the correct answer
Question 1.
How many different notations are there for representing algorithms?
a) 5
b) 4
c) 3
d) 2
Answer:
c) 3
Question 2.
………………. is a diagrammatic notation for representing algorithms.
(a) Pseudocode
(b) Flowchart
(c) Program
(d) Languages
Answer:
(b) Flowchart
Question 3.
A _________ is a notation for expressing algorithms to be executed by computers.
a) programming language
b) pseudo code
c) flow chart
d) none of these
Answer:
a) programming language
Question 4.
A ………………. statement is composed of a sequence of statements.
(a) iterative
(b) conditional
(c) sequential
(d) alternative
Answer:
(c) sequential
Question 5.
_________ expressed in pseudo-code are not intended to be executed by computers.
a) programming language
b) algorithm
c) flow chart
d) None of these
Answer:
b) algorithm
Question 6.
The triangle is right-angled, if ……………….
(a) C = a – b
(b) C2 = a2 + b2
(c) C2 = (a + b)2
(d) c2 = a2 – b2
Answer:
(b) C2 = a2 + b2
Question 7.
_________ give a visual intuition of the flow of control when the algorithm is executed.
a) programming language
b) pseudo-code
c) flow chart
d) None of these
Answer:
c) flow chart
Question 8.
After an algorithmic problem is decomposed into subproblems, we can abstract the subproblems as ……………….
(a) refinement
(b) pseudo – code
(c) decomposition
(d) functions
Answer:
(d) functions
Question 9.
_________ is an example of programming language.
a) C b) C++
c) Python
d) All the above
Answer:
d) All the above
Question 10.
Which one of the following has only high-level details?
(a) Flow chart
(b) Algorithm
(c) Programs
(d) Pseudocode
Answer:
(b) Algorithm
Question 11.
_________ must obey the grammar of the programming language exactly.
a) programs
b) pseudo-code
c) flow charts
d) None of these
Answer:
a) programs
Question 12.
Which one of the following notations will be executed by computers?
(a) Flow chart
(b) Pseudocode
(c) Programming languages
(d) Compiler
Answer:
(c) Programming languages
Question 13.
There is a _________ which translates the program into instructions executable by the computer.
a) translator
b) convertor
c) transcriptor
d) None of these
Answer:
a) translator
Question 14.
Which one of the following algorithmic notations is used for giving visual intuition of control flow?
(a) Flow chart
(b) Programming languages
(c) Pseudocode
(d) Compiler
Answer:
(a) Flow chart
Question 15.
_________ uses the same building blocks as programs, such as variables and control flow.
a) programs
b) pseudo-code
c) flow charts
d) None of these
Answer:
b) pseudo-code
Question 16.
Identify the statement which is wrong ……………….
(a) Programs must obey the grammar of the Programming language exactly.
(b) The punctuations in Programming language must be exactly.
(c) The Programming language is informal.
(d) Translator translates the programs into instructions.
Answer:
(c) The Programming language is informal.
Question 17.
_________ is the most widely used notation to represent algorithms.
a) programs
b) pseudo-code
c) flow charts
d) None of these
Answer:
b) pseudo-code
Question 18.
Identify the correct statement from the following?
(a) Pseudocode can be executed by the computer directly.
(b) Pseudocode cannot be executed by the computer directly.
(c) Algorithm cannot be expressed in Pseudocode
(d) Algorithm are written only for python language
Answer:
(b) Pseudocode cannot be executed by the computer directly.
Question 19.
In flowcharts, _________ boxes represent simple statements.
a) arrows
b) diamond-shaped
c) rectangular shaped
d) None of these
Answer:
c) rectangular shaped
Question 20.
Identify the correct statements.
(i) Pseudocode uses natural English for statements and conditions.
(ii) Pseudocode notation is a formal one.
(iii) There is no need to follow the rules of the Programming language grammar
(iv) It must be rigorous and correct.
(a) (i) (ii) (iii)
(b) (ii) (iii) (iv)
(c) (i) (iii) (iv)
(d) (i) (ii) (iii) (iv)
Answer:
(c) (i) (iii) (iv)
Question 21.
In flowcharts, _________ describe how the control flows during the execution of the algorithm.
a) arrows
b) diamond-shaped
c) rectangular shaped
d) None of these
Answer:
a) arrows
Question 22.
Find the correct flow chart diagram from the following.
Answer:
Question 23.
In flowchart,_________ boxes represent inputs given and outputs produced.
a) arrows
b) diamond shaped
c) rectangular shaped
d) Parallelogram
Answer:
d) Parallelogram
Question 24.
The symbol used for representing the box to be executed next is ………………..
(a) ⇒
(b) ⇓
(c) ↓
(d) ++
Answer:
(c) ↓
Question 25.
_________ is a disadvantage of a flowchart.
a) Flowcharts are less compact than the representation of algorithms in a programming language or pseudo code.
b) They obscure the basic hierarchical structure of the algorithms.
c) Alternative statements and loops are disciplined control flow structures.
d) All the above
Answer:
d) All the above
Question 26.
In the flow chart, rectangular boxes represent………………..
(a) statements
(b) condition
(c) Input
(d) End
Answer:
(a) statements
Question 27.
Statements may be composed of other statements, leading to a _________ structure
of algorithms.
a) bottom-up
b) top-down
c) random
d) hierarchical
Answer:
d) hierarchical
Question 28.
A collection of boxes containing statements and conditions connected by the arrow are ………………..
(a) compiler
(b) Flow chart
(c) Pseudocode
(d) Algorithm
Answer:
(b) Flow chart
Question 29.
Match the following:
(a) (i) -4 (ii) 0 – 1 (iii) – 2 (iv) – 3
(b) (i) – 1 (ii) – 2 (iii) – 3 (iv) – 4
(c) (i) – 4 (ii) – 2 (iii) – 1 (iv) – 3
(d) (i) – 3 (ii) – 2 (iii) – 1 (iv) – 4
Answer:
(a) (i) -4 (ii) 0 – 1 (iii) – 2 (iv) – 3
Question 30.
There are __________ important control flow statements.
a) four
b) three
c) two
d) no
Answer:
b) three
Question 31.
Statements composed of other statements are known as:
(a) Simple Statements
(b) Compound Statements
(c) Conditional
(d) Control flow
Answer:
(b) Compound Statements
Question 32.
A __________ is a phrase that describes a test of the state.
a) condition
b) loop
c) structure
d) None of these
Answer:
a) condition
Question 33.
Which one of the following statements is used to alter the normal flow of control of the program?
(a) Assignments
(b) Control flow
(c) Compound
(d) both b & c
Answer:
(d) both b & c
Question 34.
In case analysis, the cases are __________ .
a) exhaustive
b) disjoint
c) A or B
d) none of these
Answer:
c) A or B
Question 35.
Alternative statements analyze the problem into ……………….. cases.
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(a) 2
Question 36.
The iterative statement is commonly known as a __________
a) loop
b) block
c) sequential
d) None of these
Answer:
a) loop
Question 37.
If sC is a ……………….. statement.
(a) Conditional
(b) Alternative
(c) Case Analysis
(d) Iterative
Answer:
(a) Conditional
Question 38.
__________ involves breaking down a problem into smaller and more manageable problems.
a) Composition
b) Decomposition
c) Eliminating
d) None of these
Answer:
b) Decomposition
Question 39.
The iterative statement is commonly known as a ………………..
(a) loop
(b) Case Analysis
(c) Alternative
(d) Conditional
Answer:
(a) loop
Question 40.
We can abstract the subproblems as__________
a) functions
b) arrays
c) structures
d) None of these
Answer:
a) functions
PART – 2
II. Short Answers
Question 1.
What is a Programming Language?
Answer:
- A programming language is a notation for expressing algorithms to be executed by computers.
- Programs must obey the grammar of the programming language exactly. Ex. C, C++, python.
Question 2.
Write about pseudo code.
Answer:
Pseudocode is a notation similar to programming languages. Algorithms expressed in pseudo-code are not intended to be executed by computers, but for communication among people.
Question 3.
What is a Flow chart?
Answer:
A flow chart is a diagrammatic notation for representing algorithms. A flow chart is a collection of boxes containing statements and conditions which are connected by arrows showing the order in which the boxes are to be executed.
Question 4.
List some of the programming languages.
Answer:
The following are some of the programming languages.
- C
- C++
- Python
- Java
Question 5.
What is meant by Decomposition?
Answer:
Decomposition is one of the elementary problem-solving techniques. An algorithm may be broken into parts, expressing only high-level details. Then, each part may be refined into smaller parts, expressing finer details or each part may be abstracted as a function.
Question 6.
What are the benefits of pseudocode?
Answer:
- This notation is not formal nor exact.
- It uses the same building blocks as programs, such as variables and control flow.
- It allows the use of natural English for statements and conditions.
- there is no need to follow the rules of the grammar of a programming language.
Question 7.
Write the algorithm specification to find a minimum of 2 numbers.
Answer:
Minimum (a, b)
– – inputs : a, b
– – outputs : result = a >1 b
Question 8.
Draw the flowchart for alternative control flow.
Answer:
PART – 3
III. Explain in Brief
Question 1.
Draw the diagram flowchart for integer division.
Answer:
Question 2.
Explain the conditional statement.
Answer:
Conditional statement: Sometimes we need to execute a statement only if a condition is true and do nothing if the condition is false. This is equivalent to the alternative statement in which the else clause is empty. This variant of the alternative statement is called a conditional statement. If C is a condition and S is a statement, then
is a statement, called a conditional statement, that describes the following action:
- Test whether C is true or false.
- If C is true then do S; otherwise do nothing.
The conditional control flow is depicted in the flowchart.
Question 3.
Write an algorithm for finding the minimum of two numbers.
Answer:
Algorithm minimum can be defined as
i) minimum(a, b)
ii) – – a, b
iii) if a < b
iv) result: = a
v) else
vi) result = b
vii) — result = a ↓ b.
Question 4.
Draw various symbols used in the flowchart with their usage.
Answer:
Question 5.
Write an Algorithm to find a minimum of 2 numbers.
Answer:
Question 6.
Answer:
Question 7.
Explain the Refinement process.
Answer:
Each subproblem can be expanded into more detailed steps. Each step can be further expanded to still finer steps, and so on. This is known as refinement.
We can also abstract the subproblem. We specify each subproblem by its input property and the input-output relation. While solving the main problem, we only need to know the specification of the subproblems. We do not need to know how the subproblems are solved.
PART – 4
IV. Explain in Detail
Question 1.
Write the disadvantages of flowcharts.
Answer:
Disadvantages of flowcharts:
- Flowcharts are less compact than the representation of algorithms in a programming language or pseudo code.
- They obscure the basic hierarchical structure of the algorithms.
- Alternative statements and loops are disciplined control flow structures.
Question 2.
Explain the sequential statement in detail with the diagram.
Answer:
A sequential statement is composed of a sequence of statements. The statements in the sequence are executed one after another, in the same order as they are written in the algorithm, and the control flow is said to be sequential. Let S1 and S2 be statements. A sequential statement composed of S1 and S2 is written as
S1
S2
In order to execute the sequential statement, first, do S1 and then do S2. The sequential statement given above can be represented in a flowchart. The arrow from S1 to S2 indicates that S1 is
Let the input property be P, and the input-output relation be Q, for a problem. If statement S solves the problem, it is written as
- – – p
- S
- – – Q
If we decompose the problem into two components, we need to compose S as a sequence of two statements S1 and S2 such that the input-output relation of S1, say R, is the input property of S2.
- – – P
- S1
- – – R
- S2
- – – Q
Question 3.
Explain Case analysis with suitable examples.
Answer:
Case analysis
An alternative statement analyses the problem into two cases. The case analysis statement generalizes it to multiple cases.
Case analysis splits the problem into an exhaustive set of disjoint cases. For each case, the problem is solved independently.
If C1, C2, and C3 are conditions, and S1, S2, S3, and S4 are statements, a 4-case analysis statement has the form,
case C1
S1
case C2
S2
case C3
S3
Else
S4
The conditions C1, C2, and C3 are evaluated in turn. For the first condition that evaluates to true, the corresponding statement is executed, and the case analysis statement ends. If none of the conditions evaluates to true, then the default case S4 is executed.
- The cases are exhaustive: at least one of the cases is true. If all conditions are false, the default case is true.
- The cases are disjoint: only one of the cases is true. Though it is possible for more than one condition to be true, the case analysis always executes only one case, the first one that is true. If the three conditions are disjoint, then the four cases are (1) C1, (2) C2, (3) C3, (4) (not C1), and (not C2) and (not C3).
Question 4.
What is a function? Explain in detail.
Answer:
After an algorithmic problem is decomposed into subproblems, we can abstract the subproblems as functions. A function is like a sub-algorithm. Similar to an algorithm, a function is specified by the input property and the desired input-output relation.
To use a function in the main algorithm, the user needs to know only the specification of the function – the function name, the input property, and the input-output relation. The user must ensure that the inputs passed to the function will satisfy the specified property and can assume that the outputs from the function satisfy the input-output relation. Thus, users of the function need only to know what the function does, and not how it is done by the function. The function can be used a “black box” in solving other problems.
Ultimately, someone implements the function using an algorithm. However, users of the function need not know about the algorithm used to implement the function. It is hidden from the users. There is no need for the users to know how the function is implemented in order to use it.
An algorithm used to implement a function may maintain its own variables. These variables are local to the function in the sense that they are not visible to the user of the function. Consequently, the user has fewer variables to maintain in the main algorithm, reducing the clutter of the main algorithm.
Question 5.
Draw the flowchart for Eat breakfast.
Answer:
Question 6.
Explain the Alternative statement.
Answer:
Alternative statement:
A condition is a phrase that describes a test of the state. If C is a condition and both S1 and S2 are statements, then
is a statement, called an alternative statement, that describes the following action:
- Test whether C is true or false.
- If C is true, then do S1; otherwise do S2.
In pseudo-code, the two alternatives S1 and S2 are indicated by indenting them from the keywords if and else, respectively. Alternative control flow is depicted in the flowchart. Condition C has two outgoing arrows, labeled true and false. The true arrow points to the S1 box. The false arrow points to the S2 box. Arrows out of S1 and S2 point to the same box, the box after the alternative statement.
Conditional statement:
Sometimes we need to execute a statement only if a condition is true and do nothing if the condition is false. This is equivalent to the alternative statement in which the else clause is empty. This variant of the alternative statement is called a conditional statement.
If C is a condition and S is a statement, then
- Test whether C is true or false.
- If C is true then do S; otherwise do nothing.
The conditional control flow is depicted in the flowchart.
Question 7.
Explain various symbols in the Flow chart.
Answer:
A flowchart is a diagrammatic notation for representing algorithms. They show the control flow of algorithms using diagrams in a visual manner. In flowcharts, rectangular boxes represent simple statements, diamond-shaped boxes represent conditions, and arrows describe how the control flows during the execution of the algorithm. A flowchart is a collection of boxes containing statements and conditions which are connected by arrows showing the order in which the boxes are to be executed.
- A statement is contained in a rectangular box with a single outgoing arrow, which points to the box to be executed next.
- A condition is contained in a diamond-shaped box with two outgoing arrows, labeled true and false. The true arrow points to the box to be executed next if the condition is true, and the false arrow points to the box to be executed next if the condition is false.
- Parallelogram boxes represent inputs given and outputs produced.
- Special boxes marked Start and the End is used to indicate the start and the end of execution:
The flowchart of an algorithm to compute the quotient and remainder after dividing an integer A by another integer B is shown below, illustrating the different boxes such as input, output, condition, and assignment, and the control flow between the boxes.
Flowcharts also have disadvantages.
- Flowcharts are less compact than the representation of algorithms in a programming language or pseudo code.
- They obscure the basic hierarchical structure of the algorithms.
- Alternative statements and loops are disciplined control flow structures.
- Flowcharts do not restrict us to disciplined control flow structures.