Current Affairs updated daily
KalviGavaniKalviGavani

Specification and Abstraction Exercise Solutions | KalviGavani

TN Class 11 CS Specification and Abstraction solutions: problem specification, decomposition, abstraction with worked examples and exam tips.

Updated 15 June 202627 min read

Exercise Solutions Available

Step-by-step answers for all textbook questions in this chapter

View Solutions →

Specification and Abstraction — Exercise Solutions

1. How to Use This Page

This page provides complete, exam-focused solutions for the Specification and Abstraction chapter from the TN State Board Class 11 Computer Science textbook (Samacheer Kalvi).

Tips for best results:

  • Read the Key Concepts section first for a quick refresher before reviewing answers.
  • Try each question on your own before reading the solution.
  • Pay attention to the explanations — they contain the reasoning examiners look for.
  • Use the Exam Checklist at the end for last-minute revision.

2. Key Concepts (Quick Recap)

2.1 Problem Specification

A specification is a precise, unambiguous description of what a function or program should do. It defines:

ComponentDescriptionExample
InputWhat the function receivesA list of integers
OutputWhat the function producesThe maximum integer
Pre-conditionCondition that must hold before executionList is non-empty
Post-conditionCondition that must hold after executionOutput equals the largest element

Example — Specification of a maximum function:

# Specification: find_max
# Input:  A non-empty list of integers L
# Output: An integer m such that m is an element of L
#         and for every element x in L, m >= x
# Pre-condition: L is non-empty
# Post-condition: m is the maximum value in L

def find_max(L):
    m = L[0]
    for x in L:
        if x > m:
            m = x
    return m

2.2 Abstraction

Abstraction is the process of hiding unnecessary implementation details and exposing only what is needed to use a function or module.

TypeWhat It HidesWhat It Exposes
Procedural AbstractionHow a function works internallyFunction name, parameters, return value
Data AbstractionHow data is stored/representedOperations that can be performed on the data

Example — Abstraction in everyday programming:

# You use print() without knowing how it internally
# communicates with the display hardware.
# This is abstraction — you know WHAT it does,
# not HOW it does it.

print("Hello, World!")  # Abstraction at work

2.3 Decomposition

Decomposition (also called stepwise refinement) is the process of breaking a complex problem into smaller, more manageable sub-problems.

# Problem: Calculate the average of squares of even numbers in a list
# Decomposed into sub-problems:
#   1. Filter even numbers from the list
#   2. Square each filtered number
#   3. Calculate the average of the squared values

def is_even(n):
    return n % 2 == 0

def square(n):
    return n * n

def average(numbers):
    return sum(numbers) / len(numbers)

def avg_of_squares_of_evens(lst):
    evens = list(filter(is_even, lst))
    squares = list(map(square, evens))
    return average(squares)

2.4 Algorithmic Notation

Algorithms are expressed using a structured notation that includes:

  • Name: Identifies the algorithm
  • Input: What is given to the algorithm
  • Output: What the algorithm produces
  • Steps: Sequential, conditional, and iterative statements
# Algorithm: Swap two numbers
# Input: Two numbers a and b
# Output: a and b with values exchanged
# Steps:
#   1. temp = a
#   2. a = b
#   3. b = temp

def swap(a, b):
    temp = a
    a = b
    b = temp
    return a, b

2.5 Function Specifications

A function specification consists of:

# Function: area_of_circle
# Input: radius — a positive real number
# Output: area — a positive real number
# Pre-condition: radius > 0
# Post-condition: area = pi * radius * radius

import math
def area_of_circle(radius):
    return math.pi * radius * radius

3. I. Choose the Best Answer (MCQs)

Question 1

Which of the following best defines specification in programming?

(a) The actual code that implements a function (b) A precise description of what a function does, including inputs, outputs, and conditions (c) The hardware requirements for running a program (d) A list of variable names used in a program

Answer(b)
ExplanationSpecification is about what a function does — its inputs, outputs, pre-conditions, and post-conditions — not about how it does it. Option (a) describes implementation, not specification. Option (c) refers to system requirements, and option (d) is just a listing of variables.

Question 2

Abstraction in computer science refers to:

(a) Making programs run faster (b) Hiding implementation details and showing only essential features (c) Writing code without any comments (d) Increasing the number of variables in a program

Answer(b)
ExplanationAbstraction means hiding the internal details (the "how") and exposing only the essential interface (the "what"). For example, when you call sorted(list), you do not need to know whether it uses merge sort, quicksort, or some other algorithm — that is abstraction.

Question 3

Which of the following is an example of procedural abstraction?

(a) Using a class to store data (b) Calling a built-in function like len() without knowing its internal code (c) Declaring a variable as an integer (d) Compiling a Python program

Answer(b)
ExplanationProcedural abstraction hides the details of how a procedure works. When you call len(my_list), you know it returns the number of elements, but you do not see or need to understand the loop or counter that computes it. Option (a) relates to data abstraction, and options (c) and (d) are unrelated concepts.

Question 4

The pre-condition of a function specification refers to:

(a) The output produced by the function (b) The condition that must be true before the function starts executing (c) The loop condition inside the function (d) The return statement of the function

Answer(b)
ExplanationA pre-condition is a requirement that must be satisfied before a function is called. For example, the pre-condition for a square root function might be that the input is non-negative. If the pre-condition is violated, the function's behaviour is not guaranteed.

Question 5

Which of the following correctly distinguishes specification from implementation?

(a) Specification is written in Python; implementation is written in C (b) Specification describes what a function does; implementation describes how it does it (c) Specification includes loops; implementation includes conditions (d) There is no difference between them

Answer(b)
ExplanationThe fundamental distinction is: specification = WHAT (inputs, outputs, conditions), implementation = HOW (the actual algorithm and code). A function can have one specification but multiple valid implementations. For example, a sorting specification says "return a sorted list," but implementation could use bubble sort, merge sort, or quick sort.

Question 6

Decomposition in problem solving means:

(a) Removing unnecessary parts of a program (b) Breaking a complex problem into smaller, manageable sub-problems (c) Combining multiple programs into one (d) Writing code in a single function

Answer(b)
ExplanationDecomposition (also called stepwise refinement or top-down design) divides a large, complex problem into smaller sub-problems. Each sub-problem can be solved independently, tested separately, and then combined. This makes the overall solution easier to develop, understand, and debug.

Question 7

In a function specification, the post-condition describes:

(a) The condition that must hold before the function is called (b) What the function guarantees about its output after execution (c) The loop termination condition (d) The variable declarations inside the function

Answer(b)
ExplanationThe post-condition describes the state of affairs after the function completes execution. It specifies what relationship holds between the inputs and outputs. For example, for a sort function, the post-condition would state: "the output list contains the same elements as the input, arranged in non-decreasing order."

Question 8

Which of the following is NOT a benefit of abstraction?

(a) Reduces complexity for the user of a module (b) Allows implementation changes without affecting the interface (c) Makes the program execute faster (d) Enables modular programming

Answer(c)
ExplanationAbstraction does not inherently make programs run faster. Its benefits are in reducing complexity, enabling modularity, and allowing implementation changes without breaking the interface. Performance depends on the actual implementation, not on the abstraction layer.

Question 9

Consider the specification: "Given a non-empty list of integers, return the smallest element." Which of the following is the pre-condition?

(a) The output is the smallest integer (b) The list contains at least one element (c) The list contains only positive integers (d) The function uses a comparison operator

Answer(b)
ExplanationThe pre-condition states what must be true before the function runs. "The list contains at least one element" (i.e., the list is non-empty) is a pre-condition. Option (a) is a post-condition. Options (c) and (d) are not mentioned in the specification.

Question 10

In the context of algorithmic problem solving, which step comes first?

(a) Writing the code (b) Understanding and specifying the problem (c) Testing the program (d) Optimizing the algorithm

Answer(b)
ExplanationThe problem-solving process begins with understanding and specifying the problem clearly. Without a clear specification, you cannot design an algorithm, write code, or test correctly. The typical order is: specification, algorithm design, coding, testing, and then optimization.

4. II. Fill in the Blanks

1. A specification describes what a function does, while an implementation describes how it does it.

2. The process of breaking down a complex problem into smaller sub-problems is called decomposition.

3. The condition that must be satisfied before a function is called is called the pre-condition.

4. The condition that the function guarantees after execution is called the post-condition.

5. Procedural abstraction hides the details of how a function works and exposes only its interface.

6. Data abstraction hides the representation of data and exposes only the operations that can be performed on it.

7. The three parts of a function specification are input, output, and conditions (pre-condition and post-condition).

8. A function's interface defines what data goes in and what data comes out, without revealing the internal process.

9. In stepwise refinement, each sub-problem can be solved independently and then combined to form the complete solution.

10. The principle of abstraction allows a programmer to use a function without knowing its internal code.

11. A post-condition is a guarantee about the relationship between inputs and outputs after a function completes.

12. If a function is supposed to compute the square root of a number, the pre-condition would typically require the input to be non-negative.


5. III. True or False

Statement 1

True or False: Specification includes the exact code used to implement a function.

AnswerFalse.

Correction: Specification describes what a function does (inputs, outputs, conditions), not the actual code or algorithm. The code belongs to implementation.


Statement 2

True or False: Abstraction helps reduce complexity by hiding unnecessary details.

AnswerTrue.
ExplanationAbstraction is specifically designed to reduce complexity. By hiding internal details and exposing only essential features, it allows users to work with high-level interfaces without being overwhelmed by implementation specifics.

Statement 3

True or False: A function can have only one possible implementation for a given specification.

AnswerFalse.

Correction: A single specification can have multiple valid implementations. For example, a sorting specification can be implemented using bubble sort, merge sort, quick sort, or insertion sort — all producing the same result but using different algorithms.


Statement 4

True or False: Decomposition is also known as stepwise refinement.

AnswerTrue.
ExplanationDecomposition and stepwise refinement refer to the same concept — breaking a complex problem into smaller, manageable sub-problems, solving each one, and combining them for the complete solution.

Statement 5

True or False: The pre-condition of a function is checked by the function itself during execution.

AnswerFalse.

Correction: A pre-condition is an assumption or requirement that the caller must satisfy before calling the function. It is not necessarily checked by the function internally. It is the responsibility of the caller to ensure pre-conditions are met, though some functions may validate inputs as a defensive measure.


Statement 6

True or False: Data abstraction hides how data is stored and only shows what operations can be performed on the data.

AnswerTrue.
ExplanationData abstraction is the principle of hiding the internal representation of data. The user only knows which operations are available (like insert, delete, search), not how the data structure is organized in memory.

6. IV. Match the Following

Match the items in Column A with the correct items in Column B.

#Column A#Column B
1Specification(a)Breaking a problem into sub-problems
2Abstraction(b)Condition that must hold after execution
3Pre-condition(c)Describes what a function does
4Post-condition(d)Hiding implementation details
5Decomposition(e)Condition that must hold before execution
6Procedural abstraction(f)Hiding how a function works internally
Answer
Column AColumn B
1. Specification(c) Describes what a function does
2. Abstraction(d) Hiding implementation details
3. Pre-condition(e) Condition that must hold before execution
4. Post-condition(b) Condition that must hold after execution
5. Decomposition(a) Breaking a problem into sub-problems
6. Procedural abstraction(f) Hiding how a function works internally

7. V. Answer Briefly (2-Mark Questions)

Question 1

What is specification? Give an example.

Answer

Specification is a precise description of what a function or program does, including its inputs, outputs, and conditions, without describing how it is implemented.

Example:

# Specification: is_palindrome
# Input:  A string s
# Output: True if s reads the same forwards and backwards, False otherwise
# Pre-condition: s is a string
# Post-condition: Output is True if and only if s is a palindrome

The specification states the input, output, and conditions clearly, without revealing whether the function compares characters, reverses the string, or uses any other technique internally.


Question 2

What is abstraction? Why is it important?

Answer

Abstraction is the process of hiding unnecessary implementation details and exposing only the essential features needed to use a function or module.

Importance:

  • Reduces complexity: Users can work with a simple interface without understanding internal details.
  • Enables modularity: Different modules can be developed independently.
  • Facilitates maintenance: Implementation can be changed without affecting users of the function.
  • Promotes reuse: Well-abstracted functions can be reused in different programs.

For example, when we use math.sqrt(25), we get the result 5.0 without needing to know the Newton-Raphson method or any other algorithm used internally.


Question 3

Differentiate between pre-condition and post-condition.

Answer
AspectPre-conditionPost-condition
WhenMust be true before the function is calledGuaranteed to be true after the function finishes
PurposeStates what the function requires from the callerStates what the function guarantees to the caller
Example"Input list must be non-empty""Output is the maximum element of the list"
ResponsibilityCaller must ensure it is satisfiedThe function ensures it on completion

Question 4

What is decomposition? Give a simple example.

Answer

Decomposition is the process of breaking a complex problem into smaller, more manageable sub-problems. Each sub-problem can be solved independently and then combined to solve the original problem.

Example:

To compute the average score of students who passed an exam:

1. Sub-problem 1: Filter students who scored above the pass mark. 2. Sub-problem 2: Sum the scores of the filtered students. 3. Sub-problem 3: Divide the sum by the count of filtered students.

def passed_students(scores, pass_mark):
    return [s for s in scores if s >= pass_mark]

def average(score_list):
    return sum(score_list) / len(score_list)

def avg_passing_score(scores, pass_mark):
    passed = passed_students(scores, pass_mark)
    return average(passed)

Question 5

Distinguish between procedural abstraction and data abstraction.

Answer
AspectProcedural AbstractionData Abstraction
What is hiddenHow a function/procedure works internallyHow data is stored and represented
What is exposedFunction name, parameters, and return valueOperations that can be performed on the data
ExampleUsing sorted() without knowing the sorting algorithmUsing a stack's push/pop without knowing if it uses an array or linked list
FocusActions/operationsData representation

8. VI. Answer in Detail (5-Mark Questions)

Question 1

Explain the concept of specification in detail with examples. Why is specification important in programming?

Answer

Specification is a formal, precise description of what a function or program does. It acts as a contract between the user of a function and its implementer. A complete specification includes:

1. Function name: Identifies the function. 2. Input (parameters): Describes what data the function receives and its type. 3. Output (return value): Describes what the function produces. 4. Pre-condition: The condition that must be true before the function is called. 5. Post-condition: The condition that is guaranteed to be true after the function completes.

Detailed Example — Specification of a factorial function:

# Specification: factorial
# Input:  n — a non-negative integer
# Output: An integer equal to the product of all positive
#         integers from 1 to n
# Pre-condition: n >= 0
# Post-condition: output = 1 * 2 * 3 * ... * n (for n > 0)
#                 output = 1 (for n = 0)

def factorial(n):
    result = 1
    for i in range(1, n + 1):
        result = result * i
    return result

Note that the specification and the implementation are separate. The specification says what the function does, while the code shows how it does it.

Another Example — Specification of a search function:

# Specification: linear_search
# Input:  A list L and a target value v
# Output: Index of v in L if found, -1 otherwise
# Pre-condition: L is a list
# Post-condition: If v is in L, output is the first index
#                 where L[index] == v; otherwise output is -1

def linear_search(L, v):
    for i in range(len(L)):
        if L[i] == v:
            return i
    return -1

Importance of Specification:

1. Clarity: It eliminates ambiguity about what a function should do, ensuring both the implementer and the user have the same understanding.

2. Correctness: By stating pre-conditions and post-conditions explicitly, we can verify whether a function behaves as expected.

3. Modularity: Specifications allow different programmers to work on different parts of a program independently, as long as they agree on the interface.

4. Testing: Specifications provide the basis for writing test cases. Test cases check whether the implementation satisfies the specification.

5. Documentation: Specifications serve as documentation, helping programmers understand how to use a function correctly without reading its source code.

6. Multiple implementations: A clear specification allows the same function to be implemented in different ways (e.g., different sorting algorithms) while guaranteeing the same result.


Question 2

Explain the different types of abstraction with examples. How does abstraction help in writing better programs?

Answer

Abstraction is the process of hiding unnecessary details and exposing only the essential features. In computer science, there are two main types:

1. Procedural Abstraction:
Answer

Procedural abstraction hides the details of how a function or procedure accomplishes its task. The user only needs to know the function's name, its parameters, and what it returns — not the algorithm inside.

# Example: Python's built-in sort
numbers = [5, 2, 8, 1, 9]
numbers.sort()  # We know it sorts the list
# We don't need to know whether it uses
# Timsort, Merge Sort, or Quick Sort

# Custom example: A function to check primality
# The user just calls: is_prime(17) -> True
# They don't need to know the internal algorithm
def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True
2. Data Abstraction:
Answer

Data abstraction hides the representation of data and only exposes the operations that can be performed on it. The user interacts with data through a set of operations without knowing the underlying storage structure.

# Example: A Stack data structure with data abstraction
# The user only knows: push, pop, peek, is_empty
# They don't know if it uses a list, linked list, or array

class Stack:
    def __init__(self):
        self._data = []  # Hidden representation

    def push(self, item):
        self._data.append(item)

    def pop(self):
        if not self.is_empty():
            return self._data.pop()

    def peek(self):
        if not self.is_empty():
            return self._data[-1]

    def is_empty(self):
        return len(self._data) == 0

How Abstraction Helps in Writing Better Programs:

1. Reduces complexity: Programmers can focus on high-level logic without being burdened by low-level details. For example, using print() is simpler than managing display buffers.

2. Enables modularity: Modules communicate through well-defined abstract interfaces, making programs easier to organize and maintain.

3. Facilitates maintenance: If the implementation changes (e.g., optimizing a sorting algorithm), the rest of the program remains unaffected because the interface stays the same.

4. Promotes code reuse: Abstracted functions and classes can be reused across different projects. For instance, a well-specified Stack class can be used in any program that needs stack operations.

5. Improves collaboration: Team members can work on different modules simultaneously, agreeing on specifications without needing to understand each other's implementations.

6. Supports incremental development: Programs can be built step by step, with each level of abstraction adding more functionality while hiding complexity.


Question 3

Explain decomposition with a detailed example. What are the advantages of decomposition in problem solving?

Answer

Decomposition (also called stepwise refinement or top-down design) is the process of breaking a complex problem into smaller, more manageable sub-problems. Each sub-problem can be solved, tested, and debugged independently, and the solutions are then combined to solve the original problem.

Detailed Example — Student Grade Management System:

Suppose we need to build a program that:

  • Takes student marks in five subjects
  • Calculates the total and average
  • Determines the grade based on the average
  • Displays a report card

Step 1: Identify sub-problems (Decomposition)

Original Problem: Generate Student Report Card | |-- Sub-problem 1: Input student marks |-- Sub-problem 2: Calculate total marks |-- Sub-problem 3: Calculate average |-- Sub-problem 4: Determine grade from average |-- Sub-problem 5: Display report card

Step 2: Solve each sub-problem independently

# Sub-problem 1: Input student marks
def input_marks():
    marks = []
    subjects = ["Tamil", "English", "Maths", "Science", "Social Science"]
    for subject in subjects:
        m = int(input(f"Enter marks for {subject}: "))
        marks.append(m)
    return marks

# Sub-problem 2: Calculate total marks
def calculate_total(marks):
    return sum(marks)

# Sub-problem 3: Calculate average
def calculate_average(total, count):
    return total / count

# Sub-problem 4: Determine grade
def determine_grade(average):
    if average >= 90:
        return "A+"
    elif average >= 80:
        return "A"
    elif average >= 70:
        return "B+"
    elif average >= 60:
        return "B"
    elif average >= 50:
        return "C"
    else:
        return "F"

# Sub-problem 5: Display report card
def display_report(marks, total, average, grade):
    subjects = ["Tamil", "English", "Maths", "Science", "Social Science"]
    print("--- Report Card ---")
    for subject, mark in zip(subjects, marks):
        print(f"{subject}: {mark}")
    print(f"Total: {total}")
    print(f"Average: {average:.2f}")
    print(f"Grade: {grade}")

Step 3: Combine sub-problems

# Main function combining all sub-problems
def generate_report_card():
    marks = input_marks()
    total = calculate_total(marks)
    average = calculate_average(total, len(marks))
    grade = determine_grade(average)
    display_report(marks, total, average, grade)

generate_report_card()

Advantages of Decomposition:

1. Manageability: Large, complex problems become a set of smaller, solvable problems. Each sub-problem is easier to understand and solve.

2. Independent development: Different programmers can work on different sub-problems simultaneously, speeding up development.

3. Easier testing: Each sub-problem can be tested independently. For example, we can test determine_grade() with various average values without needing the full program.

4. Easier debugging: When an error occurs, it is easier to locate which sub-problem caused it, rather than searching through one large monolithic program.

5. Reusability: Solved sub-problems can be reused in other programs. For instance, calculate_average() can be used in any program that needs an average calculation.

6. Better understanding: Decomposing a problem helps programmers understand the problem better. The process of identifying sub-problems clarifies the overall structure and requirements.

7. Maintainability: When changes are needed, only the relevant sub-problem needs modification, without affecting others. For example, changing the grading scale only requires modifying determine_grade().


Question 4

Explain the relationship between specification, abstraction, and decomposition with suitable examples.

Answer

Specification, abstraction, and decomposition are three fundamental concepts in algorithmic problem solving that work together to produce well-structured programs.

Their Relationship:

1. Decomposition breaks a complex problem into smaller sub-problems. 2. Specification precisely defines what each sub-problem should do (inputs, outputs, conditions). 3. Abstraction hides the internal details of each sub-problem, exposing only the specification.

Together, they form a disciplined approach to programming:

Complex Problem | v (Decomposition) Sub-problems identified | v (Specification) Each sub-problem precisely defined | v (Abstraction) Details hidden, interfaces exposed | v Well-structured program

Detailed Example — Temperature Conversion System:

Suppose we need a program that converts temperatures between Celsius, Fahrenheit, and Kelvin, and displays a comparison table.

Step 1: Decomposition

Temperature Conversion System |-- Sub-problem 1: Convert Celsius to Fahrenheit |-- Sub-problem 2: Convert Fahrenheit to Celsius |-- Sub-problem 3: Convert Celsius to Kelvin |-- Sub-problem 4: Generate comparison table

Step 2: Specification

# Specification: celsius_to_fahrenheit
# Input: c — a real number representing temperature in Celsius
# Output: A real number representing temperature in Fahrenheit
# Pre-condition: c is a valid real number
# Post-condition: output = (c * 9/5) + 32

# Specification: fahrenheit_to_celsius
# Input: f — a real number representing temperature in Fahrenheit
# Output: A real number representing temperature in Celsius
# Pre-condition: f is a valid real number
# Post-condition: output = (f - 32) * 5/9

# Specification: celsius_to_kelvin
# Input: c — a real number representing temperature in Celsius
# Output: A real number representing temperature in Kelvin
# Pre-condition: c >= -273.15 (absolute zero)
# Post-condition: output = c + 273.15

Step 3: Abstraction — Implementation Hidden

# Users of these functions only need to know the specifications.
# They don't need to know the formula or how it's computed.

temp_f = celsius_to_fahrenheit(100)   # Returns 212.0
temp_c = fahrenheit_to_celsius(212)   # Returns 100.0
temp_k = celsius_to_kelvin(0)         # Returns 273.15

The user calls celsius_to_fahrenheit(100) and gets 212.0. They do not need to know whether the implementation uses (c 9/5) + 32 or (c 1.8) + 32 — that is hidden by abstraction.

How They Complement Each Other:

ConceptRoleBenefit
DecompositionBreaks problem into partsMakes complex problems manageable
SpecificationDefines each part preciselyEnsures correctness and clarity
AbstractionHides internal detailsReduces complexity for users

Without decomposition, we would try to solve the entire problem at once, leading to complex, hard-to-manage code. Without specification, we would not have a clear understanding of what each part should do. Without abstraction, users of each part would need to understand all the internal details, making the program harder to use and maintain.


9. Common Mistakes to Avoid

1. Confusing specification with implementation: Specification describes WHAT a function does; implementation describes HOW it does it. Do not include code or algorithm details in a specification. For example, saying "uses a for loop to find the maximum" is implementation, not specification.

2. Omitting pre-conditions: Always state the pre-conditions clearly. If your function assumes the input list is non-empty, state it explicitly. Missing pre-conditions can lead to incorrect results or runtime errors.

3. Confusing pre-condition and post-condition: Remember — pre-condition is what must be true BEFORE the function runs (the caller's responsibility); post-condition is what is guaranteed AFTER the function runs (the function's responsibility).

4. Thinking abstraction makes programs faster: Abstraction is about managing complexity, not improving performance. In some cases, abstraction layers can add a small overhead. The primary benefit is code clarity, modularity, and maintainability.

5. Incomplete decomposition: When decomposing a problem, ensure each sub-problem is well-defined and has clear inputs and outputs. Vague or overlapping sub-problems lead to confusion. Each sub-problem should have a single, clear purpose.

6. Writing specifications that are too vague: A specification like "this function sorts things" is too vague. A proper specification should be precise: "Given a list of integers, returns a new list containing the same elements in non-decreasing order."

7. Forgetting edge cases in specifications: When writing specifications, consider edge cases such as empty lists, zero values, negative numbers, and boundary conditions. For example, specifying that a function finds the "minimum of a list" should include the pre-condition that the list is non-empty.

8. Treating decomposition as just dividing code into functions: Decomposition is not merely about splitting code into functions. It requires thoughtful analysis of the problem to identify logical sub-problems that can be solved independently and then composed correctly.

9. Mixing "what" and "how" in specifications: A specification should never include implementation details like "iterates through the list using a for loop" or "uses recursion." The specification should only describe the relationship between input and output.

10. Ignoring the contract nature of specifications: A specification is a contract. If a caller violates the pre-condition, the function is not obligated to produce the correct result. Students often forget this and try to handle all invalid inputs inside the function rather than clearly stating the pre-condition.


10. Exam Checklist

Before your exam, make sure you can confidently address the following points:

  • [ ] Define specification — a precise description of what a function does (inputs, outputs, conditions)
  • [ ] Define abstraction — hiding implementation details, exposing only essential features
  • [ ] Differentiate specification vs. implementation — specification = WHAT, implementation = HOW
  • [ ] Define decomposition — breaking a complex problem into smaller sub-problems
  • [ ] Explain pre-condition — what must be true before a function is called
  • [ ] Explain post-condition — what is guaranteed after a function completes
  • [ ] Give examples of procedural abstraction — using len(), sorted(), print() without knowing internal code
  • [ ] Give examples of data abstraction — using Stack, Queue, or List operations without knowing internal storage
  • [ ] Distinguish procedural abstraction vs. data abstraction — hiding "how it works" vs. hiding "how data is stored"
  • [ ] Write a complete function specification — including function name, input, output, pre-condition, and post-condition
  • [ ] Decompose a given problem into sub-problems — identify, specify, and combine sub-solutions
  • [ ] Explain why abstraction reduces complexity — users interact with simple interfaces, not internal details
  • [ ] Explain why decomposition aids in testing and debugging — each sub-problem can be tested independently
  • [ ] Describe the relationship between specification, abstraction, and decomposition — how they work together in problem solving
  • [ ] Identify common mistakes — confusing pre/post conditions, mixing "what" and "how," vague specifications
  • [ ] Write Python code examples demonstrating each concept — specifications with comments, decomposed functions, abstracted interfaces

These solutions cover the key topics from the TN State Board Class 11 Computer Science chapter on Specification and Abstraction. Practice writing your own specifications and decomposing problems to build confidence for the exam.

Frequently Asked Questions

Specification is a precise description of what a function or program does, including its inputs, outputs, and conditions, without describing how it is implemented.