Answers
Reference answers and worked solutions.
1) Define the following with an example
a) Composite number (Even and Odd)
Composite Numbers: A composite number has more than two factors. Besides 1 and itself, it is divisible by at least one more integer. We do not consider 1 as a composite number.
Example:
12 is composite because it can be divided by 1, 2, 3, 4, 6, and 12 more than two factors.
- Even composite example: 12
- Odd composite example: 15 (factors: 1, 3, 5, 15 composite and odd)
b) Perfect number
Perfect Number: A positive integer is perfect if the sum of its proper divisors equals the number.
Formula:
Sum of proper divisors (excluding )
Example:
divisors: 1, 2, 3, 6
Proper divisors: 1, 2, 3
so 6 is perfect.
c) Lucas number
Lucas Numbers: Lucas numbers are similar to Fibonacci numbers. Each term is the sum of the previous two terms, but the first two terms are 2 and 1.
Formula: with ,
Lucas sequence: 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123...
d) Fibonacci number
Fibonacci Sequence: Each number is the sum of the two preceding numbers.
Formula:
, where
Example sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89...
e) Deficient number
Deficient Number: The sum of the proper divisors is less than the number.
Formula:
Example:
Factors of 8 are 1, 2, 4
deficient
f) Abundant number
Abundant Number: The sum of the proper divisors is greater than the number.
Formula:
Example:
factors excluding itself: 1, 2, 3, 6, 9
Sum
abundant
g) Prime number
Prime Number: A prime number has exactly two factors: 1 and itself. 1 is not prime.
Example: 3 is prime because it is divisible by only 1 and 3.
2) Find the Lucas numbers between 10 and 100
Formula: with ,
Lucas numbers: 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123...
Between 10 and 100:
- 11, 18, 29, 47, 76
3) Find the Fibonacci numbers between 10 and 100
Formula: with ,
Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144...
Between 10 and 100:
- 13, 21, 34, 55, 89
4) Find all the perfect numbers from 1 to 1000
Formula: A number is perfect if sum of proper divisors .
From the lecture list: 6, 28, 496, 8128...
Up to 1000:
- 6, 28, 496
5) Check whether numbers are perfect or not
Formulas:
- Perfect:
- Deficient:
- Abundant:
a) 496
496 is a known perfect number.
Perfect
b) 520
520 has many factors, so the sum of proper divisors is greater than the number.
Abundant
c) 320
320 has many factors, so the sum of proper divisors is greater than the number.
Abundant
d) 630
630 has many factors, so the sum of proper divisors is greater than the number.
Abundant
6) Explain the Quotient Remainder Theorem with an example
Formula: , where ( = quotient, = remainder)
Statement: For integers and , there exist unique integers and such that
Example: Let , .
So, and .
7) Caesar cipher: Encrypt and Decrypt "SCHOLARS", key = 3
Formulas:
Letters: , , ...,
Encryption ()
Do all letters:
Ciphertext = VFKRODUV
Decryption ()
Doing all letters returns:
SCHOLARS
8) Caesar cipher: Encrypt and Decrypt "ASSIGNMENT", key = 4
Formulas:
Encryption ()
Apply :
, , , , , , , , ,
Ciphertext = EWWMKRQIRX
Decryption ()
Apply :
9) Handshaking Lemma (20 edges)
Formula:
So:
Given:
- 3 vertices degree 5
- 7 vertices degree 3
Current sum:
Let remaining vertices be , each degree 2:
Total vertices:
Total vertices = 12
10) Handshaking Lemma (22 edges)
Formula:
Given:
- 6 vertices degree 5
- 4 vertices degree 3
Sum:
Remaining vertices degree 3: let count =
But must be an integer. So this is not possible.
No such graph exists with this data.
11) Find GCD & LCM of 33 and 12
Formula:
First find using Euclidean algorithm:
So, .
Now:
GCD = 3, LCM = 132
12) Find GCD & LCM of 95 and 496
Formula:
Check common factors:
No common factor
GCD = 1, LCM = 47120
13) MST using Prim's and Kruskal's (Start = 1)
Formula: MST has exactly edges.
Kruskal
Sort edge weights:
Pick smallest non-cycle edges:
- discard (cycle)
Now we have edges.
MST edges (Kruskal): , , , , ,
Total weight:
Prim's method (start at 1)
From 1:
- , pick
Visited:
- Candidate: , pick
- Candidate: , , pick
- Candidate: , , pick
- Candidate: , , pick
- Candidate: , , pick
Total weight:
Result: Prim's MST cost = 99 and Kruskal MST cost = 99, so they are equal.
14) MST using Prim's and Kruskal's (Start = a)
Formula: Same as Question 13.
Note: In the picture, the rightmost vertex is labeled "e" again. Here it is treated as .
Edges with weights:
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
Kruskal
Pick smallest non-cycle edges:
- -
- -
- -
- -
- - discard (cycle)
- -
- - discard (cycle)
- -
Total:
Prim (start at )
- Pick -
- From pick -
- Next pick -
- Next pick -
- Next pick -
- Next pick -
Total:
Result: Prim's = 26 and Kruskal = 26, so they are equal.
15) Differentiate between Bipartite & Complete Bipartite Graph
Formula (Complete Bipartite):
Bipartite Graph: A graph whose vertex set can be split into two disjoint sets and such that every edge joins a vertex in to a vertex in .
Complete Bipartite Graph: A bipartite graph in which every vertex of is connected to every vertex of .
16) Differentiate between Cyclic, Acyclic, and DAG
- Cyclic graph: contains a cycle
- Acyclic graph: contains no cycle
- Directed Acyclic Graph (DAG): a directed graph with no directed cycles
17) Differentiate between Planar & Non-Planar Graph
- Planar graph: can be drawn in a plane without edge crossings except at endpoints
- Non-planar graph: cannot be drawn in a plane without edge crossings
18) Searching (show all steps)
Formulas:
- Linear search: compare key with each element from index 0 until match or end
- Binary search: ; if key value go left, else go right
Array: 10 20 30 40 50 60 70 80 90
a) Linear Search for 40
- vs not match
- vs not match
- vs not match
- vs match
So, 40 is found at index 3 (0-based) or position 4 (1-based).
b) Binary Search for 30
Array is sorted.
- ,
- go left
- ,
- go right
- ,
- Match
So, 30 is found at index 2 (0-based) or position 3 (1-based).
19) Sorting: 14 33 27 35 10
Formulas:
- Bubble sort: compare adjacent pairs; swap if out of order; repeat until no swaps
- Merge sort: Divide -> Conquer -> Combine
a) Bubble Sort
Start:
Pass 1
- ok
- swap
- ok
- swap
Pass 2
- ok
- ok
- swap
Pass 3
- ok
- swap
Pass 4
- swap
b) Merge Sort
Start:
Divide
- Left:
- Right:
Further divide:
- and
- and
Conquer
Combine
20) Relation properties ()
Property formulas:
- Reflexive:
- Irreflexive:
- Symmetric:
- Asymmetric:
- Antisymmetric:
- Transitive:
a)
- Reflexive? Yes
- Irreflexive? No
- Symmetric? Yes
- Asymmetric? No
- Antisymmetric? No
- Transitive? Yes
b)
- Reflexive? No
- Irreflexive? Yes
- Symmetric? No
- Asymmetric? Yes
- Antisymmetric? Yes
- Transitive? No
c)
- Reflexive? Yes
- Irreflexive? No
- Symmetric? No
- Asymmetric? No
- Antisymmetric? No
- Transitive? No
d)
- Reflexive? Yes
- Irreflexive? No
- Symmetric? No
- Asymmetric? No
- Antisymmetric? Yes
- Transitive? No
e)
- Reflexive? Yes
- Irreflexive? No
- Symmetric? Yes
- Asymmetric? No
- Antisymmetric? No
- Transitive? Yes
f)
- Reflexive? Yes
- Irreflexive? No
- Symmetric? Yes
- Asymmetric? No
- Antisymmetric? No
- Transitive? Yes
IUS Preps - Your Academic Success Partner