SlideShare a Scribd company logo
Discrete Mathematics
Homework 1 Key
Samet Öztoprak
2601140342
April 6, 2015
1) Show that each of these conditional statements is a tautology by using truth tables.
a) (p ∧ q) → p
p q p ∧ q (p ∧ q) → p
T T T T
T F F T
F T F T
F F F T
b) p → (p ∨ q)
p q p ∨ q p → (p ∨ q)
T T F F
T F T T
F T T T
F F T T
c) ¬p → (p → q)
p q ¬p p → q ¬p → (p → q)
T T F T T
T F F F T
F T T T T
F F T T T
d) (p ∧ q) → (p → q)
p q p ∧ q p → q (p ∧ q) → (p → q)
T T T T T
T F F F T
F T F T T
F F F T T
e) ¬(p → q) → p
p q p → q ¬(p → q) ¬(p → q) → p
T T T F T
T F F T T
F T T F T
F F T F T
f ) ¬(p → q)→¬q
p q ¬q p → q ¬(p → q) ¬(p → q)→¬q
T T F T F T
T F T F T T
F T F T F T
F F T T F T
2) Determine whether each of these compound propositions is satisfiable.
a) (p ∨¬q) ∧ (¬p ∨ q) ∧ (¬p ∨¬q)
= (p ∧¬p) ∨ (p ∧ q) ∨ (¬q ∧¬p) ∨ (¬q ∧ q) ∧ (¬p ∨¬q)
(p ∧¬p) = F
(¬q ∧ q) = F
= (F ∨ (p ∧ q) ∨ (¬q ∧¬p) ∨ F) ∧ (¬p ∨¬q)
= (p ∧ q ∧ ¬p ) ∨ (¬q ∧ ¬p ∧ ¬p) ∨ (p ∧ q ∧ ¬q) ∨ (¬q ∧ ¬p ∧ ¬q)
(p ∧ q ∧ ¬p ) = F
(p ∧ q ∧ ¬q) = F
= F ∨ (¬q ∧ ¬p ∧ ¬p) ∨ F ∨ (¬q ∧ ¬p ∧ ¬q)
(¬p ∧ ¬p) = ¬p
= ¬q ∧ ¬p
b) (p → q) ∧ (p →¬q) ∧ (¬p → q) ∧ (¬p →¬q)
p → q = ¬p ∨ q
= (¬p ∨ q) ∧ (¬p ∨ ¬q) ∧ (¬(¬p) ∨ q) ∧ (¬(¬p) ∨ ¬q)
= (¬p ∨ q) ∧ (¬p ∨ ¬q) ∧ (p ∨ q) ∧ (p ∨ ¬q)
= ((¬p ∧ ¬p) ∨ (q ∧ ¬p) ∨ (¬p ∧ ¬q) ∨ (q ∧ ¬q)) ∧ ((p ∧ p) ∨ (q ∧ p) ∨ (p ∧ ¬q) ∨ (q ∧ ¬q))
= (¬p ∨ (q ∧ ¬p) ∨ (¬p ∧ ¬q)) ∧ (p ∨ (q ∧ p) ∨ (p ∧ ¬q) )
= (¬p ∧ p) ∨ (q ∧ ¬p ∧ p) ∨ (¬p ∧ ¬q ∧ p) ∨ (¬p ∧ q ∧ p) ∨ (q ∧ ¬p ∧ q ∧ p )
∨ (¬p ∧ ¬q ∧ q ∧ p ) ∨ (¬p ∧ p ∧ ¬q) ∨ (q ∧ ¬p ∧ p ∧ ¬q) ∨ (¬p ∧ ¬q ∧ p ∧ ¬q)
= False
c) (p ↔ q) ∧ (¬p ↔ q)
= (p ∧ q) ∨ (¬p ∧ ¬q) ∧ (¬ (p) ∧ q) ∨ (¬ (¬p) ∧ ¬q)
= ((p ∧ q) ∨ (¬p ∧ ¬q)) ∧ ((¬p ∧ q) ∨ ( p ∧ ¬ q))
= (p ∧ q ∧ ¬p ∧ q ) ∨ (p ∧ q ∧ p ∧ ¬ q) ∨ (p ∧ q ∧ ¬p ∧ q ) ∨ (p ∧ q ∧ p ∧ ¬ q)
= False
3) Translate each of these statements into logical expressions using predicates, quantifiers,
and logical connectives.
P(x) – x is perfect; F(x) – x is your friend
a) No one is perfect.
xP(x)
b) Not everyone is perfect.
P(x)
c) All your friends are perfect.
x[F(x)  P(x)]
d) At least one of your friends is perfect.
x[F(x)  P(x)]
e) Everyone is your friend and is perfect.
x[F(x)  P(x)]
f ) Not everybody is your friend or someone is not perfect.
xF(x)  xP(x) =[xF(x)  xP(x)] = x[F(x)  P(x)]
4) Give an arithmetic proof of ( ) + ( ) = ( )
= ( ) + ( )
= ( )
+
( ) ( )
= ( ( ) ( ) ( )
)
= (( ) ( ) ( ) ( )
)
= (( ) ( )
)
= (( ) ( )
)
=
( )
( ) ( )
= ( )
5) Use a proof by contradiction to show that there is no rational number r for which r3
+ r + 1
= 0. [Hint: Assume that r = a/b is a root, where a and b are integers and a/b is in lowest terms.
Obtain an equation involving integers by multiplying by b3
. Then look at whether a and b are
each odd or even.]
it can suppose which is ‘b’ positive.
therefore ‘a’ and ‘b’ are same sign,
then there is ‘a’ pair of positive numbers and ‘a’ pair of negative numbers for which the ratio ‘a’ / ‘b’ is
the same, so it is not point which pair we find; similarly,
if ‘a’ and ‘b’ have opposite signs, there is a fraction with positive numerator and negative denominator,
and a fraction with negative numerator and positive denominator, for which the ratio ‘a’/’b’ is the
same.
r3
+ r + 1 = 0
+ + 1 = 0
a3
+ ab2
+ b3
= 0
a3
+ b3
= -a b2
If a is also positive, then the left hand side is positive and the right hand side is negative; not possible.
If a is zero, then b must be zero; not possible since b is the denominator of our rational root.
So a can only be negative.
Let's rearrange again:
a3
+ ab2
= b3
a(a2
+ b2
) = b3
then (a2
+ b2
) = + always
a = b3
We know the right side is positive.
If ‘a’ is negative, then the left hand side is also negative. So, ‘a’ can not be negative.
Here is full proof.
a(a2
+ b2
) = b3
then (a2
+ b2
) = + always
a = b3
if | | | | and a = (-) b = (+)
( ) ( )
if | | | | and a = (+) b = (-)
( ) ( )
if | | | | and a = (-) b = (+)
( ) ( )
if | | | | and a = (+) b = (-)
( ) ( )
Since we have proven that ‘a’ cannot be positive, zero, or negative, then ‘a’ does not exist.
6) Let
A = [ ]
a) A[2].
A[2] = AA = [ ] [ ]
= [
(  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  )
(  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  )
(  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  )
]
A[2] = [ ]
b) A[3].
A[3] = A[2]A = [ ] [ ]
=[
(  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  )
(  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  )
(  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  )
]
A[3]=[ ]
c) A ∨ A[2] ∨ A[3]
A ∨ A[2] ∨ A[3] = [ ] ∨ [ ] ∨ [ ]
A ∨ A[2] ∨ A[3] = [
( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ )
( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ )
( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ )
]
A ∨ A[2] ∨ A[3] = [ ]
7) Let A be the set of English words that contain the letter x, and let B be the set of English
words that contain the letter q. Express each of these sets as a combination of A and B.
a) The set of English words that do not contain the letter x.
Solution : A
b) The set of English words that contain both an x and a q.
Solution : A ∩ B
c) The set of English words that contain an x but not a q.
Solution : A - B
d) The set of English words that do not contain either an x or a q.
Solution : A ∩ B
e) The set of English words that contain an x or a q, but not both.
Solution : (A ∪ B) - (A ∩ B)
8) Show that if A and B are sets, then A − (A − B) = A ∩ B.
Proof…
x ∈ A ∩ B.  x ∈ A and x ∈ B.
Especially, x /∈ A - B (because x ∈ A  B would imply x /∈ B).
Therefore x ∈ A - (A - B).
It shows us A∩B ⊆ A - (A - B).
Now let x ∈ A - (A - B).  x ∈ A and x /∈ A - B.
This means that x /∈ A or x ∈ B (the negation of x ∈ A and x /∈ B).
Since we know x ∈ A, this implies x ∈ B,
Therefore x ∈ A∩B.
It shows us A - (A - B) ⊆ A∩B.
It shows us obviously A ∩ B = A - (A - B).
9) Describe an algorithm that takes as input a list of n integers and finds the location of the
last even integer in the list or returns 0 if there are no even integers in the list.
public class Main {
public static int getLastEvenNumber(int[] array, int lenght) {
if (array[lenght] % 2 == 0 )
return lenght+1;
else if (lenght == 0)
return 0;
else
return getLastEvenNumber(array, (lenght - 1));
}
public static void main(String args[]) {
int[] array = {1,3,5,7,9,1}; // first element in the 1st location. if there is no even return 0
System.out.println("index of last even number : " + getLastEvenNumber(array, array.length-1));
}
}
10) A palindrome is a string that reads the same forward and backward. Describe an algorithm
for determining whether a string of n characters is a palindrome.
import java.util.Scanner;
public class Main {
public static boolean Ispalindrome(String word, int lenght) {
if ((word.length() - lenght) >= (lenght - 1)) {}
else
if (word.charAt(word.length() - lenght) != word.charAt(lenght - 1))
return false;
else
Ispalindrome(word, lenght - 1);
return true;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
String word = sc.nextLine();
System.out.println((Ispalindrome(word, word.length()) ? "it is palidromic"
: "it is not palidromic"));
}
}

More Related Content

PPT
Predicates and Quantifiers
PPTX
CMSC 56 | Lecture 5: Proofs Methods and Strategy
PPT
Logic&proof
PPT
Partial-Orderings in Discrete Mathematics
PDF
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
PPT
Discrete mathematics
PPTX
Python programming | Fundamentals of Python programming
PDF
Module - 1 Discrete Mathematics and Graph Theory
Predicates and Quantifiers
CMSC 56 | Lecture 5: Proofs Methods and Strategy
Logic&proof
Partial-Orderings in Discrete Mathematics
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
Discrete mathematics
Python programming | Fundamentals of Python programming
Module - 1 Discrete Mathematics and Graph Theory

What's hot (20)

PPT
Mathematical induction
PPTX
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
PPTX
Propositional logic
PPTX
Proofs by contraposition
PPS
Matrix Operations
PPTX
Maths-->>Eigenvalues and eigenvectors
PPT
Discrete Mathematics Lecture
PDF
Lecture 2 predicates quantifiers and rules of inference
PPT
Propositional And First-Order Logic
PPT
Lec 02 logical eq (Discrete Mathematics)
PPT
DATA STRUCTURES
PPTX
Discrete math Truth Table
PDF
Python tutorial for ML
PDF
Chapter 2: Relations
PPTX
Section 9: Equivalence Relations & Cosets
PPTX
Hasse diagram
PDF
Recurrence relations
PPTX
rules of inference in discrete structures
PPTX
Recursion DM
PDF
Discrete Mathematics Lecture Notes
Mathematical induction
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Propositional logic
Proofs by contraposition
Matrix Operations
Maths-->>Eigenvalues and eigenvectors
Discrete Mathematics Lecture
Lecture 2 predicates quantifiers and rules of inference
Propositional And First-Order Logic
Lec 02 logical eq (Discrete Mathematics)
DATA STRUCTURES
Discrete math Truth Table
Python tutorial for ML
Chapter 2: Relations
Section 9: Equivalence Relations & Cosets
Hasse diagram
Recurrence relations
rules of inference in discrete structures
Recursion DM
Discrete Mathematics Lecture Notes
Ad

Viewers also liked (7)

PPTX
Truth tables presentation
PPT
Truth tables
PPTX
Intro to Cryptography on the Web
PPTX
Logical Connectives (w/ ampersands and arrows)
PPTX
Abbreviated Truth Tables
PPT
6.3 Truth Tables For Propositions
PPTX
CATEGORICAL SYLLOGISM
Truth tables presentation
Truth tables
Intro to Cryptography on the Web
Logical Connectives (w/ ampersands and arrows)
Abbreviated Truth Tables
6.3 Truth Tables For Propositions
CATEGORICAL SYLLOGISM
Ad

Similar to Discrete mathematic question answers (20)

PDF
Math 189 Exam 1 Solutions
DOCX
Algorithmic foundations.docx
PPT
4. symbolic logic
PDF
Solutions Manual for Mathematical Proofs A Transition to Advanced Mathematics...
DOCX
Discrete mathematics
PPT
Lect14
PPT
pushdown automata
PPTX
Probability and Random Variables
PPT
Ch1 sets and_logic(1)
PDF
Course material mca
PDF
mathes probabality mca syllabus for probability and stats
PPTX
1 Functions and Permutation.pptx
PPTX
Math Assignment Help
PDF
Logic and proof
PPTX
set theory --.pptx
PDF
2 homework
PDF
Lecture 3 qualtifed rules of inference
PDF
Probability-06.pdf
PDF
Tutorial_2.pdf
Math 189 Exam 1 Solutions
Algorithmic foundations.docx
4. symbolic logic
Solutions Manual for Mathematical Proofs A Transition to Advanced Mathematics...
Discrete mathematics
Lect14
pushdown automata
Probability and Random Variables
Ch1 sets and_logic(1)
Course material mca
mathes probabality mca syllabus for probability and stats
1 Functions and Permutation.pptx
Math Assignment Help
Logic and proof
set theory --.pptx
2 homework
Lecture 3 qualtifed rules of inference
Probability-06.pdf
Tutorial_2.pdf

Recently uploaded (20)

PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Trump Administration's workforce development strategy
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharma ospi slides which help in ospi learning
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
Cell Types and Its function , kingdom of life
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Microbial diseases, their pathogenesis and prophylaxis
O5-L3 Freight Transport Ops (International) V1.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Trump Administration's workforce development strategy
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Anesthesia in Laparoscopic Surgery in India
Pharma ospi slides which help in ospi learning
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
VCE English Exam - Section C Student Revision Booklet
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Cell Types and Its function , kingdom of life
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
A systematic review of self-coping strategies used by university students to ...
O7-L3 Supply Chain Operations - ICLT Program
Microbial diseases, their pathogenesis and prophylaxis

Discrete mathematic question answers

  • 1. Discrete Mathematics Homework 1 Key Samet Öztoprak 2601140342 April 6, 2015 1) Show that each of these conditional statements is a tautology by using truth tables. a) (p ∧ q) → p p q p ∧ q (p ∧ q) → p T T T T T F F T F T F T F F F T b) p → (p ∨ q) p q p ∨ q p → (p ∨ q) T T F F T F T T F T T T F F T T c) ¬p → (p → q) p q ¬p p → q ¬p → (p → q) T T F T T T F F F T F T T T T F F T T T d) (p ∧ q) → (p → q) p q p ∧ q p → q (p ∧ q) → (p → q) T T T T T T F F F T F T F T T F F F T T
  • 2. e) ¬(p → q) → p p q p → q ¬(p → q) ¬(p → q) → p T T T F T T F F T T F T T F T F F T F T f ) ¬(p → q)→¬q p q ¬q p → q ¬(p → q) ¬(p → q)→¬q T T F T F T T F T F T T F T F T F T F F T T F T 2) Determine whether each of these compound propositions is satisfiable. a) (p ∨¬q) ∧ (¬p ∨ q) ∧ (¬p ∨¬q) = (p ∧¬p) ∨ (p ∧ q) ∨ (¬q ∧¬p) ∨ (¬q ∧ q) ∧ (¬p ∨¬q) (p ∧¬p) = F (¬q ∧ q) = F = (F ∨ (p ∧ q) ∨ (¬q ∧¬p) ∨ F) ∧ (¬p ∨¬q) = (p ∧ q ∧ ¬p ) ∨ (¬q ∧ ¬p ∧ ¬p) ∨ (p ∧ q ∧ ¬q) ∨ (¬q ∧ ¬p ∧ ¬q) (p ∧ q ∧ ¬p ) = F (p ∧ q ∧ ¬q) = F = F ∨ (¬q ∧ ¬p ∧ ¬p) ∨ F ∨ (¬q ∧ ¬p ∧ ¬q) (¬p ∧ ¬p) = ¬p = ¬q ∧ ¬p
  • 3. b) (p → q) ∧ (p →¬q) ∧ (¬p → q) ∧ (¬p →¬q) p → q = ¬p ∨ q = (¬p ∨ q) ∧ (¬p ∨ ¬q) ∧ (¬(¬p) ∨ q) ∧ (¬(¬p) ∨ ¬q) = (¬p ∨ q) ∧ (¬p ∨ ¬q) ∧ (p ∨ q) ∧ (p ∨ ¬q) = ((¬p ∧ ¬p) ∨ (q ∧ ¬p) ∨ (¬p ∧ ¬q) ∨ (q ∧ ¬q)) ∧ ((p ∧ p) ∨ (q ∧ p) ∨ (p ∧ ¬q) ∨ (q ∧ ¬q)) = (¬p ∨ (q ∧ ¬p) ∨ (¬p ∧ ¬q)) ∧ (p ∨ (q ∧ p) ∨ (p ∧ ¬q) ) = (¬p ∧ p) ∨ (q ∧ ¬p ∧ p) ∨ (¬p ∧ ¬q ∧ p) ∨ (¬p ∧ q ∧ p) ∨ (q ∧ ¬p ∧ q ∧ p ) ∨ (¬p ∧ ¬q ∧ q ∧ p ) ∨ (¬p ∧ p ∧ ¬q) ∨ (q ∧ ¬p ∧ p ∧ ¬q) ∨ (¬p ∧ ¬q ∧ p ∧ ¬q) = False c) (p ↔ q) ∧ (¬p ↔ q) = (p ∧ q) ∨ (¬p ∧ ¬q) ∧ (¬ (p) ∧ q) ∨ (¬ (¬p) ∧ ¬q) = ((p ∧ q) ∨ (¬p ∧ ¬q)) ∧ ((¬p ∧ q) ∨ ( p ∧ ¬ q)) = (p ∧ q ∧ ¬p ∧ q ) ∨ (p ∧ q ∧ p ∧ ¬ q) ∨ (p ∧ q ∧ ¬p ∧ q ) ∨ (p ∧ q ∧ p ∧ ¬ q) = False 3) Translate each of these statements into logical expressions using predicates, quantifiers, and logical connectives. P(x) – x is perfect; F(x) – x is your friend a) No one is perfect. xP(x) b) Not everyone is perfect. P(x) c) All your friends are perfect. x[F(x)  P(x)] d) At least one of your friends is perfect. x[F(x)  P(x)]
  • 4. e) Everyone is your friend and is perfect. x[F(x)  P(x)] f ) Not everybody is your friend or someone is not perfect. xF(x)  xP(x) =[xF(x)  xP(x)] = x[F(x)  P(x)] 4) Give an arithmetic proof of ( ) + ( ) = ( ) = ( ) + ( ) = ( ) + ( ) ( ) = ( ( ) ( ) ( ) ) = (( ) ( ) ( ) ( ) ) = (( ) ( ) ) = (( ) ( ) ) = ( ) ( ) ( ) = ( )
  • 5. 5) Use a proof by contradiction to show that there is no rational number r for which r3 + r + 1 = 0. [Hint: Assume that r = a/b is a root, where a and b are integers and a/b is in lowest terms. Obtain an equation involving integers by multiplying by b3 . Then look at whether a and b are each odd or even.] it can suppose which is ‘b’ positive. therefore ‘a’ and ‘b’ are same sign, then there is ‘a’ pair of positive numbers and ‘a’ pair of negative numbers for which the ratio ‘a’ / ‘b’ is the same, so it is not point which pair we find; similarly, if ‘a’ and ‘b’ have opposite signs, there is a fraction with positive numerator and negative denominator, and a fraction with negative numerator and positive denominator, for which the ratio ‘a’/’b’ is the same. r3 + r + 1 = 0 + + 1 = 0 a3 + ab2 + b3 = 0 a3 + b3 = -a b2 If a is also positive, then the left hand side is positive and the right hand side is negative; not possible. If a is zero, then b must be zero; not possible since b is the denominator of our rational root. So a can only be negative. Let's rearrange again: a3 + ab2 = b3 a(a2 + b2 ) = b3 then (a2 + b2 ) = + always a = b3 We know the right side is positive. If ‘a’ is negative, then the left hand side is also negative. So, ‘a’ can not be negative. Here is full proof. a(a2 + b2 ) = b3 then (a2 + b2 ) = + always a = b3 if | | | | and a = (-) b = (+) ( ) ( ) if | | | | and a = (+) b = (-) ( ) ( ) if | | | | and a = (-) b = (+) ( ) ( ) if | | | | and a = (+) b = (-) ( ) ( ) Since we have proven that ‘a’ cannot be positive, zero, or negative, then ‘a’ does not exist.
  • 6. 6) Let A = [ ] a) A[2]. A[2] = AA = [ ] [ ] = [ (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) ] A[2] = [ ] b) A[3]. A[3] = A[2]A = [ ] [ ] =[ (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) (  ) ∨ (  ) ∨ (  ) ] A[3]=[ ] c) A ∨ A[2] ∨ A[3] A ∨ A[2] ∨ A[3] = [ ] ∨ [ ] ∨ [ ] A ∨ A[2] ∨ A[3] = [ ( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ ) ( ∨ ∨ ) ] A ∨ A[2] ∨ A[3] = [ ]
  • 7. 7) Let A be the set of English words that contain the letter x, and let B be the set of English words that contain the letter q. Express each of these sets as a combination of A and B. a) The set of English words that do not contain the letter x. Solution : A b) The set of English words that contain both an x and a q. Solution : A ∩ B c) The set of English words that contain an x but not a q. Solution : A - B d) The set of English words that do not contain either an x or a q. Solution : A ∩ B e) The set of English words that contain an x or a q, but not both. Solution : (A ∪ B) - (A ∩ B) 8) Show that if A and B are sets, then A − (A − B) = A ∩ B. Proof… x ∈ A ∩ B.  x ∈ A and x ∈ B. Especially, x /∈ A - B (because x ∈ A B would imply x /∈ B). Therefore x ∈ A - (A - B). It shows us A∩B ⊆ A - (A - B). Now let x ∈ A - (A - B).  x ∈ A and x /∈ A - B. This means that x /∈ A or x ∈ B (the negation of x ∈ A and x /∈ B). Since we know x ∈ A, this implies x ∈ B, Therefore x ∈ A∩B. It shows us A - (A - B) ⊆ A∩B. It shows us obviously A ∩ B = A - (A - B).
  • 8. 9) Describe an algorithm that takes as input a list of n integers and finds the location of the last even integer in the list or returns 0 if there are no even integers in the list. public class Main { public static int getLastEvenNumber(int[] array, int lenght) { if (array[lenght] % 2 == 0 ) return lenght+1; else if (lenght == 0) return 0; else return getLastEvenNumber(array, (lenght - 1)); } public static void main(String args[]) { int[] array = {1,3,5,7,9,1}; // first element in the 1st location. if there is no even return 0 System.out.println("index of last even number : " + getLastEvenNumber(array, array.length-1)); } } 10) A palindrome is a string that reads the same forward and backward. Describe an algorithm for determining whether a string of n characters is a palindrome. import java.util.Scanner; public class Main { public static boolean Ispalindrome(String word, int lenght) { if ((word.length() - lenght) >= (lenght - 1)) {} else if (word.charAt(word.length() - lenght) != word.charAt(lenght - 1)) return false; else Ispalindrome(word, lenght - 1); return true; } public static void main(String args[]) { Scanner sc = new Scanner(System.in); String word = sc.nextLine(); System.out.println((Ispalindrome(word, word.length()) ? "it is palidromic" : "it is not palidromic")); } }