Upload
jomon-johny
View
217
Download
0
Embed Size (px)
Citation preview
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 1/63
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 2/63
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 3/63
[3]
iii) Testing of Algorithms
Ans. The ultimate test of an algorithms is that the programs based on the algorithm should run
satisfactorily. Testing a program really involves two phases a)debugging and b)profiling.
Debugging is the process of executing programs with sample data sets to determine if the results obtained
are satisfactory. When unsatisfactory results are generated, suitable changes are made in the program to
get the desired results. On the other hand, profiling or performance measurement is the process ofexecuting a correct program on different data sets to measure the time and space that it takes to compute
the results.
Q.3 What is a linear data structure ? Give examples. Describe how an array is represented.
Ans. A data Structure in which every data element has got exactly two neighbors or two adjacent
elements except two elements having exactly one data element is called a linear data structure.
Array is a finite ordered list of data elements of same type. In order to create an array it required to
reserve adequate number of memory locations. The allocated memory should be contiguous in nature. The
size of the array is finite and fixed up as a constant. Some of the important operations related to arrays are,
Creation() – A[n], Array created(reservation of adequate number of memory locations) memory reserved;
Write(A,i,e) – Updated array with ‘e’ at ith
position;
Compare(I,j,Relational operator) – Boolean;
Read(A,i) – ‘e’ element at ith position;
Search(A,e) – Boolean;
Q.4 Write algorithms to implement the following operations on a stack - create, push, pop.
Ans :
Algorithm: Create
Output: S,Stack created
Method :
Declare S[SIZE] //Array of size=SIZE
Declare and Initialize T=0 //Top Printer to remember the number of elements
Algorithm ends.
Algorithm: Push
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 4/63
[4]
Input : (1) S, stack; (2) e, element to be inserted; (3) SIZE, size of the stack(4) T, the top pointer
Output: (1) S, updated; (2) T, updated
Method:
If(Isfull(S)) then
Print(‘Stack overflow’)
Else
T=T+1;
S[T]=e
If end
Algorithm ends
Algorithm: Pop
Input: (1) S, stack;
Output: (1) S, updated; (2) T, updated; (3) ’e’, element popped
Method:
If(Isempty(S)) then
Print(‘stack is empty’)
Else
e=S[T]
T=T-1;
If end
Algorithm ends
Q.5 What is a first-in-first-out data structure ? Write algorithms to perform the following operations on
it – create, insertion, deletion, for testing overflow and empty conditions.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 5/63
[5]
Ans. A queue is an ordered list in which all insertions take place at one end called the rear end, while all
deletions take place at the other end called the front end. Queue is a linear data structure which works
based on the strategy first-in-first out(FIFO).
Algorithm: Create
Output: Q, Queue created
Method:
Declare Q[SIZE] //Array with size=SIZE
Declare and Initialize F=0,R=0
// Front and Rear pointers to keep track of the front element and the rear element respectively
Algorithm ends
Algorithm: Isempty
Input: Q, Queue
Output: Boolean
Method:
If(F==0)
Return(yes)
Else
Return(no)
If end
Algorithm ends
Algorithm: Isfull
Input: Q, Queue
Output: Boolean
Method:
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 6/63
[6]
If(R==SIZE)
Return(yes)
Else
Return(no)
If end
Algorithm ends
Algorithm: Insertion
Input: (1) Q, Queue; (2)e, element to be inserted; (3)SIZE, size of the Queue;(4)F, the front pointer; (5) R,
the rear pointer
Output: (1) Q, updated; (2) F, updated; (3) R,updated
Method:
If(Isfull(Q)) then
Print(‘overflow’)
Else
R=R+1;
Q[R]=e
If(F==0)
F=1;
If end
Algorithm ends
Algorithm: Deletion
Input: (1) Q, Queue; (2)SIZE, size of the Queue;(3)F, the front pointer; (4) R, the rear pointer
Output: (1) Q, updated; (2) F, updated; (3) R,updated; (4)e, element if deleted;
Method:
If(Isempty(Q)) then
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 7/63
[7]
Print(‘queue is empty’)
Else
e=Q[F]
If(F==R)
F=R=0;
Else
F=F+1;
If end
If end
Algorithm ends
Q.6 What is a graph ? What are the two ways of representing a graph ? Describe with the help of
illustrative examples.
Ans. A graph G=(V,E) consists of a set of objects V={v1 ,v2,. . . .} called vertices, and another set E={e1,e2 . . . }
whose elements are called edges. Each edge ek in E is identified with an unordered pair(v i ,v j ) of vertices.
The vertices vi ,v j associated with edge ek are called the end vertices of ek.
The most common representation of graph is by means of a diagram, in which the vertices are represented
as points and each edge as a line segment joining its end vertices.
A graph that has neither self-loop nor parallel edges are called a simple graph, otherwise it is called general
graph. It should also be noted that, in drawing a graph, it is immaterial whether the lines are drawn
straight or curved, long or short: what is important is the incidence between the edges and vertices.
In the Fig. edge e1 , having some vertex as both its end vertices is called a self-loop. There may be more
than one edge associated with a given pair of vertices, for example e4 and e5 in fig. .Such edges are
referred to as parallel edges.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 8/63
[8]
Q.7 What is a circular queue ? Write algorithms to implement the insertion and deletion operations.
Ans. A circular queue uses the same conventions as that of linear queue. Using Front will always point one
position counterclockwise from the first element in the queue. In order to add an element, it will be
necessary to move rear one position clockwise. Similarly, it will be necessary to move front one position,
clockwise each time a deletion is made.
Algorithm: Insertion
Input: (1) CQ,Circular Queue; (2)e, element to be inserted; (3)SIZE, size of the Circular Queue;(4)F, the front
pointer; (5) R, the rear pointer
Output: (1)C Q, updated; (2) F, updated; (3) R,updated
Method:
If(Isfull(CQ)) then
Print(‘overflow’)
Else
R=R mod SIZE +1;
CQ[R]=e
If(Isempty(CQ))
F=1;
If end
If end
Algorithm ends
Algorithm: Deletion
Input: (1) CQ, Queue; (2)SIZE, size of the CQ;(3)F, the front pointer; (4) R, the rear pointer
Output: (1)CQ, updated; (2) F, updated; (3) R,updated; (4)e, element if deleted;
Method:
If(Isempty(CQ)) then
Print(‘queue is empty’)
Else
e=CQ[F]
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 9/63
[9]
If(F==R)
F=R=0;
Else
F=F mod SIZE +1;
If end
If end
Algorithm ends
Q.8 Write an algorithm to find the roots of a quadratic equation.
Ans.
Algorithm: Quadratic_solver
Input: a, b, c the co-effcients of the Quadratic Equation
Output: The two roots of the Equation
Method:
Disc=((b*b)-(4*a*c))
If (disc=0)
Display ‘roots are real and equal’
r1= -b/2a
r2= -b/2a
display r1
display r2
else
if(disc>0)
display ‘roots are real and distinct’
r1=(-b+sqrt(disc))/2a
r2=(-b+sqrt(disc))/2a
else
display ‘roots are complex’
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 10/63
[10]
display’real part’,b/2a
display ‘imaginary part’ , sqrt(absolute_value_of(disc))
display ‘the two root exists in conjugates’
end_if
Algorithm ends
Q.9 Develop an algorithm to generate all the prime numbers between the given 2 limits.
Ans.
Algorithms: Primarily Testing
Input: n, number, Flag, test condition
Output: flag updated
Method
Flag=o
for( i=2 to n/2 is steps of +1 and flag=0 )
if (n%i=0) //n mod i
Flag=1
end if
end for
if (flag=0)
display ‘Number is prime’
else
Display ‘Number not prime’
end if
Algorithm ends
Assignment: TB (COMPULSORY)
Part A
I. Say whether the following statements are true or false.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 11/63
[11]
1) Definiteness is one of the properties of an algorithm. -----TRUE
2) Graph is a linear data structure. -----FALSE
3) A tree is a connected graph. -----TRUE
4) The data structure used by recursion is stack. -----FALSE
5) Queue works on the strategy “First in First out”. -----TRUE
II. Using suitable word or phrase fill up the blanks in the following sentences:
1) Performance Process is the process of executing a correct program on data sets and measuring the time
and space.
2) Tree is a Connected graph data structure.
3) For a graph with ‘n’ number of nodes the number of edges to form a tree is n-1.
4) “Last in First out” Data structure is referred to as Stack
5) A binary tree of depth ‘K’ has maximum of 2k+1
- 1number of
nodes.
6) A Simple graph is a graph without self loop and parallel edges.
7) The two methods of searching are linear search and binary search.
III. Write brief answers to the following questions:
Q.1 Define algorithm. What are its properties?
Ans. The formal representation of sequence of instructions is called an
Algorithm.
1) Input
2) Output
3) Definiteness
4) Effectiveness
5) Termination.
Q.2 Give atleast four real life examples where we use stack operations
Ans.
(a) The processing of procedure calls and their terminations in computer programming.
(b) Arrangement of Plates on over another. The plate at the bottom of the plate hype is washed and kept
first but, it is used or comes out last.
(d) Chapattis cooked first are placed at the bottom in the Tiffin and the last cooked id at the top in the
Tiffin.
(e) Arrangement of chairs on over another. The chair which is put in first lies last when comes out.
Q.3 Differentiate full and complete binary trees.
Ans. A “complete” binary tree is one which allows sequencing of the nodes and all the previous levels are
maximally accommodated before the next level is accommodated. i.e., the siblings are first accommodated
before the children of any one of them. And a binary tree which is maximally accommodated with all
leaves at the same level is called “full” binary tree. A full binary tree is always complete but complete
binary tree need not be full.
Q.4 What are the demerits of recursion?
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 12/63
[12]
Ans. 1. Many programming languages do not support recursion; hence recursive mathematical function is
implemented using iterative methods.
2. Even though mathematical functions can be easily implemented using recursion it is always at the cost
of execution time and memory space.
3. A recursive procedure can be called from within or outside itself and to ensure its proper functioning it
has to save in some order the return addresses so that, a return to the proper location will result when thereturn to a calling statement is made.
4. The recursive programs needs considerably more storage and will take more time.
PART - B
Q.1(a) What are the characteristics of an algorithm? Describe with an example
Ans.
1) Input
2) Output
3) Definiteness
4) Effectiveness
5) Termination
Q.1(b) Write an algorithm to implement any three operations of a queue
Ans.
Algorithm: Create
Output: Q, Queue created
Method:
Declare Q[SIZE] //Array with size=SIZE
Declare and Initialize F=0,R=0
// Front and Rear pointers to keep track of the front element and the rear element respectively
Algorithm ends
Algorithm: Isempty
Input: Q, Queue
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 13/63
[13]
Output: Boolean
Method:
If(F==0)
Return(yes)
Else
Return(no)
If end
Algorithm ends
Algorithm: Isfull
Input: Q, Queue
Output: Boolean
Method:
If(R==SIZE)
Return(yes)
Else
Return(no)
If end
Algorithm ends
Q.3(b) Design an algorithm to sort the elements using merge sort.
Ans.
Algorithm: MERGESORT
Input: low, high, the lower and upper limits of the list to be sorted
A, the list of elements
Output: A, Sorted list
Method:
If (low<high)
mid¬ (low + high)/2
MERGESORT(low, mid)
MERGESORT (mid, high)MERGE(A, low, mid, high)
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 14/63
[14]
If end
Algorithm ends
Q.4(a) What are preorder, Inorder, postorder traversals of a binary tree?
Ans.
Pre-Order TraversalIn this traversal, the nodes are visited in the order of root, left child and then right child. i.e.,
1. Visit the root node first.
2. Go to the first left sub-tree.
3. After the completion of the left sub-tree, Go to the right sub-tree.
Here, the leaf nodes represent the stopping criteria. We go to the sibling sub-tree after the traversal of a
sub-tree. The pre-order traversal sequence for the binary tree shown in Fig. 6.3 is : A B D E G H C F I J K
In-Order Traversal
In this traversal, the nodes are visited in the order of left child, root and then right child. i.e., the left sub-tree is traversed first, then the root is visited and then the right sub-tree is traversed. Here also, the
leaf nodes denote the stopping criteria. The in-order traversal sequence for the above considered example
(Fig. 6.3) is: D B G E H A F J I K C
Post_Order Traversal
In this traversal, the nodes are visited in the order of left child, right child and then root. i.e., the left sub-
tree is traversed first, then the sibling is traversed next. The root is visited last. The post-order traversal for
the above example (Fig. 6.3) is: D G H E B J K I F C A.
Q.4(b) Design recursion algorithms to implement them and explain with the help of an example.
Ans. The sum of the integers to n is the sum of the integers through n -1 + n. The sum of the integers to n-1
is the sum to n -2 to n -1, etc. Eventually, we know that the sum of the first positive integer is 1.
Therefore, we can define a terminating condition for some small subset of the problem. The recursive
algorithm to achieve this is as follows:
Algorithm : SumPosInt
Input : n, the upper limit
Output : Sum of first n positive integers
Method:
if (n <= 0) // We only want positive integers
return 0;
else
if (n == 0) // Our terminating condition
return 1;
else
return (n + SumPosInt( n -1 ); // recursive step
if end
if end
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 15/63
[15]
Algorithm ends
Q.5(a) What is binary search? Develop a recursive algorithm for binary search.
Ans. Binary search method is also relatively simple method. For this method it necessary to have the vector
in an alphabetical or numerically increasing order.
The algorithm for binary search.
Algorithm : binary search
Input : A, vector of n elements, K,search element
Output : low-index of k
Method:
Low =l, high=n
While(low<=high-1)
{ Mid=(low+high)/2
If(k<a[mid])
High=mid
Else
Low=mid
If end
}
While end
If(k=A[low])
{
Write(“search successful”)
Write(k is at location low)
Exit();
}
Else
Write(search unsuccessful);
If end;
Algorithm ends
Q.5(b) What are the two methods of representing a binary tree?
Ans. Binary Tree can be represented using the two methods:
1.Static allocation
2. Dynamic allocation
Q.7(a) What is validation and testing of algorithms?
Ans. Validation: Converting the algorithms into programs is a time consuming process. Hence, it essential
to be reasonably sure about the effectiveness of the algorithms before it is coded. This process, at the
algorithm level, is called “Validation”.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 16/63
[16]
Testing: The ultimate test of an algorithms is that the programs based on the algorithm should run
satisfactorily.
Q.7(b) Explain the terms with examples:
i) Finite graph : A graph with a finite number of vertices as well as a finite number of edges is
called a finite graph.
ii) Isolated and pendent vertices: A vertex having no incident edge is called an isolated vertex. A
vertex of degree one is called a pendent vertex or an end vertex.
iii) NULL graph: a graph, without any edges, is called a null graph.
iv) Path.: If a walk has the restriction of no repetition of vertices and no edge is retraced it is called
a “path”.
Q.8 Write short notes on :
a) Debugging : Debugging is the process of executing programs with sample datasets to determine if the
results obtained are satisfactory. When unsatisfactory results are generated, suitable changes are made in
the program to get the desiredresults, debugging can only indicate the presence of errors but not the
absenceof it”.
b) The need for recursion: 1. Mathematical functions such as factorial and fibonacci series generation can
be easily implemented using recursion than iteration.
2. In iterative techniques looping of statement is very much necessary.
c) Incidence matrix.: Let G be a graph with n vertices, e edges, and no self-loops. Define an n by e matrix A
=[aij], whose
n rows correspond to the n vertices and the e columns correspond to the e edges, as follows:
The matrix element
Aij = 1, if jth edge ej is incident on ith vertex vi, and
= 0, otherwise.
Incidence matrix of the graph in Fig.
Such a matrix A is called the vertex-edge incidence matrix, or simply incidence matrix. Matrix A
for a graph G is sometimes also written as A(G). A graph and its incidence matrix are shown in Fig.
and Fig. respectively. The incidence matrix contains only two elements, 0 and 1. Such a matrix is
called a binary matrix or a (0, 1)-matrix.
The following observations about the incidence matrix A can readily be made:
1. Since every edge is incident on exactly two vertices, each column of A has exactly two1’s.
2. The number of 1’s in each row equals the degree of the corresponding vertex.
3. A row with all 0’s, therefore, represents an isolated vertex.
a b c d e f g h
v1 0 0 0 1 0 1 0 0
v2 0 0 0 0 1 1 1 1v3 0 0 0 0 0 0 0 1
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 17/63
[17]
v4 1 1 1 0 1 0 0 0
v5 0 0 1 1 0 0 1 0
v6 1 1 0 0 0 0 0 0
22
4. Parallel edges in a graph produce identical columns in its incidence matrix, for example, columns.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 18/63
[18]
Subject: JAVA Programming
Subject Code: BSIT - 42
Assignment: TA (Compulsory)
Q.1 Explain basic features of Java
Ans.
Simple : Java is designed as closely to C++ as possible in order to make the system more
comprehensible. Java omits many rarely used, poorly understood, confusing features of C++.
Object-Oriented : Object-Oriented languages allow the programmer to organize a program, so that
it closely models the real world in structure and in interactions among its components.
Distributed : Java includes pre-built components or libraries that provide important additional
capabilities beyond the language itself.
Interpreted : Java’s executables files are composed of bytecodes that are instructions and data
relating to a hypothetical computer called Java Virtual Machine. Each Machine that runs a Java
program uses a small program, known as the Java run-time system, to execute the Java bytecodes
in your program.
Robust : In Java programs, exceptions can be detected and handled according to instructions
written by the programmer, often allowing software to keep working in the face of unexpected
problems.
Secure : One of the potential errors of the internet is the possibility of security breaches viruses
that infect your computer, or hackers who take advantage of a software glitch to invade your
personal cyberspace and make off with confidential information.
Architecture Neutral : Java’s bytecodes are designed to be read and interpreted in exactly the same
manner on any computer hardware or operating system that supports a Java runtime. No
translation or conversions is necessary.
Portable : Java program contain no implementation dependent aspects, so the result of executing a
series of Java bytecodes should always be the same no matter on what system they are executed.
High Performance : A typical problem with interpreted languages is that they are somewhat less
efficient than complied languages. A program written by use of an interpreted language may run 20
to 100 times slower than the same program written by use of a compiled language
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 19/63
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 20/63
[20]
Q.4 Explain the following OOPs concept :
a) object and classes : Object is a physical entity which represents a person, vehicle or a conceptual
entity(thing in existence) like bank account, company etc.
A set of variables and functions used to describe an object is a “class”.
A class defines the structure and behavior( data and code) that will be shared by a set of objects.
Each object of a given class contains the structure and behavior defined by the class, as if it were
stamped out of a mould in the shape of a class. A class is a logical construct, an object has physical
reality.
b) Abstraction : the act of leaving out of consideration one or more qualities of a complex object so as
to attend to others. Solving a problem with objects requires you to build the objects tailored to
your solution. We choose to ignore its inessential details, dealing instead with the generalized and
idealized model of the object.
c) Encapsulation : The ability to provide users with a well-defined interface to a set of functions in a
way, which hides their internal workings. In object oriented programming, the technique of keeping
together data structures and the methods( procedure) which act on them. The easiest way to think
of encapsulation is to reference phones.
d) Inheritance : Inheritance in object oriented programming means that a class of objects can inherit
properties from another class of objects. When inheritance occurs, one class is then referred to as
the parent class or superclass or base class. In turn, these serve as a pattern for a derived class or
subclass.
e) Polymorphism : Polymorphism is simply a name given to an action that is performed by similar
objects. Polymorphism allows a common data-generating message to be sent to each class and
allows each subclass object to respond a message format in an appropriate manner to its own
properties. Polymorphism encourages something we call ‘extendibility’. In other words, an object
or a class can have it’s uses extended.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 21/63
[21]
f) Message passing: In an object based world the only way for anything to happen is by objects
communicating with each other and acting on the results. This communication is called message
passing and involves one object sending a message to another and possibly receiving a result.
Q.5 What are the advantages of object oriented programming ?
Ans.
Reusability.
Modularity.
Security.
Easy Mapping
Scalability.
Easy Management.
Q.6 Explain the structure of a Java program.
Ans. Documentation Section: The documentation section comprises a set of comment lines giving the
name of the program , the author and other details. Java also uses comment /** …*/ known as
documentation comment.
Package Statement : the first statement allowed in a java file is a package statement. This statement
declares a package name and informs the compiler that the classes defined here belong to this package.
Import Statement : The next thing after a package statement( but before any class definitions) may be a
number of import statements. This is similar to the #include statement in C.
Interface Statements : An interface is like a class but includes a group of method declarations. This is also
an optional section and is used only when we wish to implement the multiple inheritance feature in the
program.
Class Definitions : A Java Program may contain multiple class definitions. Classes are the primary and
essential elements of a Java Program.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 22/63
[22]
Main Method Class : Since every stand-alone program requires a main method as its starting point, this
class is the essential part of a Java program. A simple Java program may contain only this part. The main
method creates objects of various classes and establishes communications between them.
Q.7 With an example explain Java tokens.
Ans. Java Language includes four types of token:
Reserved Keywords : Keywords are an essential part of a language definition. They implement
specific features of the language. Java language reserved 60 words as keywords. All keywords are to
be written in lower case letters. Ex. Abstract, break etc.
Identifiers : Identifiers are used for naming classes, methods, variables, objects, labels, package and
interfaces in a program. Ex. Average , sum , Batch_strength.
Literals : Literals in Java are a sequence of characters( digits ,letters, and other characters) that
represent constant values to be stored in variables.
Operators : An operator is a symbol that takes one or more arguments and operates on them to
produce a result.
Q.8 With an example explain different data types in Java.
Ans. Different types of data types of Java are :
Integer Types: Integer types can hold whole numbers such as 123 , -96 and 5639. The size of the values
that can be stored depends on the integer data type we choose. Java supports four types of integers , Byte
, Short , Int and Long.
Floating Point Types : There are two types for floating point numbers , float and double. They are used to
store number with values to the right of the decimal point. When you specify a literal value for a float, put
a capital F(float) to the right of the value to explicitly state that it is a float, not a double.
Character Types : Another data type you need to store and manipulates is single-character information.
The primitive type used for storing a single character is char. You can store only one character in a char
variable. If you want to store whole words you can use an object type called string.
Q.9 With an example explain all the operators in Java.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 23/63
[23]
Ans. Arithmetic Operators :There are five basic arithmetic operators in Java : Addition(+) , Subtraction (-),
multiplication(*) , division(/) and modulus(%). All operators can be used with all primitive numeric types(
char, byte , short, int, long float and double). In addition any two numeric types can be combined.
Although the operators can be used with any numeric type, Java actually only does arithmetic with the
types int, long, float and double.
Assignment Operators : Assignment operators are used to assign the value of an expression to a variable.
We have seen the usual assignment operator, ‘=’. In addition, Java has a set of ‘shorthand’ assignment
operators which are used in the form. Java also provides several short cut assignment operators that allow
perform an arithmetic , logical, or bitwise operation and an assignment operation all with one operator .Ex.
i=i+1;
you can shorten this statement:
i+=1;
Relational Operators: We often compare two quantities and depending on their relation, take certain
decisions. For examples, we may compare the age of two persons, or the price of two items, and so on.
These comparisons can be done with the help of relational operators.
Ex. a<b or x<20 where ‘<’ denotes less than
Logical Operators: Relational operators often are used with the conditional operators to construct more
complex decision making expressions. One such operator is &&, which performs the Boolean and
operation. For ex. you can use two different relational operators along with && to determine if both
relationships are true.
Q.10 With an example explain the following statements in Java.
a) simple if : The if statement is a powerful decision making statement and is used to control the flow
of execution of statements. The general form of a simple if statement is :
if(test expression)
{
Statement-block;
}
Statement-x;
The statement-block may be a single statement or a group of statements. If the test expression is
true, the statement-block will be executed.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 24/63
[24]
g) if..else: The if…else statement is an extension of the simple if statement. The general form is
if (Test expression)
{
True-block statement(s)
}
Else
{
False-block statement(s)
}
Statement-x
If the test expression is true, then the true-block statements, immediately following the if
statements are executed otherwise the false-block statement executed.
h) nested if: When a series of decision are involved, we may have to use more than one if…else
statement in nested form as follows:
if(test condition)
if(test condition)
{
Statement 1;
}
Else
{
Statement 2;
}
Else
{
Statement 3;
}
Statement x;
i) else..if ladder: There is another way of putting ifs together when multi path decisions are involved.
A multipath decision is a chain of ifs in which the statement associated with each else is an if. It
takes the following general form:
if(condition 1)
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 25/63
[25]
Statement 1;
Else if(condition 2)
Statement 2;
Else if(condition 30
Statement 3
……………..
Else if(condition n)
Statement n;
Else
Default-statement;
Statement-x;
Q.11 With an example explain the switch statement in Java.
Ans. The switch is used far less often than if statement, but it is sometimes useful for expressing a certain
type of multi-way branch.
A switch statement allows you to test the value of an expression and, depending on that value, to jump to
some location within the switch statement. The expression must be either integer-valued or character-
valued. It cannot be string or a real number.
A switch statement has the form:
Switch (expression) {
Case 1:
Statements-1
Break;
Case 2:
Statements-2
Break;
.
. // more cases
.
Case n:
Statements-n
Break;
Default: //optional default case
// end of switch case
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 26/63
[26]
}
Q.12 Compare while and do..while statements in Java.
Ans. The while statements contains a condition and a loop body. The condition Is enclosed within
parentheses .All the variables used in the condition of the while statements must be initialized before the
while loop. The value of the variables used in the condition must be changed in the loop body. Otherwise,
the condition may always remain true and the loop may never terminate. You change the values of the
variables by performing arithmetic operations on the variables.
Similar to the while statement, the do-while statement is a loop statement provided by Java. The
statement helps to perform certain repetitive actions depending on a condition.
The major difference between the do-while statement and the while statement is that in the while
statement, the loop body is executed only when the condition stated in the statement I true. In contrast, in
the do-while loop, the loop body is executed at least once, regardless of the condition evaluating to true or
false.
Q.13 With an example explain for statement in Java.
Ans To manage iterative actions, Java provides the for statement as an efficient alternative to the whole
statement creates a loop in which a set of statements is repeatedly executed until the specified condition
becomes false. The syntax of the for statement is:
For(Initialization expression; test condition; update expression)
{
Statement 1;
Statement 2;
}
The for statement starts with the for keyword. This statement had three elements enclosed within
parentheses.
Q.14 With the help of an example program explain break and continue statements in Java.
Ans. By using break, we can force immediate termination of loop, by passing the Conditional expression
and any remaining code in the body of the loop. When a break statement is encountered inside the loop,
the loop is terminated and program control resumes the next statement following the loop
Class Breakloop
{
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 27/63
[27]
Public static void main(string args[])
{
For(int i=0; i<00; i++)
{
If(i==10)
Break;
System.out.println(“i=:”+i);
}
System.out.println(“loop complete”);
}
}
The continue statement stops the current iteration of a loop and immediately starts the next iteration of
the same loop. When the current iteration of a loop stops, the statements after the continue statement in
loop are not executed.
Class EvenNum
{
Public static void main(String args[])
{
Int j,k;
For(j=1,k=0;j<=20;j++)
{
K=j%2;
If(k!=0)
Continue;
Else
System.out.println(j+ “is an even number”);
}
}
}
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 28/63
[28]
Assignment: TB (Compulsory)
PART-A
Q.1 How platform independence is achieved in JAVA ?
Ans. The java virtual machine
Garbage collection
Code security
Q.2 List any three features of JAVA
Ans. Simple, Object-oriented, Distributed.
Q.3 What is Java C, Javadoc and Jdbc?
Ans.Javac : translates java source code to byte code
Javadoc : creates html format documentation from java source file
JDBC : Is an API for the Java programming language that defines how a client may access a database.
Q.4 List different features of OOP.
Ans.
Objects and Classes
Abstraction
Encapsulation
Information Hiding
Inheritance
Polymorphism
Message passing
Q.5 Name different types of Java tokens.
Ans.
* Reserved Keywords
* Identifiers
* Literals
* Operators
Q.6 What is the task of the main method in Java program ?
Ans. Since every Java stand-alone program requires a main method as its starting point, this class is the
essential part of a Java program. A simple Java program may contain only this part. The main method
creates objects of various classes and establishes communications between them.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 29/63
[29]
Q.7 Why can’t we use a keyword as a variable name ?
Ans. These keywords have specific meaning in Java, we cannot use them as names for variables, classes,
methods.
Q.8 Why main method in Java is declared as static ?
Ans. You specify that the main() method can be called without instantiating a particular instance of a class.
The keyword static helps you do this. This is necessary because the main() method is called by the Java
interpreter before any objects are created.
Q.9 Write an equivalence of switch statement and if statement
Ans. The switch is used far less often than the if statement, but it is sometimes useful for expressing a
certain type of multi-way branch.
A switch statement allows you to test the value of an expression and, depending on that value, to jump to
some location within the switch statement. The expression must be either integer-valued or character
valued. It cannot be a String or a real number.
The if statement is a powerful decision making statement and is used to control the flow of execution of
statements. It is basically a two-way decision statement and is used in conjunction with an expression.
Q.10 Constructor is _____________.
Ans. Constructors are similar to methods, but they are not methods. Like a method, a constructor has a
set of parameters and a body of code. Unlike methods, however, constructors have no return type.
PART - B
Q.1(a) What is inheritance and how one can achieve code reusability? Explain
with an example
Ans. Inheritance refers to the properties of a class being available to other classes as well. The original class
is called Base Class and Derived classes are classes created from the existing class (Base Class). It will have
all the features of the base class. The concept of Inheritance is very important in Object orientedprogramming languages.
import java.io.*;
//super class declaration
class book
{
String name;
int id;
void showsuper( )
{System.out.println("the id and name of the book is :" +id+ " " +name);
}
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 30/63
[30]
}
class book1 extends book
{
String author;
void showderived( )
{
System.out.println("the author name is:” +author);
}}
class simpleinhertence
{
public static void main(String args[ ])
{
book superob=new book( );
book1 subobj = new book1( );
superob.id=10;
superob.name="java";
System.out.println("the contents of super object is");superob.showsuper( );
System.out.println( );
subobj.id=20;
subobj.name=”C programming”;
subobj.author=”Balaguruswamy”;
System.out.println(“the contents of the subobj:”);
subobj.showsuper( );
subobj.showderived( );
}
}
Result
The contents of super object is
The id and name of the book is: 10 java
The contents of the subobj:
The id and name of the book is : 20 C programming
The author name is: Balaguruswamy
Q.1(b) What is a class? How does it accomplish data hiding? Explain with example.
Ans. A class defines the structure and behavior (data and code) that will be shared by a set of objects. Each
object of a given class contains the structure and behavior defined by the class
For example, you might have a Tree class that describes the features of all trees (has leaves and roots,
grows, creates chlorophyll). The Tree class serves as an abstract model for the concept of a tree-to reach
out and grab, or interact with, or cut down a tree you have to have a concrete instance of that tree. Of
course, once you have a tree class, you can create lots of different instances of that tree, and each
different tree instance can have different features (short, tall, bushy, drops leaves in Autumn), while still
behaving like and being immediately recognizable as a tree.
Q.2(a) Compare in terms of their functions and semantics the following pairs of
statements:
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 31/63
[31]
i) do while and while : the do-while statement and the while statement is that in the while statement, the
loop body is executed only when the condition stated in the statement is true. In contrast, in the do-while
loop, the loop body is executed at least once, regardless of the condition evaluating to true or false.
ii) while and for : The for statement creates a loop in which a set of statements is repeatedly executed
until the specified condition becomes false. The while statement contains a condition and a loop body. The
condition is enclosed within parentheses.
iii) nested if and switch : The effect of a break is to make the computer jump to the end of the switch
statement.
By using break, we can force immediate termination of loop, by passing the Conditional expression and any
remaining code in the body of the loop.
iv) break and continue : The effect of a break is to make the computer jump to the end of the switch
statement. By using break, we can force immediate termination of loop, by passing the Conditional
expression and any remaining code in the body of the loop.
The continue statement stops the current iteration of a loop and immediately starts the next iteration of
the same loop. When the current iteration of a loop stops, the statements after the continue statement in
the loop are not executed.
Q.3(a) Explain different data types in Java with example.
Ans. Integer types can hold whole numbers such as 123,-96,and 5639. The size of the values that can be
stored depends on the integer data type we choose. Java supports four types of integers. Byte, short, int,
and long.
There are two types for floating point numbers, float and double. They are used to store number with
values to the right of the decimal point.
Another data type you need to store and manipulate is single-character information. The primitive type
used for storing a single character is char.
Q.3(b) Describe the structure of a typical Java program.
Ans. A Java program may contain many classes of which only one class defines a main method. Classes
contain data members and methods that operate on the data members of the class. Methods may contain
data type declarations and executable statements. To write a Java program, we first define classes and
then put them together. A Java program may contain one or more sections as shown in the Fig.
Documentation Section
The documentation section comprises a set of comment lines giving the name of the program , the author
and other details. Java also uses comment /**…*/ known as documentation comment.
Package Statement
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 32/63
[32]
The first statement allowed in a Java file is a package statement. This statement declares a package name
and informs the compiler that the classes defined here belong to this package.
Eg : package student;
Import Statement
The next thing after a package statement (but before any class definitions) may be a number of import
statements. This is similar to the #include statement in C. Example :
Import student.test;
This statement instructs the interpreter to load the test class contained in the package student.
Interface Statements
An interface is like a class but includes a group of method declarations. This is also an optional section and
is used only when we wish to implement the multiple inheritance feature in the program.
Documentation Section Suggested
Package Statement Optional
Import Statements Optional
Interface Statements Optional
Class Definitions Optional
Main Method class
{
Main Method Definition
}
Essential
Class Definitions
A Java program may contain multiple class definitions. Classes are the primary and essential elements of a
Java program.
Main Method Class
Since every Java stand-alone program requires a main method as its starting point, this class is the
essential part of a Java program. A simple Java program may contain only this part. The main method
creates objects of various classes and establishes communications between them.
Q.4(a) What is JVM ? How does it help to achieve platform independence? If JVM is
available for windows then can we run program written on Unix platform ?
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 33/63
[33]
Comment.
Ans. All language compilers translate source code into machine code for a specific computer. Java
Compiler produces an intermediate code known as bytecode for a machine that does not exist. This
machine is called the Java Virtual Machine and it exists only inside the computer memory.
Q.5(a) Distinguish between the following terms:
i) Dynamic binding and message passing : Java’s program units, classes, are loaded dynamically (when
needed) by the Java run-time system.
Loaded classes are then dynamically linked with existing classes to form an integrated unit. The lengthy
link-and-load step required by third-generation programming languages is eliminated.
In an object based world the only way for anything to happen is by objects communicating with each other
and acting on the results. This communication is called message passing and involves one object sending a
message to another and (possibly) receiving a result.
ii) Inheritance and Polymorphism : Inheritance in object oriented programming means that a class of
objects can inherit properties from another class of objects. When inheritance occurs, one class is then
referred to as the ‘parent class’ or ‘superclass’ or ‘base class’. In turn, these serve as a pattern for a
‘derived class’ or ‘subclass’.
Poly means many...morph means change (or ‘form’). Many changes of form or changes of form by many.
Polymorphism allows a common data-gathering message to be sent to each class and allows each subclass
object to respond to a message format in an appropriate manner to its own properties.
Q.5(b) What are the difference between C and Java.
Ans.
a. Ans. Java does not have a preprocessor, and as such, does not have macros like define. Constants
can be created by using the final modifier when declaring class and instance variables.
b. Java does not include C’s const keyword or the ability to pass by const reference explicitly.
c. Java classes are single inherited, with some multiple-inheritance features provided through
interfaces.
d. All functions must be methods. There are no functions that are not tied to classes.
e. The goto keyword does not exist in Java(it’s reserved word, but currently unimplemented). You can,
however, use labeled breaks and continues to break out of and continue executing complex switch
or loop constructs.
f. Java does not use pointers.
g. Java doesn’t contain the data types: Struct, Union, Enum.
Q.6(a) Define programming. What are the types of programming? Explain.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 34/63
[34]
Ans. Programming;- It is a method of implementation in which programs are organized as co-operative
collection of objects, each of which represents an instance of some class and whose classes all members of
a hierarchy of classes united in inheritance relationships.
Unstructured Programming
Usually, people start learning programming by writing small and simple programs consisting only of one
main program. Here “main program” stands for a sequence of commands or statements, which modify
data, which is global throughout the program.
Procedural Programming :
With procedural programming you are able to combine returning sequences of statements into one single
place. A procedure call is used to invoke the procedure. After the sequence is processed, flow of control
proceeds right after the position where the call was made
Modular Programming
With modular programming procedures of a common functionality are grouped together into separate
modules. A program therefore no longer consists of only one single part. It is now divided into several
smaller parts which interact through procedure calls and which form the whole program.
Object-Oriented Programming
In object oriented programming, a complex system is decomposed in accordance to the key abstractions of
the problem. Rather than decomposing the problems into steps, we identify objects, which are delivered
directly from the vocabulary of the problem domain.
Q.7(a) List and explain different types of loops in Java.
Ans.
THE WHILE LOOP
To perform an action repeatedly, Java provides certain loop statements. One of the loop statements is the
while statement. The while statement contains a condition and a loop body. The condition is enclosed
within parentheses.
Syntax:
While (test condition)
{
Body of the loop
};
DO STATEMENTThe statement helps to perform certain repetitive actions depending on a condition. The major difference
between the do-while statement and the while statement is that in the while statement, the loop body is
executed only when the condition stated in the statement is true. In contrast, in the do-while loop, the
loop body is executed at least once, regardless of the condition evaluating to true or false.
Syntax:
do
{
loop body
}while(condition);
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 35/63
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 36/63
[36]
(i) Trim : The trim method returns a copy of the invoking string from which any leading and trailing white
space has been removed. It has the general form:
String trim ( );
(ii) Substring : The Substring method is used to create new instances of the class String from existing
instances. The new string is specified by giving the required index range within the existing string .
string substring(int startIndex)
This returns the sub string that starts at startIndex and runs to the end of the invoking string.
string substring(int start Index, int endIndex)
This returns the substring that starts at startindex and runs through endIndex-1;
(iii) Length : The length of a string is the number of characters that it contains. To obtain this value call alength method str.length();
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 37/63
[37]
Subject: UNIX & Shell Programming
Subject Code: BSIT - 43
Assignment: TA (Compulsory)
Q.1 How the Unix is different from other OS?
Ans. Unix is a multitasking operating system, which allows the computer to run several programs at the
same time. By going quickly from one task to another and performing a little bit of each task every time,
the operating system gives an impression of doing many things at the same time.
Q.2 What are Internal & External commands?
Ans. Some commands in Unix are internal, built into the shell. For example, the cd command is built-in.
The shell interprets the command and changes the current directory .On the other hand , cat command isan external program stored in the file/bin/cat. External commands require the shell to run a new sub
process; this takes some time ,especially if the system is busy.
Q.3 How do you change your password in Unix?
Ans. The system will prompt the user fir the old password. Once this is entered, the new password is
requested. The system once again prompts the user to retype the new password, to make sure that there
is no mistake in the entry.
Q.4 List various directory related commands
Ans.
Cd
Mkdir
Rmdir
Ls
Q.5 What are different types of files in Unix?
Ans. Syntax file filename(s) ,This command identifies the file as regular, directory or device file. Further
attempts at classification are done by testing each filename.
Ex : denote all files .Various types are identified by file.
$ file *
Abs.dat: ascii text
Absdel.cob: English text
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 38/63
[38]
Add.lst: empty
Q.6. Define Hard Links.
Ans. In Unix, a single copy of a file can have several names, which are links to the same file. Since all the
filenames refer to the same file, they have the same inode number. The second column in output of the Is-l
command gives the number of links that a file has. The number is 1 for unlinked files. Hard links can be
created using the ln command.
Q.7 What are absolute pathnames?
Ans. A pathname gives the file’s position in the file system An absolute or full pathname specifies the
location of a file in relation to the top of the file system which is the/(root). An absolute pathname starts at
the /(root) directory and lists each directory along the path to the destination file(or directory).
Q.8 When do we use “wc” command?
Ans. The command counts lines, words and characters in the file named depending on the option used.
Q.9 Explain the parent-child relationship in Unix file system.
Ans. In Unix all files are related to one another and are organized in a hierarchical structure. This is called
the UNIX file system and at the very top of the tree is the root directory, named ”/” which serves as the
reference point for all the files. The root directory has a number of subdirectories and files . Therefore,
every file expect the root will have a parent. A sample Unix file system tre..
Assignment: TB (Compulsory)
PART - A
Q.1 What are the different standard given by POSIX ? What is POSIX ?
Ans. "Portable Operating System Interface [for Unix]"[1] is the name of a family of related standards
specified by the IEEE to define the application programming interface(API), along with shell and utilities
interfaces for software compatible with variants of the Unix operating system, although the standard can
apply to any operating system.
The POSIX specifications for Unix-like operating system environments originally consisted of a single
document for the core programming interface, but eventually grew to 17 separate documents.[3] The
standardized user command line and scripting interface were based on the Korn Sell. Many user-level
programs, services, and utilities including awk, echo, ed were also standardized, along with required
program-level services including basic I/O (file, terminal, and network) services. POSIX also defines a
standard threading library API which is supported by most modern operating systems. Nowadays, 10 out of
these 17 parts are combined into a single standard, IEEE Std 1003.1-2008, also known as POSIX:2008.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 39/63
[39]
POSIX:2008: POSIX Base Definitions, System Interfaces, and Commands and Utilities (which include
POSIX.1, extensions for POSIX.1, Real-time Services, Threads Interface, Real-time Extensions, Security
Interface, Network File Access and Network Process-to-Process Communications, User Portability
Extensions, Corrections and Extensions, Protection and Control Utilities and Batch System Utilities).
Q.2 On which variable terminal setting is done ? Name any three terminal setting
keys.
Ans. The terminal settings are found in the TERM variable.
Terminal Setting Keys:-
[ctrl-h] erases text
[ctrl-c] or [Delete] Interrupts a command
[ctrl-d] Terminates a login session
[ctrl-s] stops screen scrolling
Q.3 Explain key features of UNIX.
Ans. UNIX goes beyond the traditional operating system by providing a standard set of libraries and
applications that developers and users can use. This standard interface allows application portability and
facilitates user familiarity with the interface.
Q.4 What is script command, with command explain how to create script file of a session?
Ans. Script is used to take a copy of everything which is output to the terminal and place it in a log file. It
should be followed by the name of the file to place the log in, and the exit command should be used to
stop logging and close the file. It can be used to obtain a copy of a program run, which should be placed
your notebook, and will be a required part of an assignment submission. Everything between the script and
the exit command is logged to the file. This includes the confirmation messages from script itself.
Q. 5 What happens if a directory permission charged?
Ans. The user mask is a numeric value that determines permissions when a file or directory is created.
Consequently, when a file or directory is created, its permissions are set to the permissions are set to the
permissions specified by the creating program minus the permission values denied by the unmask value.
Q.6 How do you yank and paste lines?
Ans. By giving Y command.
Q.7 List out the different attributes of a file.
Ans.
-rw-r-----
-rw-r -- r—
-rw-r – r—
drw-r -- r—
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 40/63
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 41/63
[41]
1) Process-ID(PID)
2) Parent PID(PPID)
PART - B
Q.1(a) Explain layered architecture of Unix operating system. With a suitable
command explain the interaction between Shell and Kernel.
Ans. The part of UNIX that manages the hardware and the executing processes is called the kernel. The
kernel is a collection of programs written in C which directly communicate with the hardware. Application
programs (user programs) communicate with the hardware by using the services of the kernel. Along with
the memory management, the kernel also schedules processes and decides their priorities. In the Unix
system, each hardware device is viewed as a file and is called a device file. This allows the same simple
method of reading and writing files to be used to access each hardware device. The file system manages
read and write access to user data and to devices, such as printers, attached to the system. It implements
security controls to protect the safety and privacy of information. In executing processes the kernel
allocates resources, including use of the CPU and mediates accesses to the hardware. The user commands
are translated into action by the shell which acts as an interpreter. The shell forms the outer part of the
operating system and forms the interface between the user and the kernel. For each user logged in, there
is shell in action. When a command is given by the user, it is examined by the shell and communicated to
the kernel for execution. The functions used to communicate with the kernel are called system calls and
are built into the kernel. The system calls are in all the flavors of UNIX are the same. Hence, software
developed on one UNIX system can be easily run on another UNIX system.
Q.1(b) Explain uname command with different options.
Ans. uname - displays the name of the operating system
Syntax
uname [ options ]
Examples:
Displays all the information
$ uname -a
SCO_SV sco5 3.2 5.0.5 i386
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 42/63
[42]
Displays the machine’s node name in the communications network.
$uname -n
sco5
Displays the operating system release.
$ uname -r
3.2
Displays the name of the operating system
$ uname -s
SCO_SV
Displays the operating system version
$ uname -v
5.0.5
Displays the information about system name, node name, operating system release number, kernel ID,
processor type, bus type, serial number, number of users license, OEM number, origin number and
number of CPUs.
$ uname -X
System = SCO_SV
Node = sco5
Release = 3.2v5.0.5
KernelID = 98/07/02
Machine = PentII
BusType = ISA
Serial = 5GE048977
Users = 5-user
OEM# = 0
Origin# = 1
NumCPU = 1
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 43/63
[43]
Q.2(a) Explain the advantages of ispell, list out the basic commands used in ispell.
Ans. The advantages of using ispell are as follows:
1)In the case of ispell, each word that does not appear in its dictionary will be displayed at the top of the
screen allowing the user to change it.
2) If the dictionary contains any near misses (i.e., words which differ by only a single letter, a missing or
extra letter, a missing space or hyphen or a pair of transposed letters,), ispell will display them.
3)ispell may display guesses at ways to make the word from a known root, with each guess preceded by
question marks.
4)ispell prints the line containing the word and the previous line at the bottom of the screen. If the
terminal can display in reverse video, ispell highlights the word itself. The user can then replace the word
completely, or choose one of the suggested words.
Q.2(b) Explain Unix file system and give the difference between relative and absolute
Pathname
Ans. While there is no standard Unix file structure go all flavors of Unix, there are some common
directories created at the time of Unix installation. The director structure of a typical Unix system is as
shown
The Absolute Pathnames: An absolute or full pathname specifies the location of a file in relation to the top
of the file system which is the /(root). An absolute pathname starts at the /(root) directory and list eachdirectory along the path to the destination file (or directory).
Relative pathnames: A relative pathname specifies a file in relation to the current directory and home the
relative pathname depends on the current directory. A relative pathname starts from the current
directory. In a relative pathname, a single dot (.) represents the current working directory and two dots (..)
represent the parent of the current working directory.
Q.3(a) Explain how to split file into multiple files. Give suitable example.
Ans. split - split large files into smaller files:
Syntax
split [options] filename prefix
where filename is the name of the large file to be split, prefix is the name to be given the small output files
and options can either be excluded or can be one of the following:
-l linenumber
-b bytes
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 44/63
[44]
If -l (the letter l) option is used, linenumber will be the number of lines to be put in each of the smaller files
(the default is 1,000). If the -b option is used, bytes will be the number of bytes to be put in each of the
smaller files.
The split command will give each output file created the name prefix with an extension attached to the
end to indicate its order. By default, the split command adds aa to the first output file, proceeding through
the alphabet to zz for subsequent files. If no prefix is specified, most systems use x .
Examples
Assuming that file.txt is 3,000 lines long, it will output three files, xaa, xab, and xac, and each one will be
1,000 lines long.
$ split file.txt
This will output six 500-line files: fileaa, fileab, fileac, filead, fileae, and fileaf.
$ split -l 500 file.txt file
Assuming that file.txt has 200 kilobytes, this will output five 40 kilobyte files: fileaa, filetab, fileac, filead
and fileae
$ split -b 40k file.txt file.
Q.3(b) Give the difference between Hard Link and Symbolic Link.
Ans. A symbolic link is a special file that contains the path name of the file to which it is linked. This is
unlike the hard link where in the linked file also contains the contents of the file to which it is linked.
Symbolic links are also called as soft links and are more flexible. They can be used to link to directories, orto files on other file systems. When a target file is deleted, a symbolic link to that file become unusable.
This is unlike a hard link where the contents of the file are preserved.
Q.4(a) What is a process? Explain the mechanism of creation in unix.
Ans. A process is born when a program starts execution and exists as long as the program is running after
execution the process is said to die the name of the process is usually the name of the program being
executed.
The mechanism of creation in UNIX:
The creation of a process is in three phases and uses three system calls known as fork, exec and wait. Fork
is a system call that creates a new process from an existing process. The new process is called the child
parent and child are an identical image except for parameters like PID. The child gets a new PID and the
process is forked this is the mechanism used to multiply processes in the system.
Q.4(b) List out the navigation keys for the cursor movement
Ans. In the command mode, navigation keys for the movement of the cursor by characters, words and
lines are as follows:
Keys movement of cursor
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 45/63
[45]
H cursor moves left
j cursor moves down
k cursor moves up
l cursor moves right
w word forward
b word backward
e end of word
^ first character
$ end of line
0 beginning of line
Q.5(a) Explain grep command with at least 5 examples with different options.
Ans. The grep command in UNIX is used to search for a pattern in a given file. It displays the selected
pattern, the line numbers or the filenames where the pattern occurs. The syntax is given below:
grep options pattern filename(s) grep searches for pattern in one or more filenames. The first argument is
the pattern and ones remaining are filenames. Let’s use grep to display lines containing the string
Information from the file emp.lst; the content of this file are shown below:
$ grep “Information” emp.lst
1001|T.N.Raju |Professor |Information Science|14/06/61|30000
1004|D.S.Raghu |Lecturer |Information Science|05/12/75|17000
1005|S.K.Anantha |Asst.Prof. |Information Science|20/07/63|24000
1002|Mallu |Lecturer |Information Science|20/07/74|15000
1003|B.S.Ashok |Lecturer |Information Science|01/01/78|15000
Examples
Ignoring Case (-i) When you look for a name, but are not sure of the case, grep offers the –i option which
ignores case for pattern matching:
$ grep -i “anantha” emp.lst
1005|S.K.Anantha |Asst.Prof. |Information Science|20/07/63|24000
Deleting Lines (-v) grep can play an inverse role too; the –v (inverse) option selects all except lines
containing the pattern. Thus, you can create a file otherlist containing all but Lecturer.
$ grep -v “Lecturer” emp.lst > otherlist
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 46/63
[46]
1001|T.N.Raju |Professor |Information Science|14/06/61|30000
1005|S.K.Anantha |Asst.Prof. |Information Science|20/07/63|24000
1006|H.R.Rajesh |Asst.Prof. |Mechanical |11/07/76|21000
Displaying Line Numbers (-n) The –n (numbers) option displays the line numbers containing the pattern,
along with the lines:
$ grep -n “Lecturer” emp.lst
2:1004|D.S.Raghu |Lecturer |Information Science |05/12/75|17000
4:1009|M.P.Rajendra|Sr.Lecturer |Computer Science |13/03/66|20000
5:1002|Mallu |Lecturer |Information Science |20/07/74|15000
8:1007|Sanjay |Lecturer |Civil |19/04/73|15000
Counting Lines Containing Pattern (-c) How many Lecturers are there in the file? The –c (count) option
counts the number of lines containing the pattern (which is not the same as number of occurrences). The
following shows that there are six of them:
$ grep -c “Lecturer” emp.lst
Matching Multiple Patterns (-e) With the –e option, you can match the two Mahanand by using grep like
this:
$ grep -e “mallu” -e “MALLU” emp.lst
1002|Mallu |Lecturer |Information Science|20/07/74|15000
Q.5(b) Explain Uniq command
Ans. When you concatenate or merge the files, you’ll face the problem of duplicate entr ies creeping in.
UNIX offers a special tool to handle these lines – the uniq command.
$ uniq dept.lst
Since uniq requires a sorted file as input, the general procedure is to sort file and pipe its output to uniq.
The following pipeline also produces the same output, except that the output is saved in a file uniqlist:
$ sort dept.lst | uniq – uniqlist
Q.6(a) Explain the mechanism of executing job periodically using cron.
Ans. A task can be automatically run in the background at regular intervals by a Unix utility called cron. The
cron daemon takes care of running these background jobs, which are called cron jobs.
A user can execute crontab if the user’s name appears in the file /usr/lib/cron/cron.allow. If the
cron.allow does not exist, the cron.deny file in /usr/lib/cron is checked. If the user’s name is not in this file
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 47/63
[47]
the user is allowed to use crontab. If only cron.deny exists and is empty, all users can use crontab. If
neither file exists, only the root user can use crontab. The allow and deny files contain one user name per
line. The following options can be used with crontab:
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
An editor has to be specified to open the crontab file.
Q.6(b) Write a shell script to add two numbers by using Expr utility.
Ans. #/bin/sh
#Shell Script to Add two numbers
Sum='expa $1+$2'
echo $ sum
Here we defined a variable sum to hold the result of the operation. To run this script, we might type the
following line:
$ add 2 2
Then we get the sum are echoed on the screen
4
$
Q.7(a) What are positional parameters? Explain the command used to set the
positional parameters
Ans. A positional parameter is a variable within a shell program; its value is set from an argument specified
on the command line that invokes the program. Positional parameters are numbered and are referred towith a preceding ``$'': $1, $2, $3, and so on.
A shell program may reference up to nine positional parameters. If a shell program is invoked with a
command line that appears like this:
shell.prog pp1 pp2 pp3 pp4 pp5 pp6 pp7 pp8 pp9
then positional parameter $1 within the program is assigned the value pp1, positional parameter $2 within
the program is assigned the value pp2, and so on, at the time the shell program is invoked.
To practice positional parameter substitution, create a file called pp (short for positional parameters).
(Remember, the directory in which these example files reside must be in $PATH.) Then enter the echo
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 48/63
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 49/63
[49]
current directory (.) and directory above (..)
-A all files including those beginning with a dot
(.).does not list current directory (.) and directory
above (..)
-d if an argument is a directory, lists only its name
(not its contents)
-F marks directories with a /, executables with a *
and symbolic links with a @
-I shows the inode number
-l lists in long format, giving mode, number of
links, owner, group, size in bytes, the time that each file was last modified.
-p puts a slash (/) after each directory.
s-r sorts the filenames in the reverse order
-R recursive list
-t sorts by time modified (latest first)
-u sorts by last access time
-x lists files in columns with entries sorted across
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 50/63
[50]
Subject: Software Engineering
Subject Code: BSIT - 44
Assignment: TA (Compulsory)
Q.1 Define Software Engineering as per IEEE.
Ans. According the IEEE, Software engineering is defined more comprehensive as “ The application of a
systematic, disciplined, quantifiable approach to the development, operation, and maintenance of
software, that is, the application of engineering of software.”
Q.2 Give important characteristics of the Prototype Model
Ans.
For prototyping, the cost of the requirements analysis must be kept low, in-order- for it to be
feasible.
The development approach followed is “quick and dirty”, the focus is on quicker development
rather than on the quality.
Only minimal documentation is required because it is throw away prototype model.
This model is very useful in projects where requirements are not properly understood in the
beginning.
It is an excellent method for reducing some types of risks involved with a projects.
Q.3 What is DFD?
Ans. Data Flow Diagram also called data flow graphs are commonly used during problem analysis, for
understanding a system. It shows the flow of data through the system it does not represent procedural
information. It views a system as a function that transforms the inputs into desired outputs.
Q.4 What are the two levels of Software design process?
Ans. The design process for the software has two levels:
System design
Detailed design
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 51/63
[51]
Q.5 Name any 4 criteria used to guide modularization
Ans.
Modular Decomposability.
Modular Composability
Modular Understandability.
Modular continuity
Q.6 Define Cohesion
Ans. Cohesion is a measure of the relative functional strength of a module. It is an extension of information
hiding concept. A cohesive module must perform a single task within a software procedure., requiring little
interaction with procedures that are performed in other parts of a program.
Q.7 List any 3 popular Tabular Design Tools
Ans.
Decision Tables
Detailed State Diagrams and Tables
Karnaugh map.
Q.8 Why we require Coding standards and Practices?
Ans. When writing the code, many people are generally involved, and a great level of cooperation and
coordination is required . Thus, it is very important for others to understand not only what you have
written, but also why have written it and how it fits in their work. For these reasons, one must know theorganizations’ s standards and procedures before beginning to write code.
Q.9 What are Source code tools? Give example.
Ans. There are two commonly used source code tools-:
Editing tools, these relate to the editing of source code.
Browsing tools, helps to view the source code.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 52/63
[52]
Q.10 What is internal documentation?
Ans. Internal documentation is a descriptive material written directly with in the program, at a level
appropriate for a programmer. It contains information directed at some one who will be reading the
source code of the program .The information contains a description of data structures, algorithms and
control flow.
Q.11 Discuss the four major goals of SRS.
Ans.
It provides feedback to the customer. An SRS is the customer’s assurance that the development
organization understands the issues or problems to be solved and the software behavior necessary
to address those problems.
It decomposes the problem into component parts. The simple act of writing down software
requirements in a well-designed format organizes information, places borders around the problem,
solidifies ideas, and helps break down the problem into its component parts in an orderly fashion.
It serves as an input to the design specification . As mentioned previously, the SRS serves as the
parent document to subsequent documents, such as the software design specification and
statement of work.
It serves as a product validation check. The SRS also serves as the parent document for testing and
validation strategies that will to the requirements for verification.
Assignment: TB (Compulsory)
PART – A
Fill up the blanks using suitable word or phrase in the following sentences:
1) Software is a set of instructions that when executed provide desired function
and performance.
2) Software is a process and product .
3) The Incremental method is also known as the iterative enhancement model.
4) An external entity is represented using rectangular box in a DFD.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 53/63
[53]
5) The software requirements deal with the requirements of the proposed system.
6) The weakest coupling that is most desirable is Data coupling.
7) The three important levels of abstraction are Procedural , Data and Control.
8) P.D.L. stands for Program Design Language.
9) Browsing Tools helps to view the source code.
10) Executable Code tools help in code creation, debugging and testing.
11) The two kinds of program documentation are Internal and External .
12) Estimation makes use of an important approach Decomposition.
13) PERT stands for Program Evaluation Review Technique.
II. Write brief answers to the following questions:
Q.1 Define the terms risk mitigation, risk monitoring.
Ans. Risk mitigation is a planning process. This process defines alternative ways to prevent risks and helps:
Avoid the identified risks from occurring.
Reduce the impact of the rick on the project.
It is a good practice to address possible ricks during the initial stages of project development. This
helps mitigate the probability of occurrence of ricks and the potential impact of ricks on the project
and its test process.
The risk mitigation strategies enable the following three risk management:: risk mitigation, risk monitoring,
risk management and contingency planning
The Risk monitoring activities commence as soon as project development begins and they are periodically
performed . It is not possible to frequently monitor all risks identified for the project and its test processtherefore, risks with relatively high priority are monitored more often than others. Following are the
primary objectives :
(1) To assess if the predicted risk really occur.
(2) To ensure that the risk avoidance steps defined for a particular risk are being properly
implemented.
(3) To collect information that cans be used for risk analysis in future
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 54/63
[54]
Q.2 Name the important approaches used in program debugging.
Ans. It occurs as a consequence of successful testing when a test case uncovers an error, then debugging
process begins with the execution of test cases
There are three debugging approaches commonly used:
1) Brute force method: It is the most common and test efficient method. It is applied when all else
fails.
2) Back tracking: Fairly common, can be successfully used in small programs beginning at the site
where symptoms has been found the source code is traced backward until the site of course is found.
3) Cause elimination: Used the concept of binary partitioning. ”A cause HYPOTHESIS” is devised and
data related to the error occurrence are used to prove or disprove the hypothesis
Q.3 What are specification languages? Give an example.
Ans. A specification language is a formal language used in computer science. Unlike most programming
languages, which are directly executable formal languages used to implement a system, specification
languages are used during systems analysis, requirements analysis and systems design.
Specification languages are generally not directly executed. They describe the system at a much higher
level than a programming language. Indeed, it is considered as an error if a requirement specification is
cluttered with unnecessary implementation details, because the specification is meant to describe the
what, not the how.
A common fundamental assumption of many specification approaches is that programs are modeled as
algebraic or model-theoretic structures that include a collection of sets of data values together with
functions over those sets. This level of abstraction is commensurate with the view that the correctness of
the input/output behavior of a program takes precedence over all its other properties.
In the property-oriented approach to specification (taken e.g. by CASL), specifications of programs consist
mainly of logical axioms, usually in a logical system in which equality has a prominent role, describing the
properties that the functions are required to satisfy - often just by their interrelationship. This is in contrast
to so-called model-oriented specification in frameworks like VDM and Z, which consist of a simplerealization of the required behavior.
PART – B
Q.1(a) What is software? List out the important characteristics of software
Ans. Computer software, or just software, is a collection of computer programs and related data that
provide the instructions for telling a computer what to do and how to do it. In other words, software is a
conceptual entity which is a set of computer programs, procedures, and associated documentation
concerned with the operation of a data processing system. We can also say software refers to one or morecomputer programs and data held in the storage of the computer for some purposes. In other words
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 55/63
[55]
software is a set of programs, procedures, algorithms and its documentation. Program software performs
the function of the program it implements, either by directly providing instructions to the computer
hardware or by serving as input to another piece of software. The term was coined to contrast to the old
term hardware (meaning physical devices). In contrast to hardware, software is intangible, meaning it
"cannot be touched".
Characteristics::
Software is Developed or Engineered
Not Manufactured
Software Does Not ´Wear Outµ
May Become Un-Maintainable
Hardware Does wear out
Most Software is Custom-Built
Limited Role for Packaged Products Which Need Customization and Integration With Other Apps.
Q.1(b) Explain the waterfall model of software process. What are its limitations?
Ans. The waterfall model is a sequential design process, often used in software development processes, in
which progress is seen as flowing steadily downwards (like a waterfall) through the phases of Conception,
Initiation, Analysis, Design, Construction, Testing, Production/Implementation and Maintenance. Thewaterfall development model originates in the manufacturing and construction industries: highly
structured physical environments in which after-the-fact changes are prohibitively costly, if not impossible.
Since no formal software development methodologies existed at the time, this hardware-oriented model
was simply adapted for software development) Describe the three generic views of software engineering.
The limitation of this model is that, it requires a complete set of user requirements before the
commencement of design . Which is difficult to give since requirements keep on changing according to
needs and time.
Q.2(a) Describe the three generic views of software engineering.
Ans. The Definition phase: the definition focuses on what . That is during definition, the software developer
attempts to identify what information is to be processed, what function and performance are desired,
what system behavior can be expected, what interfaces are to be established, what design constraints
exist, and what validation criteria are required to define a successful system.
The Development phase: the development phase, focuses on how. That is , during the software
development, a software engineer attempts to define how data are to be structured, how function is to be
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 56/63
[56]
implemented as a software architecture, how procedures are to be implemented, how design will be
translated into a programming language, how testing will be performed etc.
The Maintenance Phase: the maintenance phase focuses on change that is associated with the software.
The four main changes that are encountered during this phase are: Correction , Adaptations,
Enhancement, prevention.
Q.2(b) List out the important characteristics of good SRS.
Ans. The characteristics of good SRS are:
Correct and complete:-
An SRS is correct if every requirement included in the SRS represents something required in the final
system. An SRS is complete if everything the s/w is supposed to do and the responses of the s/w to all
classes of input data are specified in the SRS. Completeness ensures that everything is indeed specified.
Unambiguous:-
An SRS is unambiguous if and only if every requirement state has one and only one interpretation.
Requirements are often written in natural language, which are inherently ambiguous. One way to avoid
ambiguities is to use some formal requirements specification language.
Verifiable:-
An SRS is verifiable if and only if every stated requirement is verifiable .A requirement is verifiable if there
exists some cost effective process that can check whether the final s/w meet that requirement.Unambiguity is essential for verifiability. As verification of requirements is often done through reviews, it
also implies that an SRS is understandable at least by the developer, the client and the users.
Consistent:-
An SRS is consistent if there is no requirement that conflicts with another. Terminology can cause
inconsistencies .This occurs if the SRS contains two or more requirements whose logical or temporal
characteristic cannot be satisfied together by any s/w system.
Modifiable :-
An SRS is modifiable if its structure and style are such that any necessary change can be made easily while
preserving completeness and consistency. Presence of redundancy is a major hindrance to modifiability as
it can easily lead to error.
Q.3(a) Give the outline structure of SRS
Ans. A sample of basic SRS outline
1. Introduction
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 57/63
[57]
Purpose, Document conventions, Intended audience, additional information, Contact information/SRS
team members, Reference
2. Overall Descriptions
Product perspective, Product functions, User classes & characteristics, Operating environment, User
environment, Design/implementation constraints, Assumptions & dependencies
3 .External Interface requirements
User Interfaces, Hardware interfaces, Software interfaces, Communication protocol and interface
4. System Features
System feature A, Description and priority, Action/result, Functional requirement, System feature B
5. Other Nonfunctional Requirements
Performance requirements, Safety requirements, Security requirement, Software quality attributes, Projectdocument
6. Other requirements
Q.3(b) ) Why is design an important phase in software development life cycle? Describe design process.
Ans. The Design Phase :-In the design phase the architecture is established. This phase starts with the
requirement document delivered by the requirement phase and maps the requirements into an
architecture. The architecture defines the components, their interfaces and behaviors. The deliverable
design document is the architecture. The design document describes a plan to implement the
requirements. This phase represents the ``how'' phase. Details on computer programming languages and
environments, machines, packages, application architecture, distributed architecture layering, memory
size, platform, algorithms, data structures, global type definitions, interfaces, and many other engineering
details are established. The design may include the usage of existing components. The design phase is
summarized in Table above.
The architectural team can now expand upon the information established in the requirement document.
Using the typical and atypical scenarios provided from the requirement document, performance trade-offs
can be accomplished as well as complexity of implementation trade-offs.
Obviously, if an action is done many times, it needs to be done correctly and efficiently. A seldom used
action needs to be implemented correctly, but it is not obvious what level of performance is required. The
requirement document must guide this decision process. An example of a seldom used action which must
be done with high performance is the emergency shutdown of a nuclear reactor.
Analyzing the trade-offs of necessary complexity allows for many things to remain simple which, in turn,
will eventually lead to a higher quality product. The architecture team also converts the typical scenarios
into a test plan.
In our approach, the team, given a complete requirement document, must also indicate critical priorities
for the implementation team. A critical implementation priority leads to a task that has to be done right. If
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 58/63
[58]
it fails, the product fails. If it succeeds, the product might succeed. At the very least, the confidence level of
the team producing a successful product will increase. This will keep the implementation team focused.
Exactly how this information is conveyed is a skill based on experience more than a science based on
fundamental foundations.
Q.4 Outline programming guidelines with regard to;
i) Control structures: In computer programming, a control structure is a programming language construct
which affects the flow of the program's execution.
For example, many language provide "if" statements, which allow the program to execute one set of code
if a statement is true, and another set of code if the statement is false. In the C programming language, this
might look like this:
if( x == 0 )
doSomething();
else
doSomethingElse();
Common control structures include while-loops, for-loops and if-statements, but there are many others as
well. The exact set of control structures depends on the programming language you're using.
ii) Algorithms: A step-by-step method of solving a problem or making decisions, as in making a diagnosis.
It is an established mechanical procedure for solving certain mathematical problems.
Prosperities of the algorithm
1) Finiteness: - an algorithm terminates after a finite numbers of steps.
2) Definiteness: - each step in algorithm is unambiguous. This means that the action specified by the step
cannot be interpreted (explain the meaning of) in multiple ways & can be performed without any
confusion.
3) Input :- an algorithm accepts zero or more inputs
4) Output :- it produces at least one output.
5) Effectiveness:- it consists of basic instructions that are realizable. This means that the instructions can be
performed by using the given inputs in a finite amount of time.
iii) Data structures: In computer science, a data structure is a particular way of storing and organizing data
in a computer so that it can be used efficiently.
Different kinds of data structures are suited to different kinds of applications, and some are highly
specialized to specific tasks. For example, B-trees are particularly well-suited for implementation of
databases, while compiler implementations usually use hash tables to look up identifiers.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 59/63
[59]
Data structures are used in almost every program or software system. Data structures provide a means to
manage huge amounts of data efficiently, such as large databases and internet indexing services. Usually,
efficient data structures are a key to designing efficient algorithms. Some formal design methods and
programming languages emphasize data structures, rather than algorithms, as the key organizing factor in
software design.
iv) General guidelines: This guidance applies to:
• Software used as a component, part, or accessory of a medical device;
• Software that is itself a medical device (e.g., blood establishment software);
• Software used in the production of a device (e.g., programmable logic controllers in manufacturing
equipment); and
• Software used in implementation of the device manufacturer's quality system (e.g., software that records
and maintains the device history record).
Q.5(a) What is software testing ? Describe the two ways of testing any engineered
software product
Ans. Software testing is an investigation conducted to provide stakeholders with information about the
quality of the product or service under test. Software testing also provides an objective, independent view
of the software to allow the business to appreciate and understand the risks of software implementation.
Test techniques include, but are not limited to, the process of executing a program or application with the
intent of finding software bugs (errors or other defects).
UNIT TESTING:: In computer programming, unit testing is a method by which individual units of source
code are tested to determine if they are fit for use. A unit is the smallest testable part of an application. In
procedural programming a unit may be an individual function or procedure. In object-orientedprogramming a unit is usually a method.[citation needed] Unit tests are created by programmers or
occasionally by white box testers during the development process.
INTERGATION TESTING:: Integration testing (sometimes called Integration and Testing, abbreviated "I&T")
is the phase in software testing in which individual software modules are combined and tested as a group.
It occurs after unit testing and before system testing. Integration testing takes as its input modules that
have been unit tested, groups them in larger aggregates, applies tests defined in an integration test plan to
those aggregates, and delivers as its output the integrated system ready for system testing.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 60/63
[60]
Q.5(b) What is the difference between verification and validation ?
Ans. Verification ensures the product is designed to deliver all functionality to the customer; it typically
involves reviews and meetings to evaluate documents, plans, code, requirements and specifications; this
can be done with checklists, issues lists, walkthroughs and inspection meetings. You CAN learn to do
verification, with little or no outside help.
Validation ensures that functionality, as defined in requirements, is the intended behavior of the product;validation typically involves actual testing and takes place after verifications are completed.
Difference between Verification and Validation:
Verification takes place before validation, and not vice versa. Verification evaluates documents, plans,
code, requirements, and specifications. Validation, on the other hand, evaluates the product itself. The
inputs of verification are checklists, issues lists, walkthroughs and inspection meetings, reviews and
meetings. The input of validation, on the other hand, is the actual testing of an actual product. The output
of verification is a nearly perfect set of documents, plans, specifications, and requirements document. The
output of validation, on the other hand, is a nearly perfect, actual product.
Q.6(a) Describe the different kinds of software development team structure
Ans. Waterfall development
The Waterfall model is a sequential development approach, in which development is seen as flowing
steadily downwards (like a waterfall) through the phases of requirements analysis, design, implementation,
testing (validation), integration, and maintenance. The first formal description of the method is often citedas an article published by Winston W. Royce[3] in 1970 although Royce did not use the term "waterfall" in
this article prototyping
Software prototyping, is the development approach of activities during software development, the
creation of prototypes, i.e., incomplete versions of the software program being developed.
Incremental development
Various methods are acceptable for combining linear and iterative systems development methodologies,
with the primary objective of each being to reduce inherent project risk by breaking a project into smallersegments and providing more ease-of-change during the development process.
Spiral development
The spiral model is a software development process combining elements of both design and prototyping-
in-stages, in an effort to combine advantages of top-down and bottom-up concepts. It is a meta-model, a
model that can be used by other models.
Q.6(b) What is COCOMO model? Explain the basic COCOMO model
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 61/63
[61]
Ans. The Constructive Cost Model (COCOMO) is an algorithmic software cost estimation model developed
by Barry Boehm. The model uses a basic regression formula, with parameters that are derived from
historical project data and current project characteristics.
COCOMO consists of a hierarchy of three increasingly detailed and accurate forms. The first level, Basic
COCOMO is good for quick, early, rough order of magnitude estimates of software costs, but its accuracy is
limited due to its lack of factors to account for difference in project attributes (Cost Drivers). Intermediate
COCOMO takes these Cost Drivers into account and Detailed COCOMO additionally accounts for the
influence of individual project phases.
Q.7(a) Define the terms: quality, quality assurance and quality control.
Ans. Quality:: Software quality measures how well software is designed (quality of design), and how well
the software conforms to that design (quality of conformance), although there are several different
definitions, including conformance to customer expectations. It is often described as the 'fitness for
purpose' of a piece of software.
Whereas quality of conformance is concerned with implementation (see Software Quality Assurance),
quality of design measures how valid the design and requirements are in creating a worthwhile product.
Quality Assurance:: Quality assurance, or QA for short, is the systematic monitoring and evaluation of the
various aspects of a project, service or facility to maximize the probability that minimum standards of
quality are being attained by the production process. QA cannot absolutely guarantee the production of
quality products.
Two principles included in QA are: "Fit for purpose" - the product should be suitable for the intended
purpose; and "Right first time" - mistakes should be eliminated. QA includes regulation of the quality of
raw materials, assemblies, products and components, services related to production, and management,
production and inspection processes.
Quality Control :: Quality control is a process by which entities review the quality of all factors involved in
production. This approach places an emphasis on three aspects.
Elements such as controls, job management, defined and well managed processes, performance and
integrity criteria, and identification of records Competence, such as knowledge, skills, experience, and
qualifications Soft elements, such as personnel integrity, confidence, organizational culture, motivation,
team spirit, and quality relationships.
Q.7(b) Mention the objectives of formal technical review.
Ans. A software technical review is a form of peer review in which "a team of qualified personnel ...
examines the suitability of the software product for its intended use and identifies discrepancies f rom
specifications and standards. Technical reviews may also provide recommendations of alternatives and
examination of various alternatives"
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 62/63
[62]
"Software product" normally refers to some kind of technical document. This might be a software design
document or program source code, but use cases, business process definitions, test case specifications,
and a variety of other technical documentation, may also be subject to technical review.
Technical review differs from software walkthroughs in its specific focus on the technical quality of the
product reviewed. It differs from software inspection in its ability to suggest direct alterations to the
product reviewed, and its lack of a direct focus on training and process improvement. The term formal
technical review is sometimes used to mean a software inspection.
Q.8. Write short notes on:
a) Software engineering: Software engineering (SE) is a profession dedicated to designing, implementing,
and modifying software so that it is of higher quality, more affordable, maintainable, and faster to build. It
is a "systematic approach to the analysis, design, assessment, implementation, test, maintenance and
reengineering of software, that is, the application of engineering to software."
b) The spiral model of software process:: The spiral model is a software development process combining
elements of both design and prototyping-in-stages, in an effort to combine advantages of top-down and
bottom-up concepts. Also known as the spiral lifecycle model (or spiral development), it is a systems
development method (SDM) used in information technology (IT). This model of development combines the
features of the prototyping model and the waterfall model. The spiral model is intended for large,
expensive and complicated projects.
c) Programming tools:: A programming tool or software development tool is a program or application that
software developers use to create, debug, maintain, or otherwise support other programs andapplications. The term usually refers to relatively simple programs that can be combined together to
accomplish a task, much as one might use multiple hand tools to fix a physical object.
8/12/2019 Assignment 5 Sem
http://slidepdf.com/reader/full/assignment-5-sem 63/63
~REFERENCES~
1.Course Materiel Provided.
2.http://www.javatpoint.com
3. http://www.tutorialspoint.com/unix/