Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
913 views
in Specification and Abstraction by (49.1k points)
closed by

Explain specification.

1 Answer

+1 vote
by (54.8k points)
selected by
 
Best answer

Specification:

To solve a problem, first we must state the problem clearly and precisely. A problem is specified by the given input and the desired output. To design an algorithm for solving a problem, we should know the properties of the given input and the properties of the desired output. The goal of the algorithm is to establish the relation between the input and the desired output.

An algorithm is specified by the properties of the given input and the relation between the input and the desired output. In simple words, specification of an algorithm is the desired input – output relation. The inputs and outputs are passed between an algorithm and the user through variables. The values of the variables when the algorithm starts is known as the initial state, and the values of the variables when the algorithm finishes is known as the final state.

Let P be the required property of the inputs and Q the property of the desired outputs. Then the algorithm S is specified as

1. algorithm name (inputs)

2. – – inputs : P 

3. – -outputs: Q

This specification means that if the algorithm starts with inputs satisfying P, then it will finish with the outputs satisfying Q. A double dash – indicates that the rest of the line is a comment. Comments are statements which are used to annotate a program for the human readers and not executed by the computer. Comments at crucial points of flow are useful, and even necessary, to understand the algorithm. In our algorithmic notation, we use double dashes (-) to start a comment line. (In C++, a double slash // indicates that the rest of the line is a comment).

Specification format:

We can write the specification in a standard three part format: 

1. The name of the algorithm and the inputs. 

2. Input: the property of the inputs. 

3. Output: the desired input – output relation.

The first part is the name of the algorithm and the inputs. The second part is the property of the inputs. It is written as a comment which starts with – inputs: The third part is the desired input – output relation. It is written as a comment which starts with – outputs:. The input and output can be written using English and mathematical notation.

Specification as contract:

Specification of an algorithm serves as a contract between the designer of the algorithm and the users of the algorithm, because it defines the rights and responsibilities of the designer and the user. Ensuring that the inputs satisfy the required properties is the responsibility of the user, but the right of the designer. The desired input-output relation is the responsibility of the designer and the right of the user. Importantly, if the user fails to satisfy the properties of the inputs, the designer is free from his obligation to satisfy the desired input – output relation.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...