Aptitude (12) ASP.NET (2) Automata (4) Browser (1) C (5) C# (1) C++ (10) Code (3) CSS (1) Data Structure (1) DATABASE (3) HTML (1) java (43) JSP (1) math (1) MySql (8) other (6) php (3) Servlet (3)

Tuesday, 8 May 2012

Difference between Statement and prepared statment


  • Prepared Statement is Pre-compiled class , but Statement is not.
  • So in PreparedStatement the execution will be faster.
Actually when u submit a simple statement to the database, at first the DBMS parses it and sends it back with the result, so again when u send the same statement again the DBMS server parses it and sends back the result so here a lot of time is wasted and because the statement is again parsed though it has been sent twice or thrice it consumes a lot of time and response will be slow.Prepared Statement is used when u want to execute a statement object many times. when u submit a PreparedStatement the DBMS server parses it and creates a execution plan. This e-plan can be used when u again send the same statement to the database.That is the DBMS server zest executes the compiled statement rather that executing it from first, hence we get an precompiled statement.And also the advanatge of using this PreparedStatement is it is used to send dynamic sql statements, which u can give values later than giving the values at the time of creation.

Thursday, 3 May 2012

Reduction of CFG

1.Eliminate useless symbols
2.Eliminate epsilan production
3.eliminate unit production

Note: A production of the form:
Non-terminal->One non-terminal
i.e
A->B
is called Unit Production.

Greibach normal form

a context-free grammar is in Greibach normal form, if all production rules are of the form:
A \to \alpha A_1 A_2 \cdots A_n
or
S \to \varepsilon
where A is a nonterminal symbol, α is a terminal symbol, A_1, A_2, \ldots, A_n is a (possibly empty) sequence of nonterminal symbols not including the start symbol, S is the start symbol, and ε is the empty word.
Observe that the grammar must be without left recursions.

Chomsky Normal Form

A CFG in the form of :

Non-terminal->string of exactly two non-terminals
i.e
A->BC

OR
Non-terminal->one terminal
i.e
A->a