Sunday, May 5, 2019

Modularity Versus Efficiency.

Modularity Versus Efficiency:
  1. Tests and systems both are considered as the modular components. since each of them are made of separate modules.
  2. A module is a defined by a distinct and small component that has a well defined purpose.
  3. It is very easy to understand the systems if the component used for constructing the system is small.
  4. Each component interacts with the other by means of interfaces.
  5. Testing process can be done / performed in the form of  modular components.
  6. Small tests are very easy to re-execute.
  7. When a bug is detected , only the small tests rather than larger test components consisting of many independent tests are execute.
  8. At the same time when a particular test has the bug then only that test was change rather than modifying the entire test plan.
  9. each test is designed in order to reduce the burden of the test design , test debugging and test execution.

Tester Versus Designer.

S.NO

                 Tester

                Designer

1)

Tester is based on the functional specifications of the system.

Designer is based on the structural specification of the system.

2)

He/she is independent on the implementations details.

He/she is dependent of the implementation details.

3)

Software tests are responsible for testing/ executing the tests.

Software designer are responsible for designing and executing the tests.

4)

Due to the lack of efficiency / implementation details , the software developed is inefficient.

The knowledge of implementation details makes the designer to develop a software that is efficient.

5)

The increase of knowledge of tests design increases the probability of removing  or eliminating unnecessary tests.

The increase of knowledge of design increases the probability of generating the faulty design.

6)

Tests are executed by the tester are free from bias therefore it is not possible to terminate the tests.

Tests are executed by the software designer are biased to the structural specification because of which the tests must withstand the drawback of structural testing.

 

Saturday, May 4, 2019

Small Versus Large and Testing Versus Debugging

S.No

                Small

                         Large

1)

Small programs comprises of few lines of code.

Large programs comprises of large number of components.

2)

They have the phases like designing , coding , testing and debugging.

They have the data dictionary to store the data and then performs the unit testing.

3)

Small programs are more efficient when compared with the large programs.

Large programs are less efficient when compared  with the small programs.

4)

The quality of the program is high.

The quality of the large programs  is always low.

5)

They do not need different techniques for testing.

They need different techniques for testing.

6)

It consists of a few components.

It consists of the large number of components.

7)

These are written by the single programmer.

These are written by the different programs.

 

S.NO

                  TESTING

                 DEBUGGING

1)

The goal of testing is to detect errors.

The goal of debugging is to detect errors and correct them.

2)

The output can be predicted.

The output cannot be predicted.

3)

Testing is a confirmation or perceptible accuracy.

Debugging is a deductive process.

4)

Testing can be planned and should be designed and then scheduled.

Procedure and duration of debugging cannot be so constrained.

5)

Testing proves the programmer’s failure.

Debugging is the programmer vindication

6)

Much of testing can be often performed by person who does not belong to the company.

Debugging cannot be performed by the person belonging to the company and has knowledge about designing and outside environment.

7)

Most of the testing can be done without a  design knowledge.

Debugging is impossible without having a detailed design knowledge.

8)

Much of test execution and design can be automated.

Automated debugging is a still a dream

 

Friday, May 3, 2019

Write a JAVA program to sort for an element in a given list of elements using bubble sort?

program:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class BubbleSort
{
public static void main(String a[])throws IOException
{
int arr[]=new int[100];
int n,k,i,j,temp;
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter the size of an array:");
n=Integer.parseInt(br.readLine());
System.out.println("Enter"+n+"number of elements:");
for(k=0;k<n;k++)
{
arr[k]=Integer.parseInt(br.readLine());
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.println("Sorted array is:");
for(k=0;k<n;k++)
{
System.out.println(arr[k]);
}
}

}

output:-



Write a C program to print the Pascal Triangle.

program:

#include<stdio.h> 
main()
{
    int i,j,n,k,sp; int c;
    printf("Enter the no.of lines that you wanted to print:"); 
    scanf("%d",&n);
    sp=n; 
    for(i=0;i<n;i++)
    {
        c=1;
        for(k=sp;k>=0;k--)
        {
            printf(" ");
        }
        sp--;
        for(j=0;j<=i;j++)
        {
            printf("%8d",c);
            c=c*(i-j)/(j+1);
        }
        printf("\n");
    }
}
output:

Write a C program to print the Floyd Triangle.

program:

#include<stdio.h> 
main()
{
    int n,i,j,k;
    printf("enter a number:"); 
    scanf("%d",&n);
    k=1;
    for(j=1;j<=n;j++)
    {
        for(i=1;i<=j;i++)
        {
        printf(" %d ",k); k++;
        }
        printf("\n");
    }
}
output:-

Write a C program to check whether a given number is prime number or not.

program:


#include<stdio.h> 
main()
{
    int n,i,count=0; 
    printf("enter a number:"); 
    scanf("%d",&n); 
    for(i=2;i<n;i++)
    {
        if(n%i==0)
        {
            count++;
        }
    }
    if(count==0)
    {
        printf("the given number is a prime\n"); 
    }
    else
    {
        printf("the given number is not a prime\n");
    }
}

 output:



Write a C program to check whether a given number is an Armstrong or not.

Program:

#include<stdio.h> 
main()
{
    int n,temp,rem,sum=0; 
    printf("enter a number:-"); 
    scanf("%d",&n);
    temp=n; 
    while(n!=0)
    {
        rem=n%10; 
        sum=sum+(rem*rem*rem); 
        n=n/10;
    }
    if(temp==sum)
    {
        printf("given number is armstrong\n");
    }
    else
    {
        printf("given number is not armstrong\n");
    }
}

output:-


Write a Program in C to check whether the given number is a palindrome or not.

program:

#include<stdio.h> 
main()
{
    int a,temp,rem,rev=0; 
    printf("enter a number:\n"); 
    scanf("%d",&a);
    temp=a; 
    while(a!=0)
    {
        rem=a%10; 
        rev=(rev*10)+rem; 
        a=a/10;
    }
    if(temp==rev)
    {
        printf("the given no.is a palindrome \n");
    }
    else
    {
        printf("the given no. is not a palindrome \n");

    }
}

output:





Thursday, May 2, 2019

Differentiate Between Good State Graph and Bad State Graph.

S.No

               Good State Graph

                  Bad State Graph

1)

A state graph is said to be good , when every state , input , transition and output is specified clearly and understandable.

A state graph is said to be bad , when every state , input , transition and output is not specified clearly and difficult to understand.

2)

In good state graph the sequence of inputs is specified for every state in order to perform some action and that will help the system to get back to the initial state.

In bad state graph , there is no sequence of inputs specified , and this result to be the incorrect output.

3)

It has exactly one transition one specified for every state and input combination so that the transition bugs may not occur

There might be either none or more than one transition specified for every state input combination , and this causes the transition bugs to take place.

4)

Here only one output action is specified for every transition because of single output gives best result rather than different outputs.

Here there might be none or more than output action specified for every transition that results to an inappropriate state graph.  

5)

In good state graph , the bugs are less and easy to identify.

In bad state graphs the bugs are more and difficult to identify.

 

Differentiate Between Waterfall Model and Incremental Model.

S.NO

                  Waterfall Model

                   Incremental Model

1)

The waterfall model is called a linear sequential life cycle model as it develops the software sequentially.

The incremental model is iterative. it develops the software in  multiple iterations.

2)

In waterfall model , the software is developed in sequence and delivered at the end at once.

In incremental model , the software is developed in increments and each phase is delivered separately at successive points.

3)

Requirements cannot be changed once fixed.

Requirements can be changed after every increment.

4)

Risks are high in waterfall model and cannot be analyzed before the last phase.

Risks are identified and solved after every iteration.

5)

Changing the requirements  becomes costly as all the phases from the beginning  have to be repeated

Changing the requirements in the incremental model is easy , as new features can be added after every iteration.

 

Write a Calculator program in C.

Arithmetic operations using (switch...........case)

program:

#include<stdio.h> 
void main()
{
    int a,b,res,choice;
    printf("enter two numbers \n"); scanf("%d%d",&a,&b);
    printf(" 1.add \n 2.subract \n 3.multiply \n 4.divide \n"); printf("enter your choice \n");
    scanf("%d",&choice); 
    switch(choice)
    {
        case 1:
        res=a+b;
        printf("the sum of %d and %d is %d \n",a,b,res); break;
        case 2:
        res=a-b;
        printf("the difference of %d and %d is %d \n",a,b,res); break;
        case 3:
        res=a*b;
        printf("the product of %d and %d is %d \n",a,b,res); break;
        case 4:
        res=a/b;
        printf("the division of %d by %d is %d \n",a,b,res); break;
        default:
        printf("you have entered wrong choice\n please... try again\n"); break;
    }
}

output:-


Comparison Between The Backtracking and Brute Force Approach.

S.NO

                         Backtracking

                Brute Force Approach

1)

This is an algorithm design technique for solving large instances of combinatorial problems.

This is a straightforward approach for solving a problem ,usually based on the problem’s constraints.

2)

In this method  solutions are constructed one component at a time and evaluate the partially constructed solutions as if no increasing values of the renaming components can lead to a solution , remaining components are not generated  at all and backtracks to replace the last component of the partially constructed with its next option.

In Exhaustive search, a brute force approach, all the solutions are generated and then identifies the one with a desired property.

3)

Backtracking method is efficient than Brute Force Approach.

Brute Force Approach is less efficient.

4)

When backtracking method is applied to the knapsack problem, using a dynamic state space tree formulation, leads to an efficient algorithm for every input.

Exhaustive search , a brute force approach , when applied to knapsack problem leads to an algorithm that is inefficient on every input.

5)

Backtracking method which is applied to combinatorial problems to solve the large instances of the problems ,here also we face the difficulty of exponential explosion.

An exhaustive search approach can also be applied to combinatorial problems which suggests generating each and every element of the problem’s domain ,we face the difficulty of exponential explosion.

6)

Examples of backtracking method, incudes n-queens problem ,sum of subsets problem.

Examples of brute force approach includes selection sort, sequential search.

7)

This method is not as simple as brute force approach

This approach is very easy and simple to implement

 

Comparison Between The Dynamic Programming and The greedy Method.

S.No

                  Dynamic Programming

                        Greedy Method

1

Dynamic programming is a method in which the solution to a problem can be viewed as a result of the sequence of decisions.

Greedy Method is the most forward technique for constructing solution to an optimum problem through a sequence of steps.

2

In this method more than one decision is made at a time.

In this method ,only one decision is made at a time

3

Dynamic programming considers all the possible sequences in order to obtain the optimum solutions.

Greedy method considers an optimum solution without revising the previous solutions.

4

Principle of optimality holds in the dynamic programming and thus the solutions obtained is guaranteed.

Solutions obtained is not guaranteed

5

Dynamic programming solves the sub-problems bottom up. The problem can’t  be solved completely until we find all the solutions of the sub-problems.

Greedy method solves the sub-problems from the top down. We first need to find  the greedy choice for a problem, then reduce it into smaller one.

6

Dynamic programming is more expensive than greedy , because we have to try every possibility before solving a problem.

Greedy method is comparatively less expensive.

7

In this method we can solve any problem.

There are some problems that greedy cannot solve while dynamic programming can. Therefore , first we try greedy , and then if it fails then we try dynamic programming.

 

Comparison Between Greedy Method and Divide and Conquer

S.No

                Greedy Method

       Divide and Conquer

1)

By greedy method , there are some chance of getting an optimal solution to a specific problem

Divide and Conquer is the result oriented approach.

2)

The time taken by this algorithm is not that much efficient when compared to Divide and Conquer

The time taken by this algorithm is efficient when compared to greedy approach.

3)

This approach does not make further move,

if the subset chosen does not satisfy the specified constraints.

This approach does not depend on constraints to solve a specific problem.

4)

This approach is applicable and as well as efficient for wide variety of problems.

This approach is not efficient for larger problems.

5)

Space requirement is less when compared to the Divide and Conquer

As the problem is divided into a large number of sub-problems, the space requirement is very much high.

6)

This approach is also applicable to problems which are not divisible.

This approach is not applicable to problems which are not divisible.

7)

Examples of this approach includes are Knapsack problem

Examples of this approach includes are Knapsack problem