Class Notes (785,471)
Canada (481,633)
COMP 102 (23)
Lecture

Logic Variable

3 Pages
164 Views
Unlock Document

School
McGill University
Department
Computer Science (Sci)
Course
COMP 102
Professor
Kaleem Siddiqi
Semester
Winter

Description
Logical  variable         • Something  that  is  true  (1)  or  false  (0)   • X  and  y  are  true  only  if  both         Logical  expresiions         -­‐combine  logical  variables           Switches  in  //  -­‐-­‐>  "or"              in  series  -­‐-­‐>  "and"       Practice  example       -­‐threee  friends  are  trying  to  decide  what  to  do  Saturday  night  (see  a  movie  or  go  clubbing).  They  settle   the  issue  by  a  vote  (everyone  gets  a  single  vote,  the  activity  with  the  most  votes  wins.)       • Assume  you  want  a  computer  to  automatically  comppile  the  votes  and  declare  the  winning   activity.   • What  logic  variable  would  you  use?  A  single  logic  variable  that  represents  the  choice  of  activity     Can  you  write  a  logical  expression,  which  evaluated  wheather  or  not  you  will  go  clubbing  (True=   Clubbing,  False=Movie).       • Input  logical  variables:   • V1-­‐  vote  of  person  1   • V2   • V3       Output  logical  variable         • Activity=  choice  of  activity   Logical  expression:       Activity=  (v1  and  v2)  or  (v1  and  v3)  or  (v2  and  v3)       How  would  you  check  whether  this  is  correct?       Checking  logical  expres sions  (Using  truth  tables)       • computer  must  be  ready  for  any  input  and  must  compute  correct  results  in  all  cases.   • Must  represent  all  possible  input  combinations       With  n  input  variable   -­‐-­‐>  we  have  2  n  (power)  rows  for  inouts  (LHS)   -­‐-­‐>  RHS  we  just  workout  the  value  of   the  output  in  each  row.       • Given  the  truth  table  we  would  like  to  come  up  with  a    logical  expression  (boolean)  for  the   output(s)-­‐-­‐>  HOW?       "Disjunction  (or)"  of  "conjuctions  (and)"         • You  can  also  extrat  the  logical  expression  directly  from  the  truth  table:        (Expression  2)  Activity=  (not  v1)and  v2  and  v3                    OR              v1  and  (not  v2
More Less

Related notes for COMP 102

Log In


OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.

Submit