0% found this document useful (0 votes)
38 views2 pages

Program Development by Step

The document discusses program development through step-wise refinement. It states that program construction consists of breaking tasks into subtasks at each refinement step, with parallel refinement of program and data descriptions. This modular approach determines how easily a program can be adapted to changes. During refinement, a natural problem notation should be used as long as possible before transitioning to the implementation language. Each refinement requires design decisions based on criteria like efficiency. Students must learn to evaluate solutions and reconsider decisions through this process of step-wise refinement.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

Program Development by Step

The document discusses program development through step-wise refinement. It states that program construction consists of breaking tasks into subtasks at each refinement step, with parallel refinement of program and data descriptions. This modular approach determines how easily a program can be adapted to changes. During refinement, a natural problem notation should be used as long as possible before transitioning to the implementation language. Each refinement requires design decisions based on criteria like efficiency. Students must learn to evaluate solutions and reconsider decisions through this process of step-wise refinement.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Program Development by Step-wise Refinement

• Program construction consists of a sequence of refinement steps. In each step a given task is
broken up into a number of suhtasks. Each refinement in the description of a task may be
accompanied by a refinement of the description of the data which constitute the means of
communication between the subtasks. Refinement of the description of program and data
structures should proceed in parallel.
• The degree of modularity obtained in this way will determine the ease or difficulty with which a
program can be adapted to changes or extensions of the purpose or changes in the environment
(language, computer) in which it is executed.
• During the process of stepwise refinement, a notation which is natural to the problem in hand
should be used as long as possible. The direction in which the notation develops during the
process of refinement is determined by the language in which the program must ultimately be
specified, i.e. with which the notation ultimately becomes identical. This language should
therefore allow us to express as naturally and clearly as possible the structure of program and data
which emerge during the design process. At the same time, it must give guidance in the
refinement process by exhibiting those basic features and structuring principles which are natural
to the machine by which programs are supposed to be executed. It is remarkable that it would be
difficult to find a language that would meet these important requirements to a lesser degree that
the one language still used most widely in teaching programming: Fortran.
• Each refinement implies a number of design decisions based upon a set of design criteria. Among
these criteria are efficiency, storage economy, clarity, and regularity of structure. Students must
be taught to be conscious of the involved decisions and to critically examine and to reject
solutions, sometimes even if they are correct as far as the result is concerned; they must learn to
weigh the various aspects of design alternatives in the light of these criteria. In particular, they
must be taught to revoke earlier decisions, and to back up, if necessary even to the top. Relatively
short sample problems will often suffice to illustrate this important point; it is not necessary to
construct an operating system for this purpose.
• The detailed elaborations on the development of even a short program form a long story,
indicating that careful programming is not a trivial subject. If this paper has helped to dispel the
widespread belief that programming is easy as long as the programming language is powerful
enough and the available computer is fast enough, then it has achieved one of its purposes.

Sort The given N Numbers

N enter no of elements8 12 5 61 60 50 1 70 81
enter the elements
5 12
60 61
5 12 60 61
1 50
70 81
1 50 70 81

#include<iostream>
#include<conio.h>
using namespace std;
void mergesort(int *,int,int);
void merge(int *,int,int,int);
int a[20],i,n,b[20];

main()
{
cout <<"\n enter no of elements";
cin >> n;
cout <<"enter the elements";
for(i=0;i<n;i++)
cin >> a[i];
mergesort(a,0,n-1);
cout <<" numbers after sort";
for(i=0;i<n;i++)
cout << a[i] << " ";
getch();
}

void mergesort(int a[],int i,int j)


{
int mid;
if(i<j)
{
mid=(i+j)/2;
mergesort(a,i,mid);
mergesort(a,mid+1,j);
merge(a,i,mid,j);
}
}
void merge(int a[],int low,int mid ,int high)
{
int h,i,j,k;
h=low;
i=low;
j=mid+1;
while(h<=mid && j<=high)
{
if(a[h]<=a[j])
b[i]=a[h++];
else
b[i]=a[j++];
i++;
}

if( h > mid)


for(k=j;k<=high;k++)
b[i++]=a[k];
else
for(k=h;k<=mid;k++)
b[i++]=a[k];

cout <<"\n";
for(k=low;k<=high;k++)
{ a[k]=b[k];
cout << a[k] <<" ";
}

You might also like