Sunday, 19 May 2013

KU Guess 4TH SEM TB - 44 - SOFTWARE ENGINEERING

KU Guess 4TH SEM TB - 44 - SOFTWARE ENGINEERING
PART – A
I. Fill up the blanks using suitable word or phrase in the following sentences:
1) Software is a set of_____________that when executed provide desired function
and performance.
Ans. INSTRUCTIONS OR COMPUTER PROGRAMS
2) Software is a process and _____________.
Ans.:- PRODUCT
3) The_____________method is also known as the iterative enhancement model.
Ans. INCREMENTAL MODEL
4) An external entity is represented using _____________ in a DFD.
Ans. EXTERNAL DESIGN INTERFACE
5) The software requirements deal with the_____________of the proposed system.
Ans.- REQUIREMENTS
6) The weakest coupling that is most desirable is _____________.
Ans.- DATA COUPLING
7) The three important levels of abstraction are _____________,_____________,
and_____________.
Ans. PHYSICAL LEVEL, LOGICAL LEVEL ,VIEW LEVEL
8) P.D.L. stands for_____________.
Ans. PROGRAM DESIGN LANGUAGE
9) _____________helps to view the source code.
Ans. BROWSING TOOLS
10) _____________tools help in code creation, debugging and testing.
Ans.- EXECUTABLE CODE
11) The two kinds of program documentation are _____________and_____________
Ans. – INTERNAL AND EXTERNAL
12) Estimation makes use of an important approach_____________.
Ans.- DECOMPOSITION
13) PERT stands for_____________.
Ans. :- PROGRAM EVALUATION AND REVIEW TECHNIQUE

II. Write brief answers to the following questions:
1) Define the terms risk mitigation, risk monitoring.
Ans.:- Risk mitigation refers to avoiding risks by developing a strategy for reducing the turn over thereby adopting a proactive approach to risks. Risk monitoring refers to monitoring the facts that may provide an indication of whether the risk is becoming more or less likely.
2) Name the important approaches used in program debugging.
Ans.:- There are three debugging approaches commonly used
- It occurs as a consequence of successful testing.
- When a test can uncovers an error, then debugging, a process that results in the removal of errors occur.
- Debugging process begins with the execution of test cases.
3) What are specification languages? Give an example.
Ans.:- specification languages posses many desired qualities of an SRS. Unlike formal languages of SRS must be exact, without ambiguity, and precise because the design specification, statement of work, and other project documents are what drive the development of the final product. Example :-Structured English, Regular Expression.
PART - B
1. a) What is software? List out the important characteristics of software.
Ans.:- Software is a set of instructions of computer programs that when executed provide desired function and performance. It is both a process and a product. To gain an understanding of software, it is important to examine the characteristics of software, which differ considerably from those of hardware.
Software Characteristic
1). Software is developed or engineered, it is not manufactured.
Unlike hardware, software is logical rather than physical. It has to be designed well before producing it. In spite of availability of many automated software development tools, it is the skill of the individual, creativity of the developers and proper management by the project manager that counts for a good software product.
2). Software does not “wear out”.
The hardware components start deteriorating – they are subjected to environmental maladies such as dust, vibration, temperature etc. and at some point of time they tend to breakdown. The defected components can then be traced and replaced.
3) Most software is custom-built, rather than being assembled from existing components
Most of the engineered products are first designed before they are manufactured. Designing includes identifying various components for the product before they are actually assembled. Here several people can work independently on these components thus making the manufacturing system highly flexible. in software , breaking a program into modules is a difficult task, since each module is highly interlinked with other modules.
b) Explain the waterfall model of software process. What are its limitations?
Ans.:-It is the simplest and the widely used process model for software development. Here the phases involved in the software development are organized in a linear order.
In a typical waterfall model, a project begins with the feasibility analysis. on successfully demonstrating the feasibility of a project, the requirements analysis and project planning begins. The design starts after completing the requirements analysis and coding starts after completing the design phase.
The limitations of waterfall model are:
nThe model states that the entire set of requirements should be frozen before development begins. This is possible for small projects, but is difficult for large projects where the exact requirements may not be known in advance.
nThe waterfall model requires formal documents after each phase. This is not possible in GUI-based applications where the documentation will be very extensive.
nThe customer sees the software only at the end of the development phase. As a result, the customer cannot suggest any changes until the product is delivered.
2. a) Describe the three generic views of software engineering.
Ans.:- The software engineering as such can be categorized in to three generic phases, regardless of application area, project size or complexity.
The three generic phases of software engineering are :-
 The definition phase
·
 The development phase
·
Formatted: Bullets and Numbering
 The maintenance phase
·
The definition phase 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 exists, and what validation criteria are required to define a successful system.
The development phase attempts to define how data are to be structured, how function is to be implemented as a software architecture, how produces are to be implemented, how design will be translated, into a programming language, how testing will be performed.
The maintenance phase focus on change that is associated with the software.
Correction:- it is likely that are customers will find errors or defects in the software in spite of quality assurance activities.
Adaptations – As time progress, it is likely that the original environment for which the software was developed is likely to change.
Enhancement – as software is used, the customer will recognize the need for additional functional requirements that will benefit him.
Prevention – computer software deteriorates due to change. so, preventive maintenance, often called software reengineering must be conducted in order to make changes to the computer software more easily.
b) List out the important characteristics of good SRS.
Ans.:- A good SRS should be:
nComplete
nConsistent
nAccurate
nModifiable
nRanked
nTestable
nTraceable
nUnambiguous
nValid
3. a) Give the outline structure of SRS.
Ans.:- The outline of SRS structure is:
Introduction
1.1 Purpose
1.2 Document conventions
1.3 Intended audience
1.4 Additional information Formatted: Bullets and Numbering
1.5 Contact information/SRS team members
1.6 References
Overall Description
2.1 Product perspective
2.2 Product functions
2.3 User classes and characteristics
2.4 Operating environment
2.5 User environment
2.6 Design/implementation constraints
2.7 Assumptions and dependencies
External Interface Requirements
3.1 User interfaces
3.2 Hardware interfaces
3.3 Software interfaces
3.4 Communication protocols and interfaces
System Features
4.1 System feature A
4.1.1 Description and priority
4.1.2 Action/result
4.1.3 Functional requirements
4.2 System feature B
Other Nonfunctional Requirements
5.1 Performance requirements
5.2 Safety requirements
5.3 Security requirements
5.4 Software quality attributes
5.5 Project documentation
5.6 User documentation
b) Why is design an important phase in software development life cycle? Describe
design process.
Ans.:- Design is an important phase in the software development life cycle because it bridges the requirements specification and the final solution for satisfying the requirements.
The software design is an activity which is after the requirements analysis activity. This phase begins when the requirements document for the system to developed is available. Design is an important phase in the software development life cycle, it bridges the requirements specification and the final solution for satisfying the requirements.
The design process for the software has two levels:-
1. System design or top-level design
2. Detailed design or logic design
System design
Using this, the modules that are needed for the system are decided, the specifications of these modules and how these modules need to be connected are also decided.
Detailed design
Using this, the internal design of the modules are decided or how the specifications of the modules can be satisfied are decided. This type of design essentially expands the system design to contain more detailed description of the processing logic and data structures so that the designs is sufficiently complete for coding.
4. Outline programming guidelines with regard to;
i) Control structures ii) Algorithms
iii) Data structures and iv) General guidelines
i) Control Structures :- Many of the control structures for a program component are given by the architecture and design of a system. And the given design is translated in to code. In case of some architecture, such as implicit invocation and object-oriented design, control is based on the system states and changes in variables.
ii) Algorithms:- The program design often specifies a class of algorithms to be used in coding. For example, the design may tell the programmer to use binary search technique. Even though, a programmer has lot of flexibility in converting the algorithm to code, it depends on the constraints of the implementation language and hardware.
iii) Data Structures :- Data structures can influence the organization and flow of a program. In some cases , it can even influence the choice of programming language. For example, LISP is a language for list processing. It is so designed that it contains structures that make it much easier for handling lists than other languages.
iv) General Guidelines :- there are several strategies that are useful in preserving the design quality of a program:-
 Localization input and output :- those parts of a program that read
· input or generate output are highly specialized and must reflect characteristics of the underlying hardware and software .
 Pseudo-code can be used for transforming the design to code through a chosen programming language.
·
 Revise the design and rewrite the code until one is completely satisfied with the result.
·
 Reuse code components if possible.
·
5. a) What is software testing ? Describe the two ways of testing any engineered
software product.
Ans.:- Software testing is the process of testing the functionality and correctness of software by running it.
The two ways of testing any engineered software product :-
1) White-Box Testing
2) Black-Box testing
Black-box testing
It is also known as functional testing. Knowing the specified function that the product has been designed to perform, tests can be conducted to demonstrate that each function is fully operational
Example :- Boundary value analysis.
White Box Testing
It is also known as structural testing. Knowing the internal working of product, test can be conducted to ensure that all internal operations perform according to specification that all internal components have been adequately.
EXAMPLE :- basic path testing.
b) What is the difference between verification and validation ?
Ans.:- Verification is a set of activities that ensures that the software correctly implements a specified function while Validation is a set of activities that ensures that the software that has been built, is traceable to the customer requirements.
6. a) Describe the different kinds of software development team structure.
Ans.:- The different kinds of software development team structure are:
nDemocratic decentralized team
nControlled centralized team
Controlled decentralized team
Democratic decentralized team
 It consists of ten or few number of programmers.
·
 The goals of the group are set by consensus
·
Formatted: Bullets and Numbering
 Every member is considered for taking major decision
·
 Group leadership rotates among group member
·
Controlled centralized team
 It consists of a chief programmer, who is responsible for all the
· major technical decisions of the project. He also does most of the design activities and allocates coding part to each and every member of the team.
 Under him, he has a backup programmer, program librarian, and programmers
·
 The backup programmer helps the chief in making decisions and takes over the role of chief in absence of the chief programmer.
·
 The program librarian is responsible for maintaining the documents and other communication related work.
·
Controlled decentralized team
 It combines the strength of the democratic and chief programmer teams
·
 It consists of a project leader who has a group of senior programmers
· under him and a group of junior programmers under a senior programmer.
 The communication between the senior and junior programmers are like ego-less team,
·
 This structure is best suited for every simple projects or research-type works.
·
b) What is COCOMO model? Explain the basic COCOMO model.
Ans.:-The COCOMO model predicts the effort and duration of a project based on inputs relating to the size of the resulting system and a number of “cost drivers” that affect productivity.
THE BASIC COCOMO MODEL
Basic COCOMO model estimates the software development effort using only a single predictor variable and three software development modes. Basic COCOMO is good for quick, early, rough, order of magnitude estimates of software costs, but its accuracy is necessarily limited because of its lack of factors which have a significant influence on software costs. The basic equation for the COCOMO model is about the effort estimate in persons –month required develop a project and the KLOC, the number of delivered lines of code for the project.
7. a) Define the terms: quality, quality assurance and quality control.
Ans.:- QUALITY:- Software quality is conformance to the explicitly stated functional and performance requirements, explicitly documented development standards, and implicit characteristics that are expected of all professionally developed software.
QUALITY ASSURANCE :- Quality assurance is an auditing and reporting function of management.
QUALITY CONTROL :- Quality control consists of a series of activities like inspections, reviews, and tests, which are carried out during the entire life cycle of software, so that each work product meets the requirements, placed upon it.
b) Mention the objectives of formal technical review.
Ans.:- This is a software quality assurance activity that is performed by software engineers.
OBJECTIVES
 To detect the errors in functions, logic or implementation found in software.
·
 To verify that the software under review meets its requirements.
·
 To ensure that the software has been represented according to predefined standards
·
 To achieve software with consistent quality and on time
·
 To make projects more manageable.
·
 It acts as a training ground for junior engineers to observe different approaches to software analysis, design, implementation
·
 FTR includes walkthroughs, inspections, round-robin reviews.
·
8. Write short notes on:
a) Software engineering
Ans.:-Software engineering is a discipline. It uses the existing tools and methods of software development and systematizes the entire process of software development. There are a number of formal definitions for software engineering, given by experts in the field. However for the purpose of understanding , we shall see some of them.
“The application of a systematic, disciplined, quantifiable approach to the development, operation, and maintenance of software, that is , the application of engineering to software “.
b) The spiral model of software process
Ans.:-The activities in this model can be organized like a spiral, that has many cycles. Typically the inner cycles represent the early phase of requirement analysis along with the prototyping and the outer spirals represent the classic software lifecycle.
This model has been divided into four quadrants, each quadrant representing a major activity like planning, risk analysis engineering and customer evaluation. The software process cycle begins with the planning activity represented by the first quadrant
of this model. Each cycle here begins with the identification of objectives for that cycle, the alternatives and constraints associated with that objective.
c) Programming tools.
Ans.:-programming tools is used to reduce time spent on the development of programs.
The tools which used in programming tools
1) source-code tools
- editing tools, these relate to the editing of source code
- browsing tools, helps to view the source code
The source-code beautifiers and templates not only makes a program look consistent but also standardize indentation styles, align variable declarations and format comments.
2) Executable code tools
Tools that are required for working with executable codes. it helps in code creation, debugging and testing
3) code creation has four major tools which help the developer in converting the source code into executable code :
4) Debugging tools help in debugging the code.
5) testing tools help in tracing the code errors.



Click Hear For New India  Awesome India.

UNIX & SHELL PROGRAMMING GUESS LAB 4TH SEM SOLUTIONS

UNIX & SHELL PROGRAMMING GUESS LAB  4TH SEM SOLUTIONS

1. Use the echo command to display the line UNIX is fun to learn
Ans :- echo "UNIX is fun to learn"

Redirect the displayed line to a file. Append the outputs of the commands to show the users logged into your system, your login account and the current date in the dd-mm-yyyy format to the file.
Ans :-who -u | cat > myfile
 date +'%d-%m-%Y' | cat > myfile

2. Assuming you have a directory containing the following files:
sprite, cola, choco, orange, book, lemon, lotus, apple
Use the ls command to list only those files that
a) consist of four letters
b) begin with the letter c
c) end with the letter e
d) have the second letter o
a)Ans :- ls ????
b)Ans :- c*.*
c)Ans :- *c.*
d)Ans :- ?o.*

3. For a file named myfile in the working directory, do the following:
a) give everyone permission to read myfile. No other privilege is to be changed
b) allow the owner and group members to read and write the file. All privileges are to be removed for everyone else.
c) remove write privileges from everyone except the owner
d) allow the owner and group members to execute myfile and give only the owner permission to read or write to it.
a)Ans :- chmod a+r myfile
b)Ans:- chmod 660 myfile
c)Ans:- chmod go-w myfile
d)Ans:- chmod 710 myfile , chmod ug=x,u+rw myfile

4. For a directory myfolder in your working directory, do the following:
a) allow everyone to list files in myfolder. No other privileges are to be changed.
b) allow the owner to and group members to list, remove or add files. All privileges are to be removed from everyone else.
c) give write privileges to everyone except the owner
d) allow the owner and group members to execute myfolder. Only the owner gets read or write permission.
a)Ans:- chmod a+rx myfolder
b)Ans:-chmod 770 myfolder
c)Ans:- chmod go+w myfolder
d)Ans:- chmod 710 my folder

5. Put a long-running process in the background and check the accuracy of the sleep command.
Ans:- date;sleep10;date$

6. The ls command with the –R option lists the files in the specified directory and also subdirectories, if any. Use this with a suitable pip-and-filter arrangement to determine whether a file exists in the account logged in.
Ans:- echo “Enter the name to search :”
read file
dat =’ls-R $ Home 1 grep $ file’
if [-s “$ dat”]
then
echo “$file File exist”
else
echo “$file File not exist”
fi

7. Write an interactive shell using I/O redirection to accept input from file1, put stdout in file2 and stderr in file3.
Ans:- echo “Enter input file name:”
read f1
echo “Enter output file name:”
read f2
echo “Enter error file name:”
read f3
cat <$f1 , cat >$f2 , cat >$f3

8. Write a shell program to extract and sort all the users in the file system. Use the /etc/passwd file as input.
Ans:- first (with pipe and filter)
Cut –d ”:” –f1/etc/passwd | sort
Second (without pipe and filter)
Cut –d “:” –f1/etc/passwd>tmp sort<temp

9. Write a shell program to translate the /etc/passwd file into uppercase and translate
the “:” delimiter into tab characters.
Ans:- tr ”[a-z:]” “[A-Z:]” </etc/passwd

10. Write a shell program using if-the-else to test whether a variable name is a directory or a file.
Ans:- echo “Enter a name”
read name
if [-f $name]
then
echo “$name is a file”
then
echo “$name is a directory”
else
echo “$name is not a file nor a directory.”
fi

11. Write a shell program in which an infinite loop prompts a user for file names to be removed and remove the files. Use trap to exit when finished.
Ans:- trap ‘exit’ INT
While [true]
do
echo “Enter filename to be deleted (ctr+c to exit)”
read file
rm $file
done

12. Write a background command to edit all the files in the directory replacing the word while with until.
Ans:- replace while until __*s

13. Write a shell program to test for arguments arg1, arg2 and arg3. If they are not present, prompt the user for them.
Ans:- if [$ # -lt 3]
then
arg=’expr $ # +1’
while [$ arg –le 3]
do
echo “Enter argument number $arg:”
read val
set $* $val
arg=’expr $arg +1’
done
fi
echo “Argument on command line entered by you are:”
echo $*

14. Write a shell program that adds the integers 1 to 100 and displays the result with a suitable message.
Ans:- s=0
c=1
while [$c-le 100]
do
s=’expr $s + $c’
c=’expr $c + 1’
done
echo “Sum of 1 to 100 is $s”

15. Using awk, sum the file sizes in your working directory and print the results.
Ans:- awk ’ {total += length ($0)}
END ‘{Print total}’ * (sameline)

16. Using a case statement, write a shell program to read a command (eg., who, cal, ls, ps) from the user and execute it.
Ans:- echo “Enter any command:”
read com
case $com in
who ) who;;
cal) cal;;
ls) ls;;
ps) ps;;
*) echo “Invalid command”
esac.

KU Guess 4TH SEM Algorithms

KU  4TH SEM: TB - 41 - ALGORITHMS
PART – A
I. Say whether the following statements are true or false.
1) Definiteness is one of the properties of an algorithm.
Ans:- TRUE
2) Graph is a linear data structure.
Ans :- FALSE
3) A tree is a connected graph.
Ans:- TRUE
4) The data structure used by recursion is stack.
Ans :- TRUE
5) Queue works on the strategy “First in First out”.
Ans :- TRUE

II. Using suitable word or phrase fill up the blanks in the following sentences:
1) _____________is the process of executing a correct program on data sets and
measuring the time and space.
Ans:- PROFILING
2) Tree is a_____________data structure.
Ans:-NON-LINEAR
3) For a graph with „n‟ number of nodes the number of edges to form a tree is
_____________
Ans: - n-1
4) “Last in First out” Data structure is referred to as _____________
Ans :- Stacks
5) A binary tree of depth „K‟ has maximum of_____________number of
nodes.
Ans : - 2k-1nodes,k>= 0
6) A _____________is a graph without self loop and parallel edges.
Ans. SIMPLE GRAPH
7) The two methods of searching are_____________and_____________
Ans.:- SEQUENTIAL SEARCH AND BINARY SEARCH

III. Write brief answers to the following questions:
1) Define algorithm. What are its properties?
Ans :- An algorithm is a set of instructions that provide step-by-step specifications to perform a task.
Ex:-
Step by step procedure for display 10 natural numbers:-
1. Set the value of counter to 1
2. Display counter
3. Increment counter by 1
4. If counter <= 10, go to step 2
The preceding step -by -step procedure is an algorithm because it produces the correct result in
A finite number of steps.
The properties of an algorithm are:
 Input: Specifies the data set that is applied to the algorithm to check its validity.
·
 Output: Specifies the data set that is produced as a result of the algorithm execution.
·
 Definiteness: Specifies that the instructions described in the
· algorithm should be well defined and should not create any ambiguity.
 Termination: Specifies that the instructions described in the algorithm must contain a proper termination condition.
·

 Effectiveness: Specifies that the algorithm take less time and less memory space during its execution.
·
2) Give atleast four real life examples where we use stack operations.
Ans:- The real life examples of stacks are:
 Bangles in a hand: The bangles wore in a hand follow last-in-first-out
n (LIFO) strategy of stack. The bangle that you wear first is the last one to be taken out while removing all the bangles from the hand. The bangle that is worn last is the first one to be taken out.
 Same circumference circular rings in a pole: The rings having same
n
circumference placed into a pole also follow LIFO strategy. The topmost ring, which was the last to be placed in the pole, is the first one to be taken out.
 The bolts screwed to a single nut: When the bolts are screwed to a
n
single nut, the last screwed bolt is unscrewed first and the bolt that was screwed first is unscrewed in the last.
 Battery cells in a torch: The battery cells in a torch also follow the same LIFO strategy of stack.
n

3) Differentiate full and complete binary trees.
Ans:- The following table lists the differences between complete binary trees and full binary trees: Complete binary trees Full binary trees
All the nodes at the previous level are fully accommodated before the next level is accommodated.
All levels are maximally accommodated.
Number of nodes at the last (n) level may or may not equal to 2n.
Number of nodes at the last (n) level is exactly equal to 2n.
Leaf nodes may or may not be at the same level.
All leaf nodes are at the same level.
A complete binary tree may or may not be full binary tree.
A full binary tree is always a complete binary tree.
4) What are the demerits of recursion?
Ans:- Demerits of recursion are:
Many programming languages do not support recursion; hence, recursive mathematical function is implemented using iterative methods.
Even though mathematical functions can be easily implemented using recursion, it is always at the cost of execution time and memory space.
The recursive programs take considerably more storage and take more time during processing.
PART - B
1. a) What are the characteristics of an algorithm? Describe with an example.
Ans:- There are five Characteristics of every Algorithm: -
1) INPUT
2) OUTPUT
3) DEFINITENESS
4) Effectiveness
5) Termination
Therefore, an algorithm can be defined as a sequence of definite and effective instructions, which terminates with the production of correct output from the given input.
For EXAMPLE:- try to present the scenario of a man brushing his own teeth as an algorithm as follows :-
1). Take the brush
2). Apply the paste
3). Start brushing
4). Rinse
5). Wash
6). Stop
If one goes through these 6 steps without being aware of the statement of the problem, he could possibly feel that this is the algorithmfor claning a toilet. This is because of several ambiguities while comprehending every step. Step-1 may imply tooth brush,paint brush, toilet brush, etc. uch an algorithm arises from the instruction of the above algorithm step.thus every step has to be made unambiguous.An unambiguous step is called definite instruction.
b) Write an algorithm to implement any three operations of a queue.
Ans:- 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:
If (R==SIZE)
Return (yes)
Else
Return (no)
If end
Algorithm ends
Algorithm: Front
Input: Q, Queue
Output: element in the front
Method:
If (Isempty (Q))
Print „no front element‟
Else
Return (Q[F])
If end
Algorithm ends
2. a) Describe the two methods of representing a graph.
Ans :- Two ways of representating Graph
DIRECTED GRAPH :- A graph that has an ordered pair of vertices, (x,y). Here , X is the tail and y is the head of the edge. There is a path from vertex X to vertex Y. However , a path from y to x may or may not exist . A path from y to x will be represented by e = (y, x) . Therefore , e = (X , Y) and e = (Y , X) are to seprate edges for a directed graph.
DIRECTED GRAPH
The graph contains five vertices,namely,v1,v2,v3,v4, and v5. The graph contains four directed edges,namely,(v1,v2) , (v2,v3) , (v4,v3) , (v4,v1) , (v4,v5) , and (v5,v1).
UNDIRECTED GRAPH :- A graph that has an unordered pair of vertices representing an edge. This means that if e = (v ,w) ,then (v, w) and (w ,v) are considered as the same edge.
For EX :-
UNDIRECTED GRAPH
b) Design an algorithm to generate all prime numbers between 10 and 20.
Ans.:- Algorithm: Primality_Testing (Second approach)
Input : between 10 & 20 , number
flag, test condition
Output : flag updated
Method
flag = 0
for(i=2 to square_root(n) in 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 is not prime‟
end_if
Algorithm ends
3. a) Trace out the algorithm Max Min on a data set containing atleast 8 elements.
Ans:- Steps to perform MaxMin on a data set (2,4,6,3,8,1,9,7) are:
(2,4,6,3) (8,1,9,7)
((2,4)(6,3)) ((8,1)(9,7))
In sublist (4,6), max is 6 and min is 4. In sublist (8,9), max is 9 and min is 8.
Comparing max and min values of sublist (2,4) and sublist (6,3), value of max is 6 and min is 2.
Therefore, for sublist (2,4,6,3) max is 6 and min is 2.
Similarly, comparing max and min values of sublist (8,1) and sublist (9,7), value of max is 9 and min is 1.
Therefore, for sublist (8,1,9,7) max is 9 and min is 1.
Finally, comparing max and min values of sublist (2,4,6,3) and sublist (8,1,9,7), value of max is 9 and min is 1.
b) Design an algorithm to sort the elements using merge sort.
Ans:- Algoritm : MERGESOt
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)
Ifend
Algorithm ends
4. What are preorder, Inorder, postorder traversals of a binary tree? Design recursion
algorithms to implement them and explain with the help of an example.
Ans:- Traversal is the most important operation done on a binary tree. Traversal is the process of visiting the verticesof the tree in a systematic order. Systematic means that every time the tree is traversed it should yield the same result.
PRE-ORDER TRAVERSAL
In 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 lleaf nodes represent the stopping criteria. We go to the sibling sub-tree after the traversal of a sub tree.
IN-ORDER Traversal
In this traversal , the nodes are visited in the order of the 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 left nodes denotes the stopping criteria.
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 recursion algorithm
Algorithm: Pre-order Traversal
Input: bt, address of the root node
Output: Preorder sequence
Method:
if(bt != NULL)
{
Display([bt].data)
Pre-order Traversal([bt].Lchild)
Pre-order Traversal([bt].Rchild)
}
Algorithm ends.
Algorithm: In-order Traversal
Input: bt, address of the root node
Output: Inorder sequence
Method:
if(bt != NULL)
{
In-order Traversal([bt].Lchild)
Display([bt].data)
In-order Traversal([bt].Rchild)
}
Algorithm ends.
Algorithm: Post-order Traversal
Input: bt, address of the root node
Output: Postorder sequence
Method:
if(bt != NULL)
{
Post-order Traversal([bt].Lchild)
Post-order Traversal([bt].Rchild)
Display([bt].data)
}
Algorithm ends.
5. a) What is binary search? Develop a recursive algorithm for binary search.
Ans:- Binary search is necessary to have the vector in an alphabetical or numerically increasing order .
Consider an example where we have to search for the name Steve in a tlephone directory that is sorted alphabetically . in this case ,we donot search for the name sequentially .instead, we open the telephone directory at the middle to open the telephone directory at the middle to determeine which half contains the name.
Recursive algorithm for binary search
Algorithm : Binary search
Input: A,vector of n elements
K,earch elements
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;
b) What are the two methods of representing a binary tree?
Ans:- The two methods of representing binary tree are:-
 Static allocation and,
·
 Dynamic allocation
·
In static allocation ,we have two ways of representing the binary tree.one is through the use of adjacency matrices and other through the use of single represention dimensional array representation.
6. a) Design an algorithm to check whether a given string is a palindrome or not.
Ans :- Algorithm: check whether the string is a palindrome or not
Input: string, flag
Output: string is a palindrome
Method:
count = 0
while (the next character ch in the string is not empty)
a(count) = ch
count = count+1
end while
half = count/2palin = true
for (i=1 to half in steps of 1 and j=count to half in steps of –1 do)
if (a (i)! =a (j))
palin = false
break
end if
if (palin = true)
Display 'String is a palindrome'
else
Display 'String is not a palindrome'
end if
end for
Algorithm ends
b) Trace out the algorithm quick sort on the data set {1,5,7,19,15,8,9, 10}.
Ans :-
{(1),5,7,19,15,8,9, 10}
{(1),5,7,15,19,8,9, 10}
{1,5,7,(15),10,8,9, 19}
{1,5,7,(10),15,8,9, 19}
{1,5,7,(10),8,15,9, 19}
{1,5,7,8,10,15,9, 19}
{1,5,7,8,10,9,15, 19}
{1,5,7,8,9,10,15, 19}
7. a) What is validation and testing of algorithms?
Ans :- Validating:- Once an algorithm has been devised it become necessary to show that it works it computer the correct to all possible, legal input. One simply way is to code into a program. However converting the algorithm into program is a time consuming process. Hence,it is essential to be reasonably sure about the effectiveness of the algorithm beforeit is coded. This process, at the algorithm level,is called"validation". Several mathematical and other empirical method of validation are available. Providing the validation of an algorithm is a fairly complex process and most often a complete theoritical validation though desirable, mey not be provided. Alternately, algorithm segment,which have been proved elsewhere may be used and the overall working algorithm may be empirically validated for several test cases.And, The process of measuring the effectiveness of an algorithm before it is coded to know the algorithm is correct for every possible input.This process is called validation.
Example :- This article describes the algorithms for validating bank routing numbers and credit card number using
the checksum built into the number. While they differ in how they are generated, the technique used for both is similar.
Testing : - The test of an algorithm is that the program 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 datasets 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 of executing a correct program on different data sets to mesure the time and space that it takes to compute the results.
b) Explain the terms with examples
i) Finite graph
Ans:-A graph with a finite number of vertices as well as finite number of edges is called a finite graph.
Finite graph
ii) Isolated and pendent vertices
Ans :- A vertex having no incident edge is called an isolated vertex. Vertex v4 and v7 are isolated vertices(in fig). A vertex of degree one is called a pendent vertex or an end vertex. Vertex v3 is pendent vertex (in fig).
Graph ontaining isolated vertices and pendent vertex
iii) NULL graph
in the definition of a graph G = ( V , E) it is possible for the edge set E to be empty. Such a graph , without any edges, is called a null graph.
iv) Path.
Ans.:- if a walk has the restriction of no repetition of vertices and no edge is retraced it is called a path.
8. Write short notes on :
a) Debugging
Ans.- 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 desired results. On the other hand, profiling or performance measurement is the process of executing a correct program on different data sets to measure the time and space that it takes to compute the results.
b) The need for recursion
Ans.:- The need of recursion is :
1) Mathematical functions such as factorial and fibonaci series generation can be easily implemented using recursion than iteration.
2) in iterative techniques looping of statement is very much necessary..
c) Incidence matrix.
Ans.:- The incidence matrix contains only two elements , o and 1. Such a matrix is called a binary matrix or a (0,1) matrix. Since every edge is incident on exactly two vertices, each column of a has exactly two 1.The number of 1‟ in each now equals the degree of the corresponding vertex. A row with all 0‟ , therefore ,represents an isolated vertex. Parallel edges in a graph produce identical columns in its incidence matrix.

Sunday, 12 May 2013

Java programming language basic

Java programming language was originally developed by Sun Microsystems, which wasinitiated by James Gosling and released in 1995 as core component of Sun Microsystems.s Java platform (Java 1.0 [J2SE]).As of December 08 the latestrelease of the Java Standard Edition is 6 (J2SE).

With the advancement of Java and its wide spread popularity, multiple configurations were built to suite various types of platforms. Ex: J2EE for Enterprise Applications, J2MEfor Mobile Applications.Sun Microsystems has renamed the new J2 versions as Java SE, Java EE and Java ME respectively. Java is guaranteed to be Write Once, Run AnywhereJava is:Object Oriented : In javaeverything is an Object. Java can be easily extendedsince it is based on the Object model.Platform independent: Unlike many other programming languages including C and C++ when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code.

This byte code is distributed over the web andinterpreted by virtual Machine (JVM) on whichever platform it is being run.Simple : Java is designed to be easy to learn. If you understand the basic concept of OOP java would be easy to master.Secure : With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption.Architectural- neutral :

Java compiler generates anarchitecture-neutral object file format which makes the compiled code to be executable on many processors, with the presence Java runtime system.Portable : being architectural neutral and having no implementation dependent aspects of the specification makes Java portable. Compiler and Java is written in ANSI C with a clean portability boundary which is a POSIX subset.Robust : Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.Multi-threaded : With Java's multi-threaded feature it is possible to writeprograms that can do many tasks simultaneously.

This design feature allows developers to construct smoothly running interactive applications.Interpreted : Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and light weight process.High Performance: With the use of Just-In-Time compilers Java enables high performance.Distributed : Java is designed for the distributed environment of the internet.Dynamic : Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that canbe used to verify and resolve accesses to objects on run-time.

History of Java:James Gosling initiated the Java language project in June 1991 for use in one of his many set-top box projects. The language, initially called Oak after an oak tree that stood outside Gosling's office, also went bythe name Green and ended up later renamed as Java, from a list of random words.Sun released the first public implementation as Java 1.0 in1995. It promised Write Once, Run Anywhere (WORA), providing no-cost run-times on popular platforms.On 13 November 2006, Sun released much of Java as free and open source software under the terms of the GNU General Public License (GPL).

On 8 May 2007 Sun finished the process, making all of Java's core code free and open-source, aside from a small portion of code to which Sun did not hold the copyright.Tools you will need:For performing the examplesdiscussed in this tutorial, you will need a Pentium 200-MHz computer with a minimum of 64 MB of RAM (128 MB of RAM recommended).You also will need the following softwares:Linux 7.1 or Windows 95/98/2000/XP operating system.Java JDK 5

JSP vs. JavaScript JavaServer Pages (also known as JSP) is a Java based technology specifically used to help software developers serve dynamically generated web pages (such as HTML and XML), as well as other document types pertinent to the development of interactive web content. It was specifically created in order to answer the scepticism that most web developers had concerning the Java platform’s ability to give developers enough support for the web. JavaScript is a scripting language that is object oriented (that is a programming paradigm implemented through the use of objects, or data structuresthat are comprised of datafields and methods). It is used to give programmatic access to objects that are found in both client application and other applications pertinent to the running of a specific program.It was intentionally created client-side (meaning, client orientated and run) in order to provide support for dynamic websites. For all intents and purpose, JSP is a sophisticated Java servlet. JSPs are loaded into the server, and from the Java EE Web application, operated and packaged as.war or .ear file archives. It allows Java code and specificpredefined actions to communicate with static web markup content. The page that results from this interaction is compiled and executed on this specific server, and is viewed as an HTML or XML document. It is comprised of two very specific syntax styles: scriptlet and markup – a scriptlet simply being blocks of Java code that are mixed with markup, which is the standard HTML or XML. JavaScript is a Java language; however, it is of a different dialect. It makes useof the ECMASCript standard and is considered a dynamic, weakly typed, prototype based language that just so happens to have first class functions. This suggests the extent to which many different languages have hadon JavaScript; however, it was designed to appear as Java – only in a format that is more feasible for non-programmers to work with. JSP pages are required to becompiled to Java bytecode classes in order to be able tobe executed. However, this compilation only really occurs one time – each time a change takes place to the source JSP file. This is because Java is a compiled language, and not a scripting language – meaning the code must, essentially, be translated to make the JSP compatible with the server. Summary: 1. JSP is a Java-based technology used specifically in order to help software developers create dynamic web pages; JavaScript is based on Java, but was created in order to allow non-programmers the ability to work with it easily. 2. JSP must be compiled in Java bytecode in order to function properly; JavaScript is a Java language of a different dialect, and does not need to be directly translated into bytecode.

Tu hi ye mujhko bata de Chahoon main ya na Apne tu dil ka pata de Chahoon main ya na.. Tu hi ye mujhko bata de Chahoon main ya na Apne tu dil ka pata de Chahoon main ya na Itna bata doon tujhko Chahat pe apni mujhko Yun to nahi ikhtiyaar Phir bhi yeh socha dil ne Ab jo laga hoon milne Poochhoon tujhe ik baar.. o.. Tu hi ye mujhko bata de Chahoon main ya na Hmm.. Apne tu dil ka pata de Chahoon main ya.. na.. Aisi.. kabhi pehle Hui na thi khwaahishein O.. Kisi se bhi milne ki Na ki thi koshishein.. Uljhan meri suljha de Chahoon main ya na Aankhon aankhon mein jataa de Chahoon main ya na Mere chhote chhote khwaab hain Khwaabon mein geet hain Geeton mein zindagi hai Chahat hai, preet hai Abhi main na dekhoon khwaabko Jin mein na tu mile Ni khole honth maine Ab tak the jo sile Mujhko na jitna mujh pe Utna is dil ko tujh pe Hone laga aitbaar.. Tanha raahon mein apne Bunti hoon tere sapne Tujhse hua mujhko pyaar o.. Poochhoongi tujhko kabhi na Chahoon main ya na Tere khwaabon mein ab jeena Chahoon main ya na Tu hi ye mujhko bata de Chahoon main ya na Apne tu dil ka pata de Chahoon main ya na

Tuesday, 12 March 2013