Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Key Concepts in Computer Science -Midterm 1

[Basic Mathematics]
1. [5 marks] Find the tightest integer upper bound and lower bound for x if 𝒙= π‹π¨π πŸ(πŸ“πŸ). Justify your answer.
πŸ‘πŸ<πŸ“πŸ< πŸ”πŸ’ ⟹ πŸπŸ“< πŸ“πŸ< πŸπŸ” ⟹ π‹π¨π πŸ(πŸπŸ“)< π‹π¨π πŸ(πŸ“πŸ)< π‹π¨π πŸ(πŸπŸ”) ⟹
πŸ“< π‹π¨π πŸ(πŸ“πŸ)< 6 ⟹ πŸ“<𝒙 < 6
2. [5 marks] Simplify these expressions using the rules for logarithms. Your answer will be a simpler formula. You do not need to calculate a numeric answer:
a. π‹π¨π πŸ‘(πŸπŸπŸπŸ•) = π‹π¨π πŸ‘πŸπŸ βˆ’ π‹π¨π πŸ‘πŸπŸ•
b. π‹π¨π πŸ“(πŸ‘πŸ’)=πŸ’Γ—π‹π¨π πŸ“(πŸ‘)
3. [5 marks] Solve this inequality 5 β‰₯ -10x + 20 and write it using interval notations for x.
5 β‰₯ -10x + 20 ⟹ -15 β‰₯ -10x ⟹ πŸπŸ“πŸπŸŽ ≀ x ⟹ πŸ‘πŸ ≀ x ⟹ 1.5 ≀ x
x ∈ (-∞, 1.5)
4. [5 marks] Plot the two functions y=2x, y=2x + 2 on the same X-Y graph for {x | -2 ≀ x ≀ 2}.

test 1

[Pseudocode]
5. [10 marks] Write pseudocode for an algorithm to compute the sum of a list of integers but only for integers that are even.
Example: input: L = [4,2,1,3,6,8,7,9] output = 4 + 2 + 6 + 8 = 20
procedure sumOfEvenInt(L: list of integers)
n := sizeOf(L)
result := 0
for i := 1 to n
if L[i] is even then
result := result + L[i]
return result
Note: we are not picky about the syntax. Also, they might write the if line (to see whether L[i] is even or not) in different ways. As long as their intention is clear, they should get the mark.
[Propositional Logic]
6. [10 marks] Construct a truth table for the following compound proposition: Β¬p ο‚«ο€ Β¬q

table 1

7. [10 marks] Let p be the proposition β€œYou have a car”, q be the proposition β€œYou miss the game” and r be the proposition β€œYou play golf”. Express the following as an English sentence:
(p –> Β¬r) οƒš (q –> Β¬r)
Answer: If you have a car, then you don’t play golf or if you miss the game, then you don’t play golf.
[Propositional Equivalences]
8. [10 marks] Use truth table to verify the following: p ^ (p v q) ο€  p
test 1
Since the values of the last column are all TRUE, then the proposition is a tautology.
10. [10 marks] Give a proof that p οƒšο€ ο€¨Β¬p  q) and p οƒš q are logically equivalent.
Note: you cannot use truth table.
p οƒšο€ ο€¨Β¬p  q) ≑
(pοƒšΒ¬p)  (pοƒšq) ≑ Distributive laws (DIS)
T  (pοƒšq) ≑ Negation laws (NEG)
p οƒšο€ q Identity laws (ID)

q11
12. [10 marks] Consider the following propositional functions:
ο‚· Sheep(x): x is a sheep
ο‚· Gorilla(x): x is a gorilla
ο‚· Fed(x): x is fed after sunset
ο‚· Moon(x): x is exposed to moonlight
ο‚· Dies(x): x dies
write the following statements in predicate logic using the above propositional functions, connectives, negation, and any needed quantifiers.
q 12

test 1

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!