Friday, August 3, 2018

PROJECT TITLES FOR 3rd CSE 1 & 2

PROJECT TITLES

follow https://www.codewithc.com for projects

->Select  Title   ( c/c++/java )
->Get Permission for ur Project Tile by guide and get registered.
->submit abstract  [14-08-2018]. and start the project under ur guide.



Wednesday, August 1, 2018

apply() related functions in R

The apply() family pertains to the R base package and is
populated with functions to manipulate slices of data
from matrices, arrays, lists and dataframes in a repetitive way.
These functions allow crossing the data in a number of ways and
avoid explicit use of loop constructs. They act on an input list,
matrix or array and apply a named function with one or several optional
arguments.

family is made up of the apply(), lapply() , sapply(), vapply(), mapply(),
rapply(), and tapply() functions.

> x<-matrix(1:9,nrow=3)
> x
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
>
> apply(x,1,sum)
[1] 12 15 18
> apply(x,2,sum)
[1]  6 15 24

The lapply() Function
-----------------------
You want to apply a given function to every element of a list
and obtain a list as result.
> a<-matrix(1:9,nrow=3)
> b<-matrix(10:18,nrow=3)
> c<-matrix(19:27,nrow=3)
> MyList<-list(a,b,c)
> MyList
[[1]]
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

[[2]]
     [,1] [,2] [,3]
[1,]   10   13   16
[2,]   11   14   17
[3,]   12   15   18

[[3]]
     [,1] [,2] [,3]
[1,]   19   22   25
[2,]   20   23   26
[3,]   21   24   27

> lapply(MyList,"[",,1)
[[1]]
[1] 1 2 3

[[2]]
[1] 10 11 12

[[3]]
[1] 19 20 21

> lapply(MyList,"[",,2)
[[1]]
[1] 4 5 6

[[2]]
[1] 13 14 15

[[3]]
[1] 22 23 24

> lapply(MyList,"[",1,)
[[1]]
[1] 1 4 7

[[2]]
[1] 10 13 16

[[3]]
[1] 19 22 25

The sapply() Function
--------------------------
The sapply() function works like lapply(), but it tries to simplify
the output to the most elementary data structure that is possible.
And indeed, sapply() is a ‘wrapper’ function for lapply().

> sapply(MyList,"[",1,)
     [,1] [,2] [,3]
[1,]    1   10   19
[2,]    4   13   22
[3,]    7   16   25

The mapply() Function
------------------------------
The mapply() function stands for ‘multivariate’ apply. Its purpose is
to be able to vectorize arguments to a function that is not usually
accepting vectors as arguments.

In short, mapply() applies a Function to Multiple List or multiple Vector Arguments.



The Sweep() Function
----------------------
The sweep() function is probably the closest to the apply() family.
You use it when you want to replicate different actions on the MARGIN elements

GRAND TEST FOR 3rd CSE-1 & II Dt: 02-08-2018 Time :9.0 A.M.

Design the following UI (Use Form /JForm /Applet) and add Listeners or Adapter classes
Time : 80Min

Thursday, July 26, 2018

ASSIGNMENT-1 :: IInd CSE-1 ,last date to submit: 28-07-18

-----------------------------------------------------------------
ASSIGNMENT-1 :: IInd CSE-1 ,last date to submit: 28-07-18
-----------------------------------------------------------------
1)
a)Write data structures in java with examples.
b)Discuss control loops with examples.
2)
a)Write R-code to return complex object.
b)Write R-code to implement binary search tree.
3)
a)Discuss quick sort implementation with example.
b)Solve the linear equations.
x1+x2=2
-x1+x2=4
---------------------------------------------------------
Discuss all with full explanation.
note :: use A4 sheets only


Saturday, July 21, 2018

3rd CSE - 2 JFRAME n sql conect

import java.sql.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class odframe extends JFrame implements
ActionListener
{
        Connection c;
        Statement st;
        ResultSet rs;
        JFrame f;
        TextField t1,t2,t3;
        Button b1,b2,b3,b4,b5,b6,b7;
        Label l1,l2,l3;
        Panel p;
        TextArea ta;

 public void actionPerformed(ActionEvent ae1)
 {
     Button bt=(Button)ae1.getSource();
       if(bt.getLabel().equals("Load"))
         Load();
 
       if(bt.getLabel().equals("Next"))
         Next();
 
        if(bt.getLabel().equals("Get"))
         Get();
 
        if(bt.getLabel().equals("Add"))
         Add();
 
        if(bt.getLabel().equals("Delete"))
         Delete();
       
        if(bt.getLabel().equals("Clear"))
                         Clear();

        if(bt.getLabel().equals("Update"))
       
                Update();
     
  }
 
  public odbcframe()
  {
           f=new JFrame("file server");
        f.setSize(320,300);
        f.setBackground(Color.gray);
        f.setForeground(Color.magenta);
        p=new Panel();
        b1=new Button("Load");
        b2=new Button("Next");
        b3=new Button("Get");
        b4=new Button("Update");
        b5=new Button("Add");
        b6=new Button("Delete");
        b7=new Button("Clear");
        b1.addActionListener(this);
        b2.addActionListener(this);
        b3.addActionListener(this);
        b4.addActionListener(this);
        b5.addActionListener(this);
        b6.addActionListener(this);
        b7.addActionListener(this);
        t1=new TextField("       ");
        t2=new TextField("       ");
        t3=new TextField("       ");
        l1=new Label("Empno");
        l2=new Label("Ename");
        l3=new Label("Salary");
        ta=new TextArea(10,30);
        f.add(p);
        p.add(l1);
        p.add(t1);
        p.add(l2);
        p.add(t2);
        p.add(l3);
        p.add(t3);
           p.add(b1);
           p.add(b2);
           p.add(b3);
           p.add(b4);
           p.add(b5);
           p.add(b6);
           p.add(b7);
           p.add(ta);
        f.setVisible(true);
        f.setDefaultCloseOperation

(JFrame.EXIT_ON_CLOSE);
  }
  void Load()
  {
        try
        {
     Class.forName("com.mysql.jdbc.Driver");
     c=DriverManager.getConnection( 
"jdbc:mysql://localhost:3306/employee","root","1234")

;
     st=c.createStatement();

     rs=st.executeQuery("select *from emp");
     //rs.setFetchDirection

//(ResultSet.TYPE_SCROLL_SENSITIVE);

        rs.next();
        t1.setText(rs.getString("eno"));
        t2.setText(rs.getString("ename"));
        t3.setText(rs.getString("sal"));
       }
        catch(Exception e)
        {
        e.toString();
        }
   }

   public void Next()
   {
        try
        {
        rs.next();
        t1.setText(rs.getString("eno"));
        t2.setText(rs.getString("ename"));
        t3.setText(rs.getString("sal"));
        }
        catch(Exception e)
        {
        ta.append("No Next Record...");
        }
   }
   public void Get()
   {
        try
        {
rs=st.executeQuery("select * from emp where eno=" +

t1.getText());
        rs.next();
        t1.setText(rs.getString("eno"));
        t2.setText(rs.getString("ename"));
        t3.setText(rs.getString("sal"));
        }
        catch(Exception e)
        {
        ta.append("No Prev Record...");
        ta.append(e.toString());
           }
   }

   public void Add()
   {
   try
   {
   rs=st.executeQuery("insert into emp values

("+t1.getText()+",'"+t2.getText()+"',"+t3.getText

()+")");
   }
        catch(Exception e)
        {
        ta.append(e.toString());
        }
  }
   public void Clear()
   {
        try
        {
        rs.next();
        t1.setText(" ");
        t2.setText(" ");
        t3.setText(" ");
        }
        catch(Exception e)
        {
        ta.append(e.toString());
        }
    }
   public void Delete()
   {
        try
        {
        rs=st.executeQuery("delete from emp where 

eno="+t1.getText());
        }
        catch(Exception e)
        {
        ta.append(e.toString());
        }
    }
   public void Update()
   {
        try
        {
        rs=st.executeQuery("update emp set 

ename="+"'"+t2.getText()+"' where eno="+t1.getText

());
        }
        catch(Exception e)
        {
        ta.append(e.toString());
        }
    }

   public static void main(String args[])
   {
    new odframe();
    }
 } 

Friday, July 20, 2018

JFrame connect with Database

import java.sql.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class odframe extends JFrame implements ActionListener
{
        Connection c;
        Statement st;
        ResultSet rs;
        JFrame f;
        TextField t1,t2,t3;
        Button b1,b2,b3,b4,b5,b6,b7;
        Label l1,l2,l3;
        Panel p;
        TextArea ta;

 public void actionPerformed(ActionEvent ae1)
 {
     Button bt=(Button)ae1.getSource();
       if(bt.getLabel().equals("Load"))
         Load();
 
       if(bt.getLabel().equals("Next"))
         Next();
 
        if(bt.getLabel().equals("Get"))
         Get();
 
        if(bt.getLabel().equals("Add"))
         Add();
 
        if(bt.getLabel().equals("Delete"))
         Delete();
       
        if(bt.getLabel().equals("Clear"))
                         Clear();

        if(bt.getLabel().equals("Update"))
       
                Update();
       
  }
 
  public odframe()
  {
           f=new JFrame("file server");
        f.setSize(320,300);
        f.setBackground(Color.gray);
        f.setForeground(Color.magenta);
        p=new Panel();
        b1=new Button("Load");
        b2=new Button("Next");
        b3=new Button("Get");
        b4=new Button("Update");
        b5=new Button("Add");
        b6=new Button("Delete");
        b7=new Button("Clear");
        b1.addActionListener(this);
        b2.addActionListener(this);
        b3.addActionListener(this);
        b4.addActionListener(this);
        b5.addActionListener(this);
        b6.addActionListener(this);
        b7.addActionListener(this);
        t1=new TextField("       ");
        t2=new TextField("       ");
        t3=new TextField("       ");
        l1=new Label("Empno");
        l2=new Label("Ename");
        l3=new Label("Salary");
        ta=new TextArea(10,30);
        f.add(p);
        p.add(l1);
        p.add(t1);
        p.add(l2);
        p.add(t2);
        p.add(l3);
        p.add(t3);
           p.add(b1);
           p.add(b2);
           p.add(b3);
           p.add(b4);
           p.add(b5);
           p.add(b6);
           p.add(b7);
           p.add(ta);
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  void Load()
  {
        try
        {
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     c=DriverManager.getConnection("jdbc:odbc:connect_ora","scott","tiger");
     st=c.createStatement();

     rs=st.executeQuery("select *from appu");
     //rs.setFetchDirection(ResultSet.TYPE_SCROLL_SENSITIVE);

        rs.next();
        t1.setText(rs.getString("empno"));
        t2.setText(rs.getString("ename"));
        t3.setText(rs.getString("sal"));
       }
        catch(Exception e)
        {
        e.toString();
        }
   }

   public void Next()
   {
        try
        {
        rs.next();
        t1.setText(rs.getString("empno"));
        t2.setText(rs.getString("ename"));
        t3.setText(rs.getString("sal"));
        }
        catch(Exception e)
        {
        ta.append("No Next Record...");
        }
   }
   public void Get()
   {
        try
        {
        rs=st.executeQuery("select *from appu where empno="+t1.getText());
        rs.next();
        t1.setText(rs.getString("empno"));
        t2.setText(rs.getString("ename"));
        t3.setText(rs.getString("sal"));
        }
        catch(Exception e)
        {
        ta.append("No Prev Record...");
        ta.append(e.toString());
           }
   }

   public void Add()
   {
   try
   {
   rs=st.executeQuery("insert into appu values("+t1.getText()+",'"+t2.getText()+"',"+t3.getText()+")");
   }
        catch(Exception e)
        {
        ta.append(e.toString());
        }
  }
   public void Clear()
   {
        try
        {
        rs.next();
        t1.setText(" ");
        t2.setText(" ");
        t3.setText(" ");
        }
        catch(Exception e)
        {
        ta.append(e.toString());
        }
    }
   public void Delete()
   {
        try
        {
        rs=st.executeQuery("delete from appu where empno="+t1.getText());
        }
        catch(Exception e)
        {
        ta.append(e.toString());
        }
    }
   public void Update()
   {
        try
        {
        rs=st.executeQuery("update appu set ename="+"'"+t2.getText()+"' where empno="+t1.getText());
        }
        catch(Exception e)
        {
        ta.append(e.toString());
        }
    }

   public static void main(String args[])
   {
    new odframe();
    }
 } 

Friday, July 13, 2018

Question Bank in R – PROGRAMMING By RVS UNIT-1

Question Bank in R – PROGRAMMING By RVS
UNIT-1
           1.           List the data structures in R with examples.
2.       Write syntax of if else in R.
3.       Write any 3 math functions in R.
4.       Explain Datatypes in R
5.       List the differences between vector and list.
6.       Calculate the cummulative sum and cummulative product for the given data 23, 1, 7, -2, 8,
7.       10, 17
8.       Explain in detail about dataframe and arrays with example R code.
9.       Write R code to generate first n terms of a Fibonacci series
10.   Create a 3-dimensional array in R.
11.   Find the minimum and maximum for 14, 23, 16, 20, 0, -17, 100
12.   Create a simple matrix with 3X3 size in R.
13.   Find the factorial of 6. Find the mean, median, standard deviation of
14.   2,4,9,10,14,28,52.
15.   Explain dnorm() function
16.   What is a vector in R? Explain operations on vectors.
17.   Write R function to check whether the given number is prime or not
18.   Explain the functioning of lapply() and tapply() in a R program with one example
19.   What is variable scope?
20.   Distinguish between max( ) and pmax( ) functions.
221.   R pmax Function
pmax() function returns the parallel maxima vector of multiple vectors or matrix.
pmax(..., na.rm = FALSE)
...: Numeric or character arguments
na.rm: whether missing values should be removed
> x <- c(3, 26, 122, 6)
> y <- c(43,2,54,8)
> z <- c(9,32,1,9)
> pmax(x,y,z)
[1]  43  32 122   9

222.   Explain about quote( ) function.


23.   Justify the following: “R functions are first-class objects”.