Sei sulla pagina 1di 6

1. Explain the structured approach used in program development.

A particular method or family of methods that a software engineer might use to solve a problem is known as a methodology. During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach to program design was based on the following method:

To solve a large problem, break the problem into several pieces and work on each piece separately; to solve each piece, treat it as a new problem that can itself be broken down into smaller problems; Repeat the process with each new piece until each can be solved directly, without further decomposition.

This approach is also called top-down program design. The following is a simple example of the structured programming approach to problem solving. Write a program for a computer to execute to display the average of two numbers entered through a keyboard connected to the computer. The average is to be displayed on a VDU that is also connected to this computer. The top-down solution is arrived at as follows: Top level: Next level: 0. Display average of two numbers entered through keyboard 0.1. Get two numbers through keyboard 0.2. Calculate average of these two numbers 0.3. Display average on VDU

The three steps in next level can now be coded in a programming language such as Pascal. Top-down program design is a useful and often-used approach to problem solving. However, it has limitations:

It focuses almost entirely on producing the instructions necessary to solve a problem. The design of the data structures is an activity that is just as important but is largely outside of the scope of top-down design. It is difficult to reuse work done for other projects. By starting with a particular problem and subdividing it into convenient pieces, top-down program design tends to produce a design that is unique to that problem. Adapting a piece of programming from another project usually involves a lot of effort and time.

Some problems by their very nature do not fit the model that top-down program design is based upon. Their solution cannot be expressed easily in a particular sequence of instructions. When the order in which instructions are to be executed cannot be determined in advance, easily, a different approach is required.

2. What do you mean by documenting a program? Explain its need.


The program documentation is a kind of documentation that gives a comprehensive procedural description of a program. It shows as to how software is written. Program documentation even has the capability to sustain any later maintenance or development of the program. The program documentation describes what exactly a program does by mentioning about the requirements of the input data and the effect of performing a programming task.

Thus, if you want to know what a program is meant to do and how it has to be executed, you should refer to the program documentation. The most common examples would be the instruction manuals for a software product, which is given to the end-user. Thus the instruction manual for a programming language like Java or for understanding a word processor can come under the purview of program documentation. The description languages used are informal and are intended to make life easy for the end-user. ------

There is also another kind of program documentation that is written for the sake of programmers who write the actual software and may have to modify it or use it as a part of another program which they write in the future. While the end-user documentation has a userfriendly language about the software, the program documentation describes things in a language which can befit the programmer. Program documentation includes hard-copy or electronic manuals that enable users, program developers, and operators to interact successful with a program. User documentation normally consists of a user's manual. This manual may provide instructions for running the program. A description of software commands, several useful examples of

applications, and troubleshooting guide to help with difficulties. Program developers include people who design, write, test and maintain programs that is anyone contributing to the softwaredevelopment process.

Developer documentation usually consists of tools that will simplify anydevelopment task. Such tools might include program examples, a description of the design tools incorporated into the product, instructions for debugging and testing, maintain tips and so on. Since developers are highly literate about computers, developer documentation is written at a more technical level than documentation.Developer documentation is also increasingly becoming electronic. Operator documentation includes online and hard-copy manuals that assist machine operators in setting up hardware devices, learning the ins and outs of successful hardware operation, and diagnosing machine malfunctions. Operator documentation is machine dependent and unless one has a good grounding in hardware specifies, it can be difficult to read through.

Internal documentation of programs is very important, not just to you but to the NEXT programmer who will be modifying your program. Outside of academia, most programming consists of fixing bugs or adding features to existing code. The comments you put in your source code files should be written to help other programmers navigate through your code easily in order to find bugs or to determine where to add new features. Thus, it is important to pay attention to how the code is laid out on the screen (indentation matching) and to use meaningful variable names, as well as to write comments that are concise yet clear. Programmer documentation should be concise so the person who reads it doesn't have to spend too much time to find what he or she is looking for. Even though your code will actually be read only by yourself and the instructor, write the comments as if they would be read only by another programmer who needs to modify it. How well you follow this rule will be one of the factors that determines your grade! Object oriented languages such as C++ make us distinguish between two different types of programmers: programmers who define classes and programmers who use classes. A major value of using an object oriented language is that it promotes code

reuse: one person develops a class type and makes it available somehow to other programmers. Other programmers then either reuse the class directly in their application programs or extend the original class definition in some way(s) to tailor it to a particular application. Again, working as a student makes this distinction difficult because you have to play both roles in order to do a complete assignment. Nonetheless, the comments in your code should be written with the type of your realworld audience in mind: When documenting class definitions the comments should focus on making it clear how to use the class and any special provisions you made for extending the definition. When documenting your driver program (the one that tests your class definitions) you should make the structure of the program clear so that, for example, someone would be able to change the user interface or the nature of the tests the program performs. Example of documentation you MUST provide on assignments:
Source file name Author's name : (person who wrote the program originally) Last Modified by: (person who modified program last ) Date last Modified: Program description Main function's variable descriptions Functions PreConditions PostConditions Task of Function Classes Description of class - what it does NOT how. Description of each public member - what/how to use

3. How many values can be held by arrays with dimensions A[0:n], B[-1:n, 1:m], C[-n :0,2]?
A(0:n) = n+1 elements

-1 specifies that the array indexing starts at '-1' up till 'n'. Therefore there can be "n-(-1)+1 = n+2" rows in the array. Each of this row may hold up to m (m-1+1) elements. Therefore B(-1:n 1:m) = (n+2)*(m) elements

Similarly

C(-n:0 2) = (n+1)*(3) elements

4.

Obtain an indexing formula for the element A[i1,i2,i3...in] in an array declared as A[l1:u1,l2:u2, . . . , ln:un] . Assume a column major representation of the array with one word per element and M be the address of A[l1,l2,...,ln]. [To Be Done]

5. Give an algorithm for a single linked circular list which reverses the direction of the links.
Reverser(head) 1.Let temp = head, prev=next=NULL 2.while(temp->Link != NULL) 1.next = temp->Link 2.temp->Link = previous 3. previous = temp 4.temp = next 3.head = temp

Reverse a singly linked list


// // iterative version // Node* ReverseList( Node ** List ) {

Node *temp1 = *List; Node * temp2 = NULL; Node * temp3 = NULL;

while ( temp1 ) { *List = temp1; //set the head to last node temp2= temp1->pNext; // save the next ptr in temp2 temp1->pNext = temp3; // change next to privous temp3 = temp1; temp1 = temp2; }

return *List; } Swap: 1st nodes object with Nth nodes object Swap: 2nd nodes object with (N-1)th nodes object Swap: 3rd nodes object with (N-2)th nodes object

6. Design an algorithm to split a circular list into two circular lists


1) Count the number of nodes in the given circular linked list. 2) Find the midpoint using slow and fast pointers (using tortoise and hare algorithm). After reaching the midpoint, do following a) fast->next = slow->next /*Make second half circular*/ b) start2 = fast->next /* save start pointer for second half*/ c) slow->next = start /* Male first half circular */ d) start1 = start /* save start pointer for first half*/

Potrebbero piacerti anche