Some really nice resources for maths wre written up by Gretchen last week. It contains examples as well as questions which are answered below.
- What kind of graph is this?
directed because it has the arrows, unweighted because there's no numbers
- Draw edge list and adjacency matrix.
edge list
AC, AD, BB, CD, DC, DA, DB
adjacency matrix
ABCD
A 0011
B 0200
C 0001
D 1110
- What kind of graph is this?
undirected because there's no arrows, weighted because there's numbers between the lines
- Draw edge list and adjacency matrix.
edge list
A5B, A2C, A3D, B4C, C1E
adjacency matrix
ABCDE
A 05230
B 00400
C 00001
D 00000
E 00000
- Properties of relations described as "=".
the properties of the relation described as "=" are symmetric, reflexive and transitive, has all three
- Properties of relations described as ">=".
the properties of the relation described as ">=" are reflexive and transitive
- Properties of relations described as ">".
the properties of the relation described as ">" are transitive
- Provide example of transitive relationship.
an example of a transitive relationship is the following: if john is taller than bill, and bill is taller than fred, then its a logical consequence that john is taller than fred
- Binary to hex.
1001 1000
8001 8000
9 8
=>98
0110 0111
6 7
=>67
1101 0110
13 6
D 6
=>D6
0011 0101
3 5
=>35
10) hex to binary
3C
3 12
=>0011 1100
D4
13 4
=>1101 0100
2D
2 13
=> 0010 1101
C3
12 3
=>1100 0011
- Hex to decimal.
16**1 16**0
16 1
3C
3 C
3 12
(16 * 3 = 48) + (1 * 12 = 12) = 60
D4
D 4
13 4
(16 * 13 = 208) + (1 * 4 = 4) = 212
2D
2 D
2 13
(16 * 2 = 32) + (1 * 13 = 13) = 45
C3
12 3
(16 * 12 = 192) + (1 * 3 = 3) = 195
- Order of complexity in BigO from most complex to least.
O(n**2) => looping through two different arrays and comparing, lots of sums (quadratic)
O(n) => looping through one array and comparing it to a result "are you apple?", a fair few sums (linear)
O(log n) => sorting array and then going to middle, asking are you higher or lower than value, excluding values that return false to this every time, least amount of sums in the end (binary)
-
Code to convert base 10 to base 2 in JavaScript.
-
Binary to decimal.
11010110
(0 * 1 = 0) + (1 * 2 = 2) + (1 * 4 = 4) + (0 * 8 = 0) + (1 * 16 = 16) + (0 * 32 = 0) + (1 * 64 = 64) + (1 * 128 = 128) = 2 + 4 + 16 + 64 + 128 = 214
- bitwise operations
&11010001
01110110
--------
01010000
|10110101
10001001
--------
10111101
^10110111
01001011
--------
11111100
- Draw an | truth table.
T F
T|T T
F|T F
- Draw an & truth table.
T F
T|T F
F|F F
- Draw an ^ truth table.
T F
T|F T
F|T F
- Given vowels as set A, given alphabet as domain, find the compliment.
compliment of A is all other alphabet characters that aren't vowels
A = {1,2,3,4}
B = {2,3,6,9}
- What is the intersection of these sets (A ∩ B)?
it's the elements that belong to both sets
{2,3}
- What is A - B (A \ B)
the difference of sets A and B is the set of all elements of A which do not belong to B
{1,4}
For matrices, this is a great resource for remembering how it's row by column.
a = [1,4]
[2,5]
[3,6]
b = [7,8,9]
[0,1,2]
- Multiply a * b.
First item (1 * 7 + 4 * 0 = 7)
Second item (1 * 8 + 4 * 1 = 12)
Third item (1 * 9 + 4 * 2 = 17)
[7, 12, 17]
[14, 21, 28]
[21, 30, 39]