Monday 24 August 2015

RAILWAY RESERVATION SYSTEM

1. INTRODUCTION:

1.1. PURPOSE:
The purpose of this source is to describe the railwayreservation system which provides the train timing details, reservation,billing and cancellation.

1.2. DOCUMENT CONVENTIONS:
Main headings: Bold
Not applicable

1.3INTENDED AUDIENCE AND READING SUGGESTIONS:
The different types of readers are:
Customers
Developers
Management people.

1.4PROBLEM DIFINITION AND PRODUCT SCOPE:
It consists of  
Train details
Reservation form
Billing
Cancellation.

2. OVERALL DESCRIPTION:

2.1. PRODUCT PERSPECTIVE:
It enables us to maintain the railway train details like their timings,number of seat available and reservation billing and cancelling the tickets.

2.2. PRODUCT FUNCTIONS:
It tells the short note about the product.

2.2.1. TRAIN DETAILS:
Customers may view the train timing at a date their nameand number of tickets.

2.2.2. RESERVATION:
After checking the number of seats available thecustomers reserve the tickets.

2.2.3. BILLING:
After reserving the required amount of tickets, thecustomer paid the amount.

2.2.4. CANCELLATION:
If the customers want to cancel the ticket, then half of theamount paid by the customer will be refunded to him.

3. USER CLASS AND CHARACTERISTICS:
Knowledgeable user
Novice user
Expert user

4. OPERATING ENVIRONMENT:
The OS types are
Windows NT
Windows XP
Windows 98
Linux

5. SOFTWARE CONSTRAINTS:
Designing -> Rational RoseDeveloping -> Visual Basic

6. USER DOCUMENTATION:
USER MANUAL:
Manual helps to understand the product details abouthow to work.
TUTORIALS:For beginners use.

7. EXTERNAL INTERFACE REQUIREMENTS:

7.1. USER INTERFACE:
Keyboard and Mouse.

7.2. HARDWARE INTERFACE:
Printer
Normal PC

7.3. SOFTWARE INTERFACE: 
Front end -> Visual Basic
Back end -> MS-Access

8. OTHER NON-FUNCTIONAL REQUIREMENTS:

8.1. PERFORMANCE REQUIREMENTS:
It is available during all 24 hours.

8.2. SOFTWARE SYSTEM ATTRIBUTES:
Reliable
Available
Secure


DATA FLOW DIAGRAM
Data Flow Diagram (DFD) is used widely for modelingthe requirement.
They have been used for many yearsprior to the advent of computer. DFDs show the flow of data through the system.
The system may be a company,an organization, a set of procedural, a computer hardwaresystem, a software system, or any combination of thepreceding.

Case diagram


Level 1 Data Flow Diagram :-




Question 3. How will you comment about the quality of a Software System? (20 Marks)
Ans: 
Software quality may be defined as conformance to explicitly stated functional and performance
requirements, explicitly documented development standards and implicit characteristics that are
expected of all professionally developed software.


The three key points in this definition: 

  • Software requirements are the foundations from which quality is measured. Lack of conformance to requirement is lack of quality.
  • Specified standards define a set of development criteria that guide the manager is software engineering. If criteria are not followed lack of quality will usually result.
  • A set of implicit requirements often goes unmentioned, for example ease of use, maintainability etc. If software confirms to its explicit requirement but fails to meet implicit requirements, software quality is suspected. 

Software Quality Factors
A software quality factor is a non-functional requirement for a software program, which is not
called up by the customer's contract, but it is a desirable requirement that enhances the quality
of the software program. Some software qualities factors are listed here:-
McCall Software Quality Model 

Product operation: 
Factors which are related to the operation of a product are combined.
These five factors are related to operational performance, convenience, ease of usage and its
correctness. 

The factors are:
  • Correctness: Extent to which a program satisfies its specifications and fulfils the user’s mission objectives.
  • Efficiency: Amount of computing resources and code required by a program to perform a function.
  • Integrity: Extent to which access to software or data by unauthorized persons can be controlled.
  • Reliability: Extent to which a program can be expected to perform its intended function with required precision.
  • Usability: Effort required learning, operating, preparing input and interpreting output of a program. 
Product Revision: These factors pertain to the testing & maintainability of software. They give
us idea about ease of maintenance, flexibility and testing effort.
Factors are:-
  • Maintainability: Effort required for locating and fixing a defect in an operational program.
  • Flexibility: Effort required for modifying an operational program.
  • Testability: Effort required for testing a program to ensure that it performs its intended functions.
Product Transition: We may have to transfer a product from one platform to another
platform or from one technology to another technology. The factors are given below:-
  • Portability: Effort required transferring a program from one hardware and/or software environment to another.
  • Reusability: Extent to which parts of a software system can be reused in other applications.
  • Interoperability: Effort required to couple one system with another. 
ISO 9126 Software Quality Model
There are six factors:-
Functionality has been subdivided into:
  • Suitability
  • Accuracy
  • Interoperability: The capability of the software to interact with one or more specified systems.
  • Security
Reliability has been subdivided into:
  • Maturity: The capability of the software to avoid failure as a result of faults in the software.
  • Fault Tolerance:
  • Recoverability:
Usability has been subdivided into: 
  • Understandability
  • Learnability
  • Operability
  • Attractiveness
Efficiency has been subdivided into:
  • Time Behaviour
  • Resource Utilization:
Maintainability has been subdivided into:
  • Analyzability: The capability of the software product to be diagnosed for deficiencies or causes of failures in the software or for the parts to be modified to be identified.
  • Changeability:
  • Stability: The capability of the software to minimize unexpected effects from modifications of the software.
  • Testability
Portability has been subdivided into:
  • Adaptability:
  • Installability
  • Coexistence
  • Replaceability

Monday 23 March 2015

Q1 Ten individuals are chosen at random, from a normal population and their weights (in kg) are found to be 63, 63, 66, 67, 68, 69, 70, 70, 71 and 71. In the light of this data set, test the claim that the mean weight in population is 66 kg at 5% level of significance.
Ans. Weighted mean = Σwx/Σw
Σ = the sum of (in other words…add them up!).
w = the weights.
x = the value.
To use the formula:
  1. Multiply the numbers in your data set by the weights.
  2. Add the numbers in Step 1 up. Set this number aside for a moment.
  3. Add up all of the weights.
  4. Divide the numbers you found in Step 2 by the number you found in Step 3.
Mean weight = 67.8 kg
Standard deviation = 8.16 kg
Z = (67.9 – 66) /8.16 kg = 0.2328
ZTable(Z) = 0.091      it is 9.1 % significance level.
So the claim that the mean weight in the population is 66 kg at 5% level of significance is WRONG.
Q2 I bought two packets of apples, 25 in each packet. The mean and standard deviation of weights of apples in the first packet are 235 and 3; and the mean and standard deviation for the second packet are 237.5 and 4. Write down the mean and standard deviation formulae for all the fifty
apples and compute them.
Ans. Apples in Each Packets – 25
Mean of First Packets – 235
Standard Daviation of Weight is – 3
Mean of second Packets – 237.5
Standard Daviation of Weight of second packets is – 4
Mean and Standard Deviation for all fifty apples are :
mean = Σwx/Σw
mean of Total = Σ(235 X3 )/Σ(237.5 X 4)
= 705/950
= 0.74
Q3 A consumer research organization tests three brands of tires to see how many miles they can be driven before they should be replaced. One tyre of each brand is tested in each of five types of cars. The results (in thousands of miles) are as follows: (10)
Type of car Brand A Brand B Brand C
I           6 9 4
II         3 2 7
III        2 3 6
IV        8 8 5
V         9 1 8
Compute the ANOVA and interpret your result.
Ans.
STEP 1:
Do the ANOVA table
d.fit <- aov(v~TR,data=d)
summary(d.fit)
Interpretation:
Makes an ANOVA table of the data set
d
, analysing if the factor
TR
has a signi
cant e
ect on
v
.
The function
summary
shows the ANOVA table.
> summary(d.fit)
Df Sum Sq Mean Sq F value Pr(>F)
TR 2 26.1667 13.0833 35.682 0.001097 **
Residuals 5 1.8333 0.3667

Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
STEP 2:
Decision:
Interpretation:
Exactly the same as for the “by hand” calculated tableWith
R
we do not have the critical values to a level, but we have the P
Q4 A building has 11 flats. A sample of 4 flats is to be selected using (i) linear systematic sampling and (ii) circular systematic sampling. List all possible samples for each of these cases (10)
separately.
N = 11
n = 4
N/n = 11/4 =2.75      nearest integer = 3
let k = 3
1) Linear systematic sampling
Let i = 1,  sample : 1, 4, 7, 10
i = 2,  sample :   2, 5 , 8 , 11
i =3 ,  sample :    3, 6, 9
2)  Circular systematic sample:
i = 1, sample:  1, 4,7,10
2                2,5,8, 11
3                 3,6,9,1
4                 4,7,10,2
5                 5, 8, 11, 3
6                 6,9,1, 4
7                 7,10,2,5
8                 8,11,3,6
9                 9,1,4,7
10               10,2,5,8
11,              11,3,6,9
Q5 Calculate Probabilities for following situations :
a) There are 1000 pages in a book out of which 100 pages are defective. What is the probability that out of first 50 pages 10 pages will be defective?
AnsProbability Functions
A probability function is a function which assigns probabilities to the values of a random variable.
  • All the probabilities must be between 0 and 1 inclusive
  • The sum of the probabilities of the outcomes must be 1.
If these two conditions aren’t met, then the function isn’t a probability function. There is no requirement that the values of the random variable only be between 0 and 1, only that the probabilities be between 0 and 1.
Probability Distributions
A listing of all the values the random variable can assume with their corresponding probabilities make a probability distribution.
A note about random variables. A random variable does not mean that the values can be anything (a random number). Random variables have a well defined set of outcomes and well defined probabilities for the occurrence of each outcome. The random refers to the fact that the outcomes happen by chance — that is, you don’t know which outcome will occur next.
Here’s an example probability distribution that results from the rolling of a single fair die.
x123456sum
p(x)1/61/61/61/61/61/66/6=1

Mean, Variance, and Standard Deviation
Consider the following.
The definitions for population mean and variance used with an ungrouped frequency distribution
BCS-040_1
Some of you might be confused by only dividing by N. Recall that this is the population variance, the sample variance, which was the unbiased estimator for the population variance was when it was divided by n-1.

What’s even better, is that the last portion of the variance is the mean squared. So, the two formulas that we will be using are:BCS-040_2
BCS-040_3
x123456sum
p(x)1/61/61/61/61/61/66/6 = 1
x p(x)1/62/63/64/65/66/621/6 = 3.5
x^2 p(x)1/64/69/616/625/636/691/6 = 15.1667
The mean is 7/2 or 3.5
The variance is 91/6 – (7/2)^2 = 35/12 = 2.916666…
The standard deviation is the square root of the variance = 1.7078
Q 5 b) A die is tossed twice. Getting an odd number in at least a toss is termed as a success. Find the probability distribution of number of successes. Also find expected number of successes.
Ans. Let S = event that at least an odd number is the outcome of n tosses. = success
Let F = event that no odd number turns out = failure
n =1, then in one toss, probability of an odd number turning out = 3/6 = 1/2
P(S) = 1/2   So P(F) = 1 – 1/2 = 1/2
The tosses of die are independent. The probabilities can be multiplied.
n = 2, two tosses,  P(S) = 1 –  ( P(Failure) in first toss * P(Failure) in 2nd toss)
= 1  – 1/2 * 1/2 = 1 – 1/4 = 3/4
probability distribution is
P(n,X) :   = 0   for n = 0
=  1/2  for  n = 1
=  3/4  for  n = 2
Q 5 c) Find the probability that at most 5 defective fuses will be found in a box of 200, if experience shows that 20% of such fuses are defective.
Ans. 20%of 200=40
so there are 40 fuses which are defective
the probability of finding 5 defectives= 5/40=1/8
Q6 Following data are given for marks in subject A and B in a certain examination :
SUBJECT A     SUBJECT B
MEAN MARKS                       36                               85
STANDARD DEVIATION      11                               8
Coefficient of correlation between A and B = ±0.66
  1. i) Determine the two equations of regression
  2. ii) Calculate the expected marks in A corresponding to 75 marks obtained in B
Ans. i)
The Regression Line
With one independent variable, we may write the regression equation as:
BCS-040_4
Where Y is an observed score on the dependent variable, a is the intercept, b is the slope, X is the observed score on the independent variable, and e is an error or residual.
We can extend this to any number of independent variables:
BCS-040_5
Note that we have k independent variables and a slope for each. We still have one error and one intercept. Again we want to choose the estimates of a and b so as to minimize the sum of squared errors of prediction. The prediction equation is:
BCS-040_6
Finding the values of b is tricky for k>2 independent variables, and will be developed after some matrix algebra. It’s simpler for k=2 IVs, which we will discuss here.
For the one variable case, the calculation of b and a was:
BCS-040_7
At this point, you should notice that all the terms from the one variable case appear in the two variable case. In the two variable case, the other X variable also appears in the equation. For example, Xappears in the equation for b1. Note that terms corresponding to the variance of both X variables occur in the slopes. Also note that a term corresponding to the covariance of X1 and X2 (sum of deviation cross-products) also appears in the formula for the slope.
The equation for a with two independent variables is:
BCS-040_8
This equation is a straight-forward generalization of the case for one independent variable
Ans.6 ii)In a cross between two heterozygous individuals, the offspring would be expected to show a 3 : 1 ratio. For example, in Case 1, three-fourths of the individuals would have red (wild-type) eyes, and one-fourth would have sepia eyes.
If there are 44 offspring, how many are expected to have red eyes?
We expect three-fourths to have red eyes.
If there are 44 offspring, how many are expected to have sepia eyes?

Q7A sample of 900 members has a mean 3.4 cm and standard deviation 2.61 cm. Test whether the sample is from a large population of mean 3.25 cm and standard deviation 2.61 cm. If the population is normal and its mean is unknown, find the 95% confidence interval for population mean.
Ans.
N_s = sample size = 900.         Î¼_s = mean of the sample = 3.4 cm
σ_s = Standard deviation of the sample = 2.61 cm
Population mean Î¼₀ =3.25
Population standard deviation = Ïƒ₀ = 2.61 cm
student’s t = (μ_s – Î¼₀) / [σ_s / √N_s ]
t  = (3.4 – 3.25) * √900 / 2.61 = 1.7241
Find the probability that     -1.7241 <= t <= 1.7241     from the students t distribution table or from a website that calculates these. Here the degrees of freedom (d.f) are 899.  Sample size is 900.
The probability  is 0.915.  Hence,  the sample belongs to the population with a probability 0.915  or  a  confidence level of 91.5%.
The population is normal.  we don’t  know its mean. We know sample size, mean and standard deviation.
Z = (μ_s – Î¼₀) / Ïƒ
Here Ïƒ_s = 2.61  cm
The value z of normal distribution variable Z for which the probability
P( -z < Z < z) = 95% = 0.95   is  z = 1.96
-1.96 * Ïƒ_s <= (μ_s – Î¼₀) <= 1.96 * Ïƒ_s
– 5.1156 <= (μ_s – Î¼₀) <= 5.1156 cm
If we take the value of Î¼_s = 3.4 cm then,
-1.7156  <= Î¼₀ <= 8.5156  cm
Q8 The mean yield for one acre plot is 662 kg with a s.d. 32 kg. Assuming normal distribution, how many one acre plot in a batch of 1000 plots would your expect to have yield between 600 and 750 kg.
Ans.The mean yield for one acre plot is 662 kg with a s.d 32kg .assuming normal distribution how many one acre plot in a batch of 1000 plots would your expect to have yield between 600 and 750 kg.

Saturday 28 February 2015

(i) A Palindrome is a string that reads the same forward and backward. Write an algorithm for determining whether a string of characters is palindrome.
Solution:-
C program to check whether it is a palindrome and also find the length of string
1. #include <stdio.h>
2. #include <string.h>
3.  
4. void main()
5. {
6.     char string[25], reverse_string[25] = {'\0'};
7.     int i, length = 0, flag = 0;
8.  
9.     printf("Enter a string \n");
        gets(string);
    /*  keep going through each character of the string till its end */
   for (i = 0; string[i] != '\0'; i++)
    {
        length++;
    }
    printf("The length of the string '%s' = %d\n", string, length);
    for (i = length - 1; i >= 0 ; i--)
    {
        reverse_string[length - i - 1] = string[i];
    }
   /*  Check if the string is a Palindrome */
    for (flag = 1, i = 0; i < length ; i++)
    {
        if (reverse_string[i] != string[i])
            flag = 0;

    }
    if (flag == 1)
       printf ("%s is a palindrome \n", string);
    else
       printf("%s is not a palindrome \n", string);
}
Output:-
Enter a string
  how  are you
The length of the string 'how  are you' = 12
how  are you is not a palindrome
-------------------------------------------------------------------
 Enter a string
   madam
 The length of the string 'madam' = 5
 madam is a palindrome
Algorithm:-
step 1 : start

step 2 : Declare variables char_string[25], reverse_string[25]
                    int i, length = 0, flag = 0;

step 3 : read value string.

step 4 : for (i = 0; string[i] != '\0'; i++)
         length++
step 5 : display 'the length of string =', string, length

step 6 : for (i = length - 1; i >= 0 ; i--)
        do reverse_string[length - i - 1] = string[i]
          /*  Check if the string is a Palindrome */

step 7 : for (flag = 1, i = 0; i < length ; i++)
                  if revers_string[i] ! = string[i]
                           do flag = 0
                        if flag == 1
                         display string is palindrome.
                         else 
                         display string is not palindrome.

step 8 : stop.
(ii) Find the largest number in an array and count a number of comparison operations as well as running time complexity of each statement and total complexity of the problem.
Solution:-
#include <stdio.h>
int main() {

    int i,n, count = 0;
    float arr[100];
    printf("Enter total number of elements(1 to 100): ");
    scanf("%d",&n);
    printf("\n");
    for(i=0;i<n;++i)  /* Stores number entered by user. */
    {
       printf("Enter Number %d: ",i+1);
       scanf("%f",&arr[i]);
    }

    for(i=1;i<n;++i)  /* Loop to store largest number to arr[0] */
    {
       if(arr[0]<arr[i]) /* Change < to > if you want to find smallest element*/
       {       
       count++;
       }
           arr[0]=arr[i];
    }
    printf("Largest element = %.2f \n",arr[0]);
    printf(“the number of comparison %d”, count);    
    return 0;
       getch();
}
Output:-
largestnum

Time Complexity of AlgorithmsTime complexity of an algorithm signifies the total time required by the program to run to completion. The time complexity of algorithms is most commonly expressed using the big O NotationTime Complexity is most commonly estimated by counting the number of elementary functions performed by the algorithm.
Calculating the Complexity
Now lets tap onto the next big topic related to Time complexity, which is How to Calculate Time Complexity. It becomes very confusing some times, but we will try to explain it in the simplest way.
Now the most common metric for calculating time complexity is Big O notation. This removes all constant factors so that the running time can be estimated in relation to N, as N approaches infinity. In general you can think of it like this:
statement;
Above we have a single statement. Its Time Complexity will be Constant. The running time of the statement will not change in relation to N
for(i=0; i &lt; N; i++)
              {
                     statement;
               }
The time complexity for the above algorithm will be Linear. The running time of the loop is directly proportional to N. When N doubles, so does the running time.
for(i=0; i &lt; N; i++)
    {
        for(j=0; j &lt; N;j++)
            {
              statement;
             }
    }
This time, the time complexity for the above code will be Quadratic. The running time of the two loops is proportional to the square of N. When N doubles, the running time increases by N * N.
(iii) Write a programme which interchanges the values the variable using only assignment operations. What is the minimum number of assignments operations required?
Solution:-
#include <stdio.h>
#include <string.h> 
/* Function Prototype */

void swap(int*, int *);
void main()
{
    int num1, num2;
printf("\nEnter two numbers:");
scanf("%d %d", &num1, &num2);
printf("\nThe numbers before swapping are Number1= %d Number2 = %d", num1, num2);
swap(&num1, &num2);   /* Call by Reference to function swap */
printf("\nThe numbers after swapping are Number1= %d Number2 = %d", num1, num2);

}
/* Code to swap two numbers using Assignment operator */
void swap(int *x, int *y)
  {
    *x = *x ^= *y;
    *y = *y ^= *y;
    *x = *x ^= *y;
}
Output:-
numsapThe minimum number of operator assigned is six because as we can see in the void swap function in that we used assignment operator six time to swap the value of num1 and num2.
(iv) Write a programme to do bubblesort to sort an array X={10,5,7,8,3,6,4,14} showing the
list obtained at each step. Also count no. of comparison operations in the programme
Solution:
#include <stdio.h>
int printAarray(int arr[]){
printf("\n Array at this stage = ");
for(int i=0; i<8; i++){
if(i==7){
printf("%d", arr[i]);
}else{
printf("%d, ", arr[i]);
}
}
printf("\n");
}
int main()
{
int X[]={10,5,7,8,3,6,4,14};
int n=8, c, d, swap, comp=0;
for (c = 0 ; c < ( n - 1 ); c++)
{
for (d = 0 ; d < n - c - 1; d++)
{
if (X[d] > X[d+1]) /* For decreasing order use < */
{
comp++;
swap = X[d];
X[d] = X[d+1];
X[d+1] = swap;
printAarray(X);
}
printAarray(X);
}
printAarray(X);
}
printf(" \n\n Sorted list in ascending
order:\n===================================\n");
for ( c = 0 ; c < n ; c++ ){
printf(" %d\n", X[c]);
}
printf("===================================\n Total Comparisons =
%d\n", comp);
return 0;
}
(v) Write a programme to find multiplication of matrices of order 4*4 and find the total
number of comparison, total no. of assignments, total number of multiplications and total
number of addition operations required in the programme.
Solution:
#include <stdio.h>
int main()
{
int a[4][4]={
{1,2,3,4},
{5,6,7,8},
{9,1,2,3},
{3,4,5,6}
} ;
int b[4][4]={
{1,2,3,4},
{5,6,7,8},
{9,1,2,3},
{3,4,5,6}
} ;
int c[4][4];
int sum, total_comparisons=0, total_assignments=0,
total_multiplications=0, total_additions=0;
//Multiplication Logic
for (int i = 0; i <= 3; i++) {
total_comparisons++;
for (int j = 0; j <= 3; j++) {
total_comparisons++;
sum = 0;
total_assignments++;
for (int k = 0; k <= 3; k++) {
sum = sum + a[i][k] * b[k][j];
total_comparisons++;
total_multiplications++;
total_additions++;
total_assignments++;
}
c[i][j] = sum;
total_assignments++;
}
}
printf("\nMultiplication Of Two Matrices :
\n================================\n");
for (i = 0; i <= 3; i++) {
for (int j = 0; j <= 3; j++) {
printf(" %d ", c[i][j]);
}
printf("\n");
}
printf("\nTotal Numbers (for logic only not for printing):
\n===============================================\n");
printf("\nTotal comparison \t:\t %d\n", total_comparisons);
printf("\nTotal assignments \t:\t %d\n",
total_assignments);
printf("\nTotal multiplications \t:\t %d\n",
total_multiplications);
printf("\nTotal addition \t\t:\t %d\n", total_additions);
return 0;
}