Tuesday, April 30, 2019

Applications Of Logic Programming

logic programming is used in 

1.Relational Database Management Systems:
  • These are the systems which stores the data in the tabular form.
  • Relational calculus is used to perform queries on such databases.
  • Those query-languages are non procedural which means ,in that user doesn't need to explain the process of retrieving an output but only describes the characteristics of the output.
  • "prolog structures'' are used to describe the information present in the tables and the "prolog rules" explains relationships between the tables.
  • The resolution operation contains the retrieval process.
  • The queries for the RDBMS can be provided by the prolog goal statements.

Advantages:-


  1. Single language is required for the implementation of RDBMS.
  2. All the Queries related to data definitions,data manipulations and input and output functions can be found by using a single logic programming language.
  3.  Deductive capability is built in the logic programming languages,which is helpful for implementing RDBMS.
  4. deducing the data from the conventional RDBMS is not possible as it is only contains the facts but not inference rules.

Dis-Advantages:-

  1. use of logic programming for implementing the RDBMS is a slow process.

2.Expert Systems

expert systems are the computer systems which had been developed for imitating human expertise in some domain.
  • They consists of database of facts an inferencing  process along with some heuristic and human friendly interfaces.
  • the problems of incompleteness and inconsistencies of the databases in expert systems can be solved by using logic programming.
  • The knowledge needed for expert systems was provided by the polog.
  • They can grow dramatically because these can learn from the process being used.
  • prog can be used to build the expert systems because it uses the resolution for processing queries for adding facts and rules for enhancing the learning capabilities.

3.Natural Language Processing:-

  • It uses the logic programming in providing interfaces to a computer software systems such as intelligent databases and knowledge based systems etc.,
  • it helps in describing the language syntax
  • set of sentences in natural languages can be expressed in clausal form by the logic-based semantics networks.
  • some semantics in natural language can be efficiently modeled by employing the logic programming language.
  • the proof procedures in logic programming are similar to certain parsing technique.

4.Education:- 

logic programming such as micro prolog  can be used in the field of education which provides the following advantages:-
  • it introduces computing.
  • it's is easy to teach logic programming to the starters rather than the experienced individuals.
  • it helps in  the students in clear thinking and expressions.
  • it helps in solving the mathematical problems,equations,understanding the grammar of natural language and the rules of the physical world.

Sunday, April 21, 2019

Structural testing versus Functional Testing

 

Structural Testing

Functional Testing

1

Structural Testing is also known as White Box or Open-Box Testing

Functional Testing is also known as Black Box or Closed-Box testing.

2

Structural Tests will be performed based on the knowledge of internal features of the Software/Source Code.

Functional tests will be performed without having the knowledge of internal features of the software.

3

Both the testers and the programmers are dependent on each other for test process.

Both the testers and the programmers are not dependent and performs the tests individually.

4

It is less effective when compare to the Functional Testing.

It is more effective than the Structural Testing.

5

Inputs are represented by certain predefined paths in software

Inputs are represented by some peripheral devices or simulated systems.

6

The tests cases take finite time but can’t detect all bugs.

The tests cases take infinite time and detect all errors

7

Tests are performed either from programmers or designer’s perspective.

Tests are performed from user’s perspective.

8

Different methods are used for performing the white box texting,which are as follows:-

·        Statement Testing.

·        Decision Testing

·        Condition Testing

Different methods are used for performing the Black box texting,which are as follows:-

·        Expected inputs method

·        Boundary values method

·        Illegal values method

9

It helps in removing the un-necessary code that may results in some bugs or errors

It helps in disclosing the problems and inconsistencies that may arise in functional testing.

 

Comparison Between Backtracking and Branch and Bound Methods.

 

 

Branch and Bound Method

BackTracking Method

In this technique, any of the search methods among the depth first search or breadth first search can be used to get the optimum solution.

In this technique , the solutions will be obtained using the DFS (depth first search)method.

This method is used to provide/solve optimization problems.

This method Provides solutions to the decision problems effectively.

Here in this method there is no chance of getting the bad solutions.

Here in this method there is chance of getting the bad solutions in sometimes.

By using technique, we can generate the SST (State Space Tree) and can be searched completely.

By using this method SST (State Space Tree) and can’t be searched completely.

Hence there is a possibility of getting an optimum solution at any point in the state space tree.

Hence the process of  searching terminates as soon as the solutions obtained.

This method is applied to the problems like Travelling Sales –person(TSP),job sequencing etc.,

This method can be used on problems like Graph-Coloring, Sum-of-Subsets and N-queens.

 

Saturday, April 6, 2019

Write a Java Program The Prints The Following Output Using The Applets



PROGRAM:-

import javax.swing.JApplet;
import java.awt.Graphics;
import java.awt.Color;

public class MyHomeDemo extends JApplet
{
public void paint(Graphics g)
{
//house roof
g.setColor(Color.red);
g.fillRect(50,150,400,40);
//house 
g.setColor(Color.yellow);
g.fillRect(100,190,300,310);
//house entrance doors
g.setColor(Color.white);
g.fillRect(120,230,150,270);
g.setColor(Color.green);
int xs[]={120,170,170,120,120};
int ys[]={230,250,480,500,230};
g.fillPolygon(xs,ys,5);
int xs1[]={270,220,220,270,270};
int ys1[]={230,250,480,500,230};
g.fillPolygon(xs1,ys1,5);
g.setColor(Color.black);
int x1[]={120,170,170,120,270,220,220,270,120};
int y1[]={230,250,480,500,500,480,250,230,230};
g.fillPolygon(x1,y1,9);
//house windows
g.setColor(Color.white);
g.fillRect(280,210,100,75);
g.setColor(Color.black);
g.drawRect(280,210,25,75);
g.drawRect(305,210,25,75);
g.drawRect(330,210,25,75);
g.drawRect(355,210,25,75);
//house antenna
g.drawLine(400,50,400,150);
g.drawLine(350,50,450,50);
g.drawLine(360,10,340,90);
g.drawLine(380,10,360,90);
g.drawLine(400,10,380,90);
g.drawLine(420,10,400,90);
g.drawLine(440,10,420,90);
g.drawLine(460,10,440,90);
g.drawArc(410,6,40,80,60,60);
g.drawArc(390,14,40,80,240,60);
//welcome boards
g.setColor(Color.white);
g.drawString("My Home",135,170);
g.setColor(Color.black);
g.drawString("WELCOME",135,210);
}
}
/*
<applet code='MyHomeDemo.class' width='500' height='500'></applet>
*/

output:-

compile and run the file as below

Friday, April 5, 2019

C Program To Find Salesman Commission By Following The Below Conditions • If sales<=1000 then commission is 10% • If sales >=1000 then commission is 15% • If sales > 5000 then the commission is 20%

program:

#include<stdio.h>
void main()
{
float s,c;
printf("enter a string:");
scanf("%f",&s);
if(s<=1000)
{
c=(s*10.0)*100.0;
}
else if(s<=5000)
{
c=(s*15.0)*100.0;
}
else
{
c=(s*20.0)*100.0;
}
printf("Commission is %f",c);
}
output:-

C Program To Count Number Of Upper Case Letters and Lower Case Letters in a Given String

Program:-

#include<stdio.h>
#include<string.h>
int main()
{
int up=0,lr=0;
char ch[150];
printf("Enter the String:-\n");
scanf("%[^\n]",ch);
int i=0;
while(ch[i]!='\0')
{
if(ch[i] >= 'A' && ch[i] <= 'Z')
{
up++;
}
if(ch[i] >= 'a' && ch[i] <= 'z')
{
lr++;
}
i++;
}
printf("UpperCase Letters:%d\n",up);
printf("LowerCase Letters:%d",lr);
return(0);
}

output:-



Write a Java Program To Paint Like Paint Brush In APPLET

Program:

import java.awt.Frame;
import java.awt.Label;
import java.awt.event.*;
import java.awt.Graphics;
import java.awt.Color;
public class MouseMotionListenerDemoC extends Frame implements MouseMotionListener
{
          Label l1;
MouseMotionListenerDemoC()
          {
                   addMouseMotionListener(this);
                   l1=new Label("Mouse not found yet....Get the mouse on to the frame!!!");
                   l1.setBounds(20,50,500,50);
                   add(l1);
                   setSize(500,500);
                   setLayout(null);
                   setVisible(true);
          }
          public static void main(String a[])
          {
                   MouseMotionListenerDemoC mmldc=new MouseMotionListenerDemoC();
          }
          public void mouseDragged(MouseEvent me)
{
l1.setText("Mouse Dragged"+me.getX()+" , "+me.getY());
Graphics g=getGraphics();
g.setColor(Color.red);
                   g.fillOval(me.getX(),me.getY(),20,20);
}
          public void mouseMoved(MouseEvent me)
{
                   l1.setText("Mouse Moved"+me.getX()+" , "+me.getY());
                   //Graphics g=getGraphics();
                   //g.setColor(Color.green);
                   //g.fillOval(me.getX(),me.getY(),20,20);
          }
}

output:-

run the program as follows
javac MouseMotionListenerDemoC.java
java MouseMotionListenerDemoC


UNIT-1

TOPICS TO BE DISCUSSED

1)External Sorting
2)K-Way Merging
3)Buffer Handing for parallel Operation
4)Run Generation
5)Optimal Merging Of Run

External Sorting:

what is Sorting?
The process of arranging the elements either in the ascending order or in the descending can be called as "Sorting"

Types of Sorting:
This sorting can be classified into two types:
1)External Sorting
2)Internal Sorting

External Sorting:

It is the process which is used when the number of elements or records to be sorted are in large number,such that all of them can not be accommodated in the internal memory of computer.therefore
the files containing huge records or files to be sorted will be stored on external storage  devices and external storage process is applied.

Internal Sorting

It is the process which is usually used when the records to be sorted
are less in number.

External Sorting Process:

It performs the following steps:-
a)It collects the records from the external storage and kept into the internal memory.
b)In order to generate "runs" apply internal sort algorithms on those records
c)write those "runs" onto the external storage devices.
d)merge the "runs" generated in the previous(above)steps 
e)repeat steps b,c and d untill all runs are merged and we are left with a single run in  which the file containg all the records in sorted order.

Example Of PassWordField Option In Swing

program:

import javax.swing.*;
public class PasswordFieldDemo
{
public static void main(String[] args)
{
JFrame jf=new JFrame("Password Field Demo");
JPasswordField val=new JPasswordField();
JLabel l1=new JLabel("PassWord");
l1.setBounds(50,110,90,40);
val.setBounds(110,110,110,40);
jf.add(val);
jf.add(l1);
jf.setSize(310,310);
jf.setVisible(true);
jf.setLayout(null);
}
}
output:
run the file as follows
javac PasswordFieldDemo.java
java PasswordFieldDemo

Matrix Multiplication Using C

Program

#include<stdio.h>
main()
{
    int a[100][100],b[100][100],c[100][100],n,m,i,j,o,p,k,l;
    printf("enter the order of matrix 1\n");
    scanf("%d%d",&n,&m);
    printf("enter the order of matrix 2\n");
    scanf("%d%d",&o,&p);
    if(m!=o)
    {
        printf("matrix multiplication not possible\n");
    }
    else
    {
        printf("enter matrix 1 values\n");
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                scanf("%d",&a[i][j]);
            }
        }
        printf("enter matrix 2 values\n");
        for(k=0;k<o;k++)
        {
            for(l=0;l<p;l++)
            {
                scanf("%d",&b[k][l]);
            }
        }
        for(i=0;i<n;i++)
        {
            for(l=0;l<p;l++)
            {
                c[i][l]=0;
            }
        }
        for(i=0;i<n;i++)
        {
            for(l=0;l<p;l++)
            {
                for(j=0;j<m;j++)
                {       

                    c[i][l]=c[i][l]+(a[i][j]*b[j][l]);
                }
            }
        }
        printf("the resultant matrix is \n");
        for(i=0;i<n;i++)
        {
            for(l=0;l<p;l++)
            {
                 printf("%d\t",c[i][l]);
            }
            printf("\n");
        }
    }
}
output:










Five Bikers Compete in a race such that they drive at a constant speed which may or may not be the same as the other. To qualify the race, the speed of a racer must be more than the average speed of all 5 racers. Take as input the speed of each racer and print back the speed of qualifying racers.

PROGRAM

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class Race
{
          public static void main(String a[]) throws IOException
          {
                   int r1,r2,r3,r4,r5,avg;
                   BufferedReader br=new BufferedReader(new     InputStreamReader(System.in));
                   System.out.println("enter the speed of the r1:");
                   System.out.println("enter the speed of the r2:");
                   System.out.println("enter the speed of the r3:");
                   System.out.println("enter the speed of the r4:");
                   System.out.println("enter the speed of the r5:");
                   r1=Integer.parseInt(br.readLine());
                   r2=Integer.parseInt(br.readLine());
                   r3=Integer.parseInt(br.readLine());
                   r4=Integer.parseInt(br.readLine());
                   r5=Integer.parseInt(br.readLine());
                   avg=(r1+r2+r3+r4+r5)/5;
                   if(r1>avg)
                   {
                             System.out.println("first racer is qualified with a race speed "+r1+"\n");
                   }
                   else if(r2>avg)
                   {
                             System.out.println("second racer is qalified with a race speed "+r2);
                   }
                   else if(r3>avg)
                   {
                             System.out.println("third racer is qalified with a race speed "+r3);
                   }
                   else if(r4>avg)
                   {
                             System.out.println("fourth racer is qalified with a race speed "+r4);
                   }
                   else if(r5>avg)
                   {
                             System.out.println("fifth racer is qalified with a race speed "+r5);
                   }
                   else
                   {
                             System.out.println("no biker is qualified");
                   }
          }
}
Output:

LOGIC PROGRAMMING LANGUAGES

Logic Programmming

logic programming is a programming which uses a type of symbolic logic as a language.The languages which are based on the symbolic logic are called as logic programming languages.they are also called as a "declarative languages".syntaxes of these languages
differ from imperative and the functional languages.

Coupling and Cohesion


differenciate between coupling and cohesion

Coupling

1)Coupling is the measure of interdependence among models.
2)Modules are dependent on each other such that changes to one module affects other  modules.
3)A high degree of Coupling must be avoided while designing.
4)In case of High Coupling , it is very difficult to understand the modules.
5)In case of High Coupling  ,we can not reuse the modules.

Cohesion

1)Cohesion is the measure of functional grouping of elements within a single module 
2)Modules are dependent on each other such that changes to one module does not affects other modules directly. 
3)A high degree of Coupling must be considered while designing.
4)In case of High Coupling , it is very easy to understand the modules.
5)In case of High Coupling  ,we can easily reuse the modules.