Truth Tables
Evaluating Python code blocks
Dijkstra's
Matrix-Based Block Cipher
Sorting Methods
100

What are the three main types of logic used for truth tables and their symbols?

AND ∧

OR ∨

NOT ¬

100

What is the difference between * and **?

* multiplication

** exponent

100

How is Dijkstra's algorithm used in the read world?

Used for IP routing to find servers

100
How do you find the inverse of a matrix?

[ a b ]     -->  [ d -b ]

[ c d ]            [ -c a ]

100

What is the difference between selection sort and bubble sort?

Selection sort--finds the largest value in the list and switches the position of [-1] to where the largest value was.

Bubble sort--compares a value to the values next to it, 'hopping' through the list

200

Write a truth table for the following: 

¬A ∧ ¬B

A  B    Output

0  0        1

0  1        0

1  0        0

1  1        0

200

What is the output of the following code given a= 1, b=3, c=2

while c < 5:

    if a != 7 and b <= 12:

         a += 2

         b = b*2

         c += 1

A = 7

B = 12

C = 4

200

Evaluate the following:

0: (0--0, 1--4, 2--8, 3--inf, 4--inf)

1: (0--0, 1--4, 2,--8, 3--inf, 4--10)

2: (0--0, 1--4, 2,--8, 3--10, 4--6)

3: (0--0, 1--4, 2,--8, 3--10, 4--6)

4: (0--0, 1--4, 2,--8, 3--10, 4--6)

200

Find the inverse of the key matrix and decrypt the message 'WQPTJE' :

K = [ 2  1 ]

      [ 3  2 ]

SEND IT

200

Sort the following list using selection sort:

arr = [5, 3, 8, 1, 2]

1st pass: arr = [5, 3, 2, 1, 8]

2nd pass: arr = [1, 3, 2, 5, 8]

3rd pass: arr = [1, 2, 3, 5, 8]

300

Fill in the following truth table, with ~ meaning not.

p   ~p      q     ~p∧q

0    1       0         0

0    1       1         1

1    0       0         0 

1    0       1         0

300

What is the output of the following code:

numbers = [2, 4, 6, 9, 10]

all_even = True

for num in numbers:

  if num % 2 != 0:

           print(num, 'is odd')

           all_even = False

  print(num, "is even")

2 is even

4 is even

6 is even

9 is odd 

300

Evaluate the following: 


A: A--0, B--8, C--5, D--inf, E--inf

B: A--0, B--8, C--5, D--9, E--inf

C: A--0, B--8, C--5, D--9, E--16

D: A--0, B--8, C--5, D--9, E--11

E: A--0, B--8, C--5, D--9, E--11

300

Using the key, encrypt the message 'only me'

[ 7  3 ]

[ 2  1 ]

CGDIWR

300

Use bubble sort to sort the following list:

[4, 7, 2, 12, 33, 1, 43]

1st pass: [4, 2, 7, 12, 1, 33, 43]

2nd pass: [2, 4, 7, 1, 12, 33, 43]

3rd pass: [2, 4, 1, 7, 12, 33, 43]

4th pass: [2, 1, 4, 7, 12, 33, 43]

5th pass: [1, 2, 4, 7, 12, 33, 43]

400

Write a truth table for the following:

(¬A) ∧ (B ∨ C)

A    B    C      ¬A      B ∨ C      Output

0    0    0       1          0             0

0    0    1       1          1             1

0    1    0       1          1             1

0    1    1       1          1             1

1    0    0       0          0             0

1    0    1       0          1             0

1    1    0       0          1             0

1    1    1       0          1             0

400

What is the output of the following code if x=4 and y=2?

for i in range(0, 11):

    x += (x*2)

    while x <= 100:

        y = y**2

X = 400

Y = 16

400

Evaluate the following:


A: A--0, B--7, C--inf, D--inf, E--1

B: A--0, B--7, C--10, D--inf, E--1

C: A--0, B--7, C--10, D--16, E--1

D: A--0, B--7, C--10, D--16, E--1

E: A--0, B--7, C--3, D--8, E--1

400

Find the inverse of the key and decrypt the following message, “KLYAOD” using the following key:

[ 2  3 ]

[ 3  5 ]

FOUR PM

400

Use both selection and bubble sort to sort the following list and find which method is more efficient:

[3, 19, 34, 21, 51, 67, 49]

Bubble sort: 1) [3, 19, 21, 34, 51, 49, 67]

2) [3, 19, 21, 34, 49, 51, 67]

Selection sort: 1) [3, 19, 34, 21, 51, 49, 67]

2) [3, 19, 34, 21, 49, 51, 67]

3) [3, 19, 21, 34, 49, 51, 67]

500

Write a truth table for the following circuit:

A       B       ¬A     A∨B   ¬A∧B  (¬A∧B) ∨ (A)

0       0        1        0         0         0

0       1        1        1         0         1

1       0        0        1         0         1

1       1        0        1         0         1

500

What is the output of the following code given lis=[2, 3, 7, 23, 8]?

for i in lis:

    while i < 10:

         i = i*10

         if i // 3 == 0:

              print(i, "is a lucky number")

         else:

              i = 0

print(lis)

30 is a lucky number

[0, 30, 0, 23, 8]

500

Evaluate the following: 


A: A--0, B--4, C--5, D--inf, E--inf, F--inf

B: A--0, B--4, C--5, D--15, E--11, F--inf

C: A--0, B--4, C--5, D--15, E--8, F--inf

D: A--0, B--4, C--5, D--15, E--8, F--15

E: A--0, B--4, C--5, D--15, E--8, F--14

F: A--0, B--4, C--5, D--15, E--8, F--14

500

Encrypt the message 'Computer' using the following key:

K = [ 5  2 ]

      [ 2  1 ]

IUSPOSIB

500

Use both selection sort and bubble sort to sort the following list and determine the efficiency of each:

[23, 12, 3, 71, 68, 35, 9]

Bubble sort: 1) [ 12, 3, 23, 68, 35, 9, 71]

2) [3, 12, 23, 35, 9, 68, 71]

3) [3, 12, 23, 9, 35, 68, 71]

4) [3, 12, 9, 23, 35, 68, 71]

5) [3, 9, 12, 23, 35, 68, 71]

Selection sort: 1) [23, 12, 3, 9, 68, 35, 71]

2) [23, 12, 3, 9, 35, 68, 71]

3) [9, 12, 3, 23, 68, 35, 71]

4) [9, 3, 12, 23, 68, 35, 71]

5) [3, 9 12, 23, 68, 35, 71]

M
e
n
u