Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Types , rablems

Tsacable Can
tme
be dol vable in reasonabla (Pslymonay
Inbackable
nablotosle thomin Ylasonabo ti hre
becision
optimizaticn
AYe all prslomy duablu poly nomastimo- Nb
Net n polynomjal timo b ) D(") o(n!)
Andoision prsblom is
Dols a
ghaph b have a mst wt <w.

&ptma Ssluten to Preb lam '


o/ kne salk , Mst:

p - The eloss prsbr Hhat hae polynomiastime


leteiminin stic algo
Abele,- al
A is one thd alibays Computes he
lorect nswe
MST, Sottng, foctnal knapak
dusjon,
Pb hat cO Sol vablo 'n
NP- The elas
Np
po ynomial imo on a nendeteami stc mc.
also be hrget s the elass -
Poblu ms ohose Soutions can be vesied
tn polynemial Hime
Traveliny lalesman, araph aomy, sahi stia
PCNP
2My22, 66) 25) So,6s, 58,63,6, 99,uu, od,l?.

patient information
Field Name obl Data Type
Y Patient ID AutoNumber
First Name
Primary Key
Middle Name
Cut
Last Name
Gender 4d Copy
DOB Paste
Time
Contact No Ea Insert Rows er
Address
Delete Rows
Pin code
per
Buitd.
Referred By
Consulting Dr Properties

Save the file and now let's start entering data of individual patient.
Entering data intodatabase
Notice the database view of the table appear in front of you to add data to it. Now
the field names are displayed as headings and a blank row is provided to enter data.
Now that you have specified the ata type, text that effect can only be entered in
that field.

Notice when you type data in the. last field and press the TAB key the pointer
automaticaliy moves to the next record. Now that you have successfully entered
data into the first record, type the remaining which you need to add. Once the data
entry is over save thc file in your directory.

A/19/7c1s
Prnels 6z2108 O, y

Result:

Ihus we studied to create a database 1n MS acccss to store thc patient


inornaion with the required lields.
|@2010 1 Examples:
*
science be and
Generally solvable
in their
******* " solved thosepolynonmial Introduction:5.1
exactlyBoolean connectives if 3-CNFproblem. cycle Euler's of Finding Shortest worst
.Shankai there G that Almost
exactly in can we in
* k of P case
* is
satisfiability:
variables
** formula a tour the Vs
polynomial notassumne polynonial
NP; time
some dËrected
* such longest time all
* once, Vs Longest be such the
* it solvable
**t assignment
is as means the
Hamilton is
Thawkar, or in although
graph simple astime, algorithms
O(n)
*** (AND), time, problems
their
k-conjunctive turning
A simple NP the
*
Boolcan is these are
**
negations. path complete
a
** of (OR), cycle may itcycle: "Intractable" machineanswer for so
that
the between path: problems some far
HOD ****** * NP-Completeness
values and formula that visitEuler's can is we
3-CNF normal we problems "halting constant
No,
contains the be have
II, two can are or solved it
** 0(NOT); tour Unit-V
******** isforn, andT contains vertex vertices called hard means studied
HCST NP find exist. Problem". k.
ofa
problem. all problems. in that Now
or to and vertices directed in shortest NP
polynomial are
its variables more is
k-CNF, parentheses. NP problems. there pblynomial the
variables
(visited than graph problem. path So question
are
if whose there time
it once. from We some
is that A exactly is type
the Boolean a
causes values Itcycle single believe exist are probleIns that is
AND takes "tractable algorithms,
some
once). that source can
it
formula are O in
of to traverses
(E) problems
theoretical that all
clausesevaluate 0 It "or
or istime. in cannot the on
easyPDF
Printer orested
BCLusing easy
is 1; NP problerms input
ofsatisfiable O(VE) that
Boolean Hamilton each
complete computer problerns be
Driver ORs to cannot of
1. edge time. solved size
of A are
n
|@2010 2
NP-Hard:
but solved
NP-Complete: that
complemnent NP not D.Z DefineNP, 2
Mr.Shankar co-NPor N Class if The being in can
Example: can
sayby
is all in any polynomial solvedby
closed polynomial class P
casily
CRSS Input Problem
c0-NP: NP-complete A N'-complete given is ISS
problem to
txample: ofproblen al so The N: the
whether it Example: Any check for nondeterministic problem. P;
follows under a in assuming
time, a
classes It , The
certificate. NP, they NP-complete
Classes
class time. problem 3-CNF stands
Thawkar, therecomplement L in because are class
problems
Set Hamilton-cycle is since
polynomial
that co-NP problem NP NP Most
covering NP-bard satisfiability, certificate for problems P P,
is PO is is if consist
some the non-deterministic of consists NP,
as NP
divided a algorithm the and
are can problem size th at
HOD
NPOco-NP. can the
language problemNP-hard. and if complete time of problems NP-completeNP-hard,
be of ofthose can of
be set and into th at a
only solved certificate a be those
rephrased of two iscertificate such solved
vertex-cover if in thi s solution.polynomial in
problems Give
T,HCST if bolvnomial
in languages NP-hard. is
NPO Once it in is ittypes:
assignment P as nvohlens
is polynomial NP then is searching, tine in andexamples
as reducible. would equal Then
co-NP again, NP-Complete and we that time.
whether L problem. On) which NP-Hard
such NP-Hard. can be to we are time. of
satisfies sorting
however, time solve an the can
fo r each.
All "verifiable" So are
NPthat assignment size verify etc some
NP-hard it the NP solvable and
= L¬ the These and
in
of ar e
it
co-NP. every NP-Hard problem. that is constant co-N!
is polynomialBoolean the class P
not NP problems in
problems of polynomial the set in
known Since the NP-complete values probles.
of k,
formula. certificate polynomial
wheren
question problems
P have time
whether are to
Printer
easyPDF
Driver BCL
is variableS. time. is
closed NP-complete th e without Any is the
of problem Correct thcanatbe siZe time.
P whether property problem Tni s
=NP under even We
ofMore
is in we tne
@2010 3

Solve
Figure characteristics
2.following
1. suppose thereReductions: 5.3 oNP
in One and Penclosing
NPAco-NP.possibiliy
The The polynomial showing be
B is of the Figure: NPaoNP) P PNoND
transformation
answers
in :
In
that one the case (a)
polynomial key Four
Polyrnomial wemore Let that another as
are time. concepls Problem the
possibilities
have us P NP
same. NP nnost
consider indicates
1T,HCST
Thanh
HOD takes an We NP.
time,Rn Problei A
)
problem
i.e. algorithm consider in unlikely.
(©)
tim to
polynomial
the showing NPnoN NP
co
we a be P= afor
proper-subset
answer B, NP
NPAco-NP,relationships
(b)
transforn that that problemtheNP-Complete NDoND
we
a IfNP (d) (P)
for time. transform we V/P problem
LIShe
a already to is
is closed among
butrelation. NP
instarnoe Problem B
the (or to
"yes"
answer any problem say be NP
if instance decision
know NP-complete complexity
under
is (a)
and not
a P
for how is complement,
of only an
Problem) closed NP
B a to
A of instance classes,
into
ass if
the Asolve is: under co-NP.
an
instanoe into
answer
answer in of A,
some complement. thenMost each In
no Yes
polynomial the which
for NP=
ßof instance problem. we researchers
diagram,
for ß
is would co-NP,
aB. yes
no
also time. (d)
Printer
eayPDE
Drive created
BCLusirg wve ß
"yes". of Now like NP but one
regard
Finally = region
with B suppose to co-NP need it
solve this
the we not
problem Ainpolynomial time,
Asinabove figuro, the algorthm solve an
algorithm transforms it into instance Bof
reduction
1. Given an instance a of problem A, the
problem B,
2, Run polynomial tinhedecision algofor Bon instance p.
3. Use the aty ofp as ans fora.

Q. Write ashort note on NP-completeneSs and reducibility.

5.4 NP-completenesNS and Reducibility


NP complete problems exist ,these
In theoretical computer science we believe that P ANP. it means
in polynomial
problems have the interesting property that if any NP-complete problem can be solved
of study,
time the every NP-complete problem is solved in polynomial time, i.e. P=NP. Despite years
though no polynomial time algorithm has ever been discovered for any NP-complete problem.
in
The language (Problem) Hamilton cycle is NP-complete problem, if we solve Hamilton cycle
polynomial tme, then we could solve every problemn in polynomial time.
Reducibility: Any problem Q can be reduce to problem Q' such that solution of Q' provide solution to
Q. for example a problem of solving the linear equation can be reduce to the problem of solving
quadratic equations Given axtb=0 this cun be transformed into Ox2+axtb=0, so solution of this problem
provide the solution toax tb-0
Alanguage Li is polynomial-time reducible to another language L2, denoted Li SpLa if there exists a
Polynomial-time computable function f:{0, 1}* -’ {0, 1}* such that for all x belongs to {0, 1}*, x
belongs to Liif and only if f(x) belongs to Lz.
We call the function fthe redúction function, and a polynomial-time algorithm F that computes a
reduction function fis called reduction algorithm. Following fig. shows the reduction of L into L, in
polynomial tine.

X f(x) f(x) e L2? XE L1?


A2

AL
4|@2010 Mr.Shankar Thawkar, HODIT, HCST Crastud usro
BCL easyPDF
NP-Comnplete: Polynomial-tinereductions provide a fornal means for showing that
as hard as another, to within a one problem is at least
polynomial-time factor. That is,if Li SPL2, then
factor harder than La, which is why the Li is not more than a
less than or equal to" notation for polynomial
define the set of NP-complete languages, which are reduction is mnemonic. can now
We
the hardest problems in NP.
A language l. (0, 1)" is NP-complete it
1. LENP, and
2. L SpL for every l.'e NP.
Ifa language L. satisties property 2, but not
necessarily property 1, we say that L is NP-hard. We also define
to be the class of NPC
NP-complete languages.
*********** k s* ** * *
******* ******** * *** * ***
*****

5.5SAT
ABoolean formula is a formula where the variables and
operations are Boolean (0/1):
(atb+-d+e)(-at-c)(-btctdie)(at-etre)
OR: +, AND: (), NOT:

SAT: Given a Boolean formula S, is S


satisfiable, that is, can we assign 0's and 1's to the variables so
that S is 1(true)? Easy tosee that CNF-SAT is in
NP: Non-deterministically choose an
of 0's and 1's.to the variables and then assignment
evaluate cach clause. If they are all 1(true"), then the
formula is satisfiable.

*********** *************>
k*****

Q. Prove that CIRCUIT-SAT belongs to NP. Or


prove that CIRCUIT-SAT is NPC.
5.6 Circuit satisfiability
A Boolean circuit is a set of AND, OR and NOT gates.
The
there is an assignment of 0's and l's to a circuit I/P so that thecircuit-SAT problem is to determine if
of circuit is 1 then circuit is satisfiable] circuit output is 1. [If the output of the

CIRCUIT-SAT={<C|Cis asatisfiability Boolean combinational circuit)

5 @2010 Mr.Shankar Thawkar, HOD T, HCST


oreated using
BCL easyPDF
Printer Driver
Forexample, the circuit inthe
and so it is
satisfiable. following Figure has the satisfying assignment xl = 1,:x2=1, x3 =0

ckt
Ceatfre

Given a circuit C, we might attempt to


determine
assigniments to the inputs. Unfortunately, ifwhether
all possible it ís satisfiable by simply
check1ng
assignments. When the size of C is polynomial in k. there are k. inputs, there are 2 possible

Super-polynomial in the size of the checking each one takes (2) time, which is
no polynomial time circuit. In fact, as has been claimed, there is
algorithm exists that solves the strong evidence that
satisfiability is NP-complete. circuit-satisfiability problem because circuit
Theorem: Prove that
CRCUIT-SAT belongs to NP.
Proof: We assume that two inputs to
polynomial time
problem. One of the inputs is Boolean circuit C algorithm A that can verify CIRCUIT-SAT
and another is a certificate
assignment of Boolean values tothe circuit. corresponding to the
The Algorithm A is
constructed as: for each logic gate in circuit, it checks that
provided by the certificate on I/P wires is the values
Ce SA correctly computed as a function of values on the
wires. Then if the output of entire circuit is output
1, the algorithm o/p is 1.
equals to the size of circuit i.e. The certificate has a length
polynomial in size. So CIRCUIT-SAT problem is verified in
polynomial time. It nmeans that CIRCUIT-SAT is NP problem.
k * * * * *** * *
***** *** * ** k*** **
*****

6|@2010 Mr.Shankar Thawkar, HOD IT, HCST


BCL easyPDE
Printet Drver
Q. Prove that SAT
(formula SAT) 0s NPC.
5.7 Formula
Satisfiability Problem or SAT
ABoolean
formula composed of -
1. n Boolean
2. m Boolean
variables: xl, x2, ..., xn
connectives: any Boolean
A(ANDj. v(OR). ¬ (NOT). function with one or two inputs and one
’(implication), if and only i output, such as
3. Parenthesis
A Boolean formula o is said to be satisfiable if the
variables xi of the Boolean formula that causes the truth assignment of Boolean values (0, 1) to
formula to evaluate to 1.
In formal language it is
defined as
SAT= (: Í is a satisfiable Boolean
As an
formula}
example. the formula

has the satis fying a_signment (r| = 0, x


= 0, I; = 1.N4 = 1), since
((0- 0) v ¬((¬0 )v 1)) A-0

=lv)) A1

and thus this formula o belongs to SAT. The naive


algorithm to determine whether an arbitrary
boolean fornmula is satjsfiable does not run in polynomial time. There are
2" possible assignments in a
formula with n variables. If the length of o is polynomial in n, then
checking every assignment
requires (2")time, which is super-polynomial in the length of o. so SAT is NP problem.

Theorem: Prove that SAT is NPC (NP-complete)


Proof:Since SAT is NP-complete if
1, SAT is NP and

2. SAT is NP-Hard i.e. SAT is reducible.


1. SAT is NP: To show that SAT belongs to NP, we assume a certificate that consist of a
satisfying assignment for an input formula p. The verifying algorithm simply replaces
cach variable in the formula with its corresponding value and then evaluates the
expression (just like above example). This task is easily done in polynomial time. If the
expression evaluates to 1, the formula is satisfiable.
7|@2010 Mr.Sha nkar Thawkar, HOD IT, HCST oreatec using
BCL easyPDF
Printer Driver
(i.e. NP-hard). It means th
reducible
that SAT is reduction or
NP-llard: Now we can show following circuit for the
SAT is
Circui-SAT'p SAT, Consider the
we have to prove
CIRCUIT-SAT to SAT.
the problemfrom

proper operation of a
variable xi . The p
For cach wire xi in the circuit C, the formula p has a wires. The
expressed as a formula involving the variables of its incident
gte can nowbe output variable with
is the AND of the circuit
lormula produced by the reduction algorithm
the conjunction of clauses describing the operation of each gate.
For the circuit in the figure, the formula is
(X6-(x4 Axi)
Y-(rlvx2)
X5=¬x3
So d=(xlvx2) A3)
Let us consider the satisfiable truth assign1mentxl=1, x2= 1,x3-O

>=((xlv x2} A(X3)


=(lv 1) a(1)

Thus theformulais satiyfiable.


So, given acircuit it is easily converted into formula in polynomial time, and this can also be
verified in polynomial time. So if we assign the values to the circuit exactly as in formula,
circut is satisfiable, so Circuit-SAT p SAT. Hence is NP-Complete.

8|@2010 Mr.Shankar Tha wkar, HOD IT, HCST


BCL vay
Priuter Driver
lltt
Q. Prove that 3-CNF is NP Complete (NPC)?

5.8 CNF satisfiability


formnula is in
or its negation. A Boolean
variable OR of one or
Aliteral in a Boolean founula is an occurrence of a clauses, cach of which isthe
expressed asan AND of has exactlythree
conjunctive normal form, or CNE,ifit is 3-CNE,if each clause
3-conjunctivenormalform, or
more literals. ABoolean formula is in 3
distinct literals.
For example, the Boolean formula

literals x1, x1, and


which contains the three
is in 3-CNE, The first of its three clauses is

satisfiable or not.
whether a given boolean formula in 3-CNF is
In 3-CNF-SAT, The problem is

normal form is NP-complete.


Theorem: Prove that 3-conjunctive

Proof: Since 3-CNF is NP complete ifitis -


1. NP
2. NP-H¡rd (i.e. reducible)

certificate that consist of a


3-CNF is NP: To show that 3-CNF belongs to NP, we assume a
1.
3-CNF The verifying algorithm simply
satisfying assignment for an input formula g of
corresponding value and then evaluates the
replaces each variable in the formula with its
expression evaluates to 1, the
expression. This task is easily done in polynomialtime. If the
formula is satisfiable.
reducing SAT (Boolean
2. 3-CNP is NP-hard: We can prove that 3-CNP is NP-hard by
formula) into 3-CNP i.e. SAT SP 3-CNF-SAT.The reduction algorithm can be broken into
three basic steps.
Step 1: Construct a binary "parse" tree for the input formula o, with literals as leaves and
connectives as internal nodes. Following Figure shovws such a parse tree for the formula

9|@2010 Mr,Snankar Thankar, HOD IT,HCST created Usirg


BCL easyPDF
Priiter Driver
-Intraduce a variable yi for the output of each internal
as the AND of the root node. Then, we rewrite the original
variable and a coniunction of clauses formula
For the formula p , the describing the operation of each node.
resulting expression is

Step 2: Convert into CNF (conjunctive normal form)


First construct a truth table for each
clause in . We consider the first clause in the
formula oand it is denoted by 1 = (
(y2 ^ )). The truth table corresponding
the clause Pi is give below

0 1 I
0 0
0 0 0

Note: the symbol is called if and only if and its value is l if values of l-side =r-side, otherwise 0.]
10 |@2010 MrShankar Thaw kar. HOn T HCsT
BCL easyPD
Printer Driver
disjunctive normalform (or
build aformula in
Using the trudh-able entries that evaluate to 0, we
DNP) an OR of AND's

-Convert this formula into a CNF formula

Aplying DeMorgan's laws, we get the CNF formula

distinc literals. The final 3-CNF


formula so that eachclause has exactly 3 of, we
Step 3: Iransforms the CNF formula , For cach clause

clauscs of the
formula isconstructed from the
include the following clauses in :
distinct literals, then simply include Ci asa clause of
-IfCi has 3
vh), where ll and 12 are literals, then Include
is, if C;=h
-IfCi has 2 distinct literals, that
requirement that there be exactly 3distinct literals fulfill.
U,vl; vp)A , vl, V¬p) ;
^
include vp v4) ^ (/Vpv ¬4)
has just 1 distinct literal . then
- If Ci
¬q)clauses of
i/ V-pv q) A/vpv

computed in polynomial
We can see that the 3-CNFformula is in 3-CNF and the reduction is
time. ***********
*************** **************** *****%****k**

11 |@2010 Mr.Shaskar Thawkar, HD 1T,HCST cre3ted usirg


BCL easyPDF
Printer Driver
ad Hha
th(
inprts ithms
n &ame ot Can.
The Could too Vegas flm fsncton
Buch sped
od sameTho eonoyal algo ecianey
sandomíod hto
USe eeneato
put.
vegns
has
ifer Usivg algik
nput a tthe ot Bmall
thoalgothm tho to in
makes Catigoisd m
ho
fut
a
poduco nHha n is
hasdepends Chasactenzod umbe have
Samne amo time
ozoa.
miqt o a and sndom
a Somi avnntaqes
tht umbeh a un exeution
Vasuiablo: wile 0(lg
thoot shaplicity
vandomiud veo the
o Ahe for
Aloays Dutpub )
the
to be time Sand to
un
on outpu
run be inpt that algoithm
fo Can ia Hhat
tineTho
cbjecive in
fs random - Can
nportn sonße oblovn
algoitmHho
Aepmusition
Algowns
analgoitms
om a un lgntms ginen Auoo enjubw her
may the a
a o a ministic
to
Tosfomiyto in mostave
as un fea
sandomiz0 tme wtereas
Samo
'Aueh
sun
di Carto mocloyuzed
A s algosthms
ndomized to alaoexelution
omRardomitod
lgoithns.
Hm
ttheatgo5tthms
alatos he
run
hdomiu Morta Anis gos o
, solve
Aom Cald Naby
classe
s
in al Too Any AmyHime
Tho
A
he randomitod qutk sort algoitm Uses Random (P,2yAo
as to obta'n a no0 pivot elamont

3 Randonitod- QuicK Sot (A, P,-1)


Randoeod- Quick Sost (As1, A)
Rondoisd- PartiHon (Ae, A)
Le Random cP, )
exehange AfA] A|Ä]
3 etur. Partition (AiP,a)

timo is o(nlrgn)

tegminoog foom
(Siqma Stav) = ho Set , alf t -logth Stings
Using characters from the alhabet z
denotod
’ Astoing 0is a prefix os a stong x,
=y for Soma

ab C ab cca

cca I ab cca

You might also like