Suggestions logoSuggestions

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 \Rightarrow more than two factors.

  • Even composite example: 12
  • Odd composite example: 15 (factors: 1, 3, 5, 15 \Rightarrow composite and odd)

b) Perfect number

Perfect Number: A positive integer NN is perfect if the sum of its proper divisors equals the number.

Formula:
Sum of proper divisors (excluding NN) =N= N

Example:
66 \Rightarrow divisors: 1, 2, 3, 6
Proper divisors: 1, 2, 3
1+2+3=61+2+3 = 6 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: Ln=Ln1+Ln2L_n = L_{n-1} + L_{n-2} with L0=2L_0 = 2, L1=1L_1 = 1

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:
Fn=Fn1+Fn2F_n = F_{n-1} + F_{n-2}, where n2n \ge 2

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:
sum of proper divisors<N\text{sum of proper divisors} < N

Example:
Factors of 8 are 1, 2, 4
1+2+4=71+2+4 = 7
7<87 < 8 \Rightarrow deficient

f) Abundant number

Abundant Number: The sum of the proper divisors is greater than the number.

Formula:
sum of proper divisors>N\text{sum of proper divisors} > N

Example:
1818 \Rightarrow factors excluding itself: 1, 2, 3, 6, 9
Sum =1+2+3+6+9=21= 1+2+3+6+9 = 21
21>1821 > 18 \Rightarrow 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: Ln=Ln1+Ln2L_n = L_{n-1} + L_{n-2} with L0=2L_0 = 2, L1=1L_1 = 1

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: Fn=Fn1+Fn2F_n = F_{n-1} + F_{n-2} with F0=0F_0 = 0, F1=1F_1 = 1

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 NN is perfect if sum of proper divisors =N= N.

From the lecture list: 6, 28, 496, 8128...

Up to 1000:

  • 6, 28, 496

5) Check whether numbers are perfect or not

Formulas:

  • Perfect: sum(proper divisors)=N\text{sum(proper divisors)} = N
  • Deficient: sum(proper divisors)<N\text{sum(proper divisors)} < N
  • Abundant: sum(proper divisors)>N\text{sum(proper divisors)} > N

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: a=bq+ra = bq + r, where 0r<b0 \le r < b (qq = quotient, rr = remainder)

Statement: For integers aa and b>0b > 0, there exist unique integers qq and rr such that

a=bq+r,0r<ba = bq + r,\quad 0 \le r < b

Example: Let a=29a = 29, b=5b = 5.

29=5(5)+4,04<529 = 5(5) + 4,\quad 0 \le 4 < 5

So, q=5q = 5 and r=4r = 4.


7) Caesar cipher: Encrypt and Decrypt "SCHOLARS", key = 3

Formulas:
En(x)=(x+n)mod26E_n(x) = (x + n) \bmod 26
Dn(x)=(xin)mod26D_n(x) = (x_i - n) \bmod 26

Letters: A=0A=0, B=1B=1, ..., Z=25Z=25

Encryption (n=3n = 3)

S18S \Rightarrow 18
(18+3)mod26=21V(18+3) \bmod 26 = 21 \Rightarrow V

Do all letters:

  • SVS \Rightarrow V
  • CFC \Rightarrow F
  • HKH \Rightarrow K
  • ORO \Rightarrow R
  • LOL \Rightarrow O
  • ADA \Rightarrow D
  • RUR \Rightarrow U
  • SVS \Rightarrow V

Ciphertext = VFKRODUV

Decryption (n=3n = 3)

Dn(x)=(xi3)mod26D_n(x) = (x_i - 3) \bmod 26

V21V \Rightarrow 21

(213)mod26=18S(21-3) \bmod 26 = 18 \Rightarrow S

Doing all letters returns:

SCHOLARS


8) Caesar cipher: Encrypt and Decrypt "ASSIGNMENT", key = 4

Formulas:
En(x)=(x+n)mod26E_n(x) = (x+n) \bmod 26
Dn(x)=(xin)mod26D_n(x) = (x_i-n) \bmod 26

Encryption (n=4n = 4)

Apply En(x)=(x+4)mod26E_n(x) = (x+4) \bmod 26:

AEA \Rightarrow E, SWS \Rightarrow W, SWS \Rightarrow W, IMI \Rightarrow M, GKG \Rightarrow K, NRN \Rightarrow R, MQM \Rightarrow Q, EIE \Rightarrow I, NRN \Rightarrow R, TXT \Rightarrow X

Ciphertext = EWWMKRQIRX

Decryption (n=4n = 4)

Apply Dn(x)=(xi4)mod26D_n(x) = (x_i-4) \bmod 26:

EWWMKRQIRXASSIGNMENT\text{EWWMKRQIRX} \Rightarrow \text{ASSIGNMENT}

9) Handshaking Lemma (20 edges)

Formula: deg(v)=2E\sum \deg(v) = 2E

So:

deg(v)=2×20=40\sum \deg(v) = 2 \times 20 = 40

Given:

  • 3 vertices degree 5 3×5=15\Rightarrow 3 \times 5 = 15
  • 7 vertices degree 3 7×3=21\Rightarrow 7 \times 3 = 21

Current sum:

15+21=3615 + 21 = 36

Let remaining vertices be xx, each degree 2:

36+2x=402x=4x=236 + 2x = 40 \Rightarrow 2x = 4 \Rightarrow x = 2

Total vertices:

3+7+2=123 + 7 + 2 = 12

Total vertices = 12


10) Handshaking Lemma (22 edges)

Formula: deg(v)=2E\sum \deg(v) = 2E

deg(v)=2×22=44\sum \deg(v) = 2 \times 22 = 44

Given:

  • 6 vertices degree 5 6×5=30\Rightarrow 6 \times 5 = 30
  • 4 vertices degree 3 4×3=12\Rightarrow 4 \times 3 = 12

Sum:

30+12=4230 + 12 = 42

Remaining vertices degree 3: let count = xx

42+3x=443x=242 + 3x = 44 \Rightarrow 3x = 2

But xx 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:

LCM(A,B)=A×BGCD(A,B)LCM(A,B) = \frac{A \times B}{GCD(A,B)}

First find GCD(33,12)GCD(33,12) using Euclidean algorithm:

  • 33=12×2+933 = 12 \times 2 + 9
  • 12=9×1+312 = 9 \times 1 + 3
  • 9=3×3+09 = 3 \times 3 + 0

So, GCD=3GCD = 3.

Now:

LCM(33,12)=33×123=132LCM(33,12) = \frac{33 \times 12}{3} = 132

GCD = 3, LCM = 132


12) Find GCD & LCM of 95 and 496

Formula:

LCM(A,B)=A×BGCD(A,B)LCM(A,B) = \frac{A \times B}{GCD(A,B)}

Check common factors:

  • 95=5×1995 = 5 \times 19
  • 496=24×31496 = 2^4 \times 31

No common factor GCD=1\Rightarrow GCD = 1

LCM(95,496)=95×4961=47120LCM(95,496) = \frac{95 \times 496}{1} = 47120

GCD = 1, LCM = 47120


13) MST using Prim's and Kruskal's (Start = 1)

Formula: MST has exactly V1|V|-1 edges.

Kruskal

Sort edge weights:

10, 12, 14, 16, 18, 22, 24, 25, 2810,\ 12,\ 14,\ 16,\ 18,\ 22,\ 24,\ 25,\ 28

Pick smallest non-cycle edges:

  • (1,6)=10(1,6)=10
  • (3,4)=12(3,4)=12
  • (2,7)=14(2,7)=14
  • (2,3)=16(2,3)=16
  • (7,4)=18(7,4)=18 discard (cycle)
  • (4,5)=22(4,5)=22
  • (5,6)=25(5,6)=25

Now we have V1=6|V|-1 = 6 edges.

MST edges (Kruskal): (1,6)(1,6), (3,4)(3,4), (2,7)(2,7), (2,3)(2,3), (4,5)(4,5), (5,6)(5,6)

Total weight:

10+12+14+16+22+25=9910+12+14+16+22+25 = 99

Prim's method (start at 1)

From 1:

  • (1,6)=10(1,6)=10, (1,2)=28(1,2)=28 \Rightarrow pick (1,6)=10(1,6)=10

Visited: {1,6}\{1,6\}

  • Candidate: (6,5)=25(6,5)=25, (1,2)=28(1,2)=28 \Rightarrow pick (6,5)=25(6,5)=25
  • Candidate: (5,4)=22(5,4)=22, (5,7)=24(5,7)=24, (1,2)=28(1,2)=28 \Rightarrow pick (5,4)=22(5,4)=22
  • Candidate: (4,3)=12(4,3)=12, (4,7)=18(4,7)=18, (1,2)=28(1,2)=28 \Rightarrow pick (4,3)=12(4,3)=12
  • Candidate: (3,2)=16(3,2)=16, (4,7)=18(4,7)=18, (1,2)=28(1,2)=28 \Rightarrow pick (3,2)=16(3,2)=16
  • Candidate: (2,7)=14(2,7)=14, (4,7)=18(4,7)=18, (5,7)=24(5,7)=24 \Rightarrow pick (2,7)=14(2,7)=14

Total weight:

10+25+22+12+16+14=9910+25+22+12+16+14 = 99

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 gg.

Edges with weights:

  • aa-b(1)b(1)
  • aa-c(5)c(5)
  • bb-c(4)c(4)
  • bb-d(8)d(8)
  • cc-d(6)d(6)
  • bb-e(7)e(7)
  • dd-e(11)e(11)
  • dd-f(9)f(9)
  • cc-f(2)f(2)
  • ee-f(3)f(3)
  • ee-g(10)g(10)
  • ff-g(12)g(12)

Kruskal

Pick smallest non-cycle edges:

  • aa-b(1)b(1)
  • cc-f(2)f(2)
  • ee-f(3)f(3)
  • bb-c(4)c(4)
  • aa-c(5)c(5) discard (cycle)
  • cc-d(6)d(6)
  • bb-e(7)e(7) discard (cycle)
  • ee-g(10)g(10)

Total:

1+2+3+4+6+10=261+2+3+4+6+10 = 26

Prim (start at aa)

  • Pick aa-b(1)b(1)
  • From {a,b}\{a,b\} pick bb-c(4)c(4)
  • Next pick cc-f(2)f(2)
  • Next pick ff-e(3)e(3)
  • Next pick cc-d(6)d(6)
  • Next pick ee-g(10)g(10)

Total:

1+4+2+3+6+10=261+4+2+3+6+10 = 26

Result: Prim's = 26 and Kruskal = 26, so they are equal.


15) Differentiate between Bipartite & Complete Bipartite Graph

Formula (Complete Bipartite):

E=V1V2=mn|E| = |V_1| \cdot |V_2| = m \cdot n

Bipartite Graph: A graph whose vertex set can be split into two disjoint sets V1V_1 and V2V_2 such that every edge joins a vertex in V1V_1 to a vertex in V2V_2.

Complete Bipartite Graph: A bipartite graph in which every vertex of V1V_1 is connected to every vertex of V2V_2.


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: mid=(low+high)/2mid = \lfloor (low + high)/2 \rfloor; if key << value go left, else go right

Array: 10 20 30 40 50 60 70 80 90

a) Linear Search for 40

  • 4040 vs 1010 \Rightarrow not match
  • 4040 vs 2020 \Rightarrow not match
  • 4040 vs 3030 \Rightarrow not match
  • 4040 vs 4040 \Rightarrow match

So, 40 is found at index 3 (0-based) or position 4 (1-based).

b) Binary Search for 30

Array is sorted.

  • low=0low=0, high=8mid=(0+8)//2=4value=50high=8 \Rightarrow mid=(0+8)//2=4 \Rightarrow value=50
  • 30<5030 < 50 \Rightarrow go left
  • low=0low=0, high=3mid=(0+3)//2=1value=20high=3 \Rightarrow mid=(0+3)//2=1 \Rightarrow value=20
  • 30>2030 > 20 \Rightarrow go right
  • low=2low=2, high=3mid=(2+3)//2=2value=30high=3 \Rightarrow mid=(2+3)//2=2 \Rightarrow value=30
  • 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:

[14,33,27,35,10][14, 33, 27, 35, 10]

Pass 1

  • (14,33)(14, 33) ok [14,33,27,35,10]\Rightarrow [14, 33, 27, 35, 10]
  • (33,27)(33, 27) swap [14,27,33,35,10]\Rightarrow [14, 27, 33, 35, 10]
  • (33,35)(33, 35) ok [14,27,33,35,10]\Rightarrow [14, 27, 33, 35, 10]
  • (35,10)(35, 10) swap [14,27,33,10,35]\Rightarrow [14, 27, 33, 10, 35]

Pass 2

  • (14,27)(14, 27) ok
  • (27,33)(27, 33) ok
  • (33,10)(33, 10) swap [14,27,10,33,35]\Rightarrow [14, 27, 10, 33, 35]

Pass 3

  • (14,27)(14, 27) ok
  • (27,10)(27, 10) swap [14,10,27,33,35]\Rightarrow [14, 10, 27, 33, 35]

Pass 4

  • (14,10)(14, 10) swap [10,14,27,33,35]\Rightarrow [10, 14, 27, 33, 35]

b) Merge Sort

Start:

[14,33,27,35,10][14, 33, 27, 35, 10]

Divide

  • Left: [14,33,27][14, 33, 27]
  • Right: [35,10][35, 10]

Further divide:

  • [14][14] and [33,27][33, 27]
  • [33][33] and [27][27]

Conquer

  • merge([33],[27])[27,33]merge([33],[27]) \Rightarrow [27,33]
  • merge([14],[27,33])[14,27,33]merge([14],[27,33]) \Rightarrow [14,27,33]
  • merge([35],[10])[10,35]merge([35],[10]) \Rightarrow [10,35]

Combine

  • merge([14,27,33],[10,35])[10,14,27,33,35]merge([14,27,33],[10,35]) \Rightarrow [10,14,27,33,35]

20) Relation properties (A={1,2,3,4}A = \{1,2,3,4\})

Property formulas:

  • Reflexive: a((a,a)R)\forall a\,((a, a) \in R)
  • Irreflexive: a((a,a)R)\forall a\,((a, a) \notin R)
  • Symmetric: ab((a,b)R(b,a)R)\forall a \forall b\,((a, b) \in R \rightarrow (b, a) \in R)
  • Asymmetric: ab((a,b)R(b,a)R)\forall a \forall b\,((a, b) \in R \rightarrow (b, a) \notin R)
  • Antisymmetric: ab(((a,b)R(b,a)R)(a=b))\forall a \forall b\,(((a, b) \in R \wedge (b, a) \in R) \rightarrow (a = b))
  • Transitive: abc(((a,b)R(b,c)R)(a,c)R)\forall a \forall b \forall c\,(((a, b) \in R \wedge (b, c) \in R) \rightarrow (a, c) \in R)

a) R1={(1,1),(2,2),(3,3),(4,4),(2,4),(4,2)}R_1 = \{(1,1), (2,2), (3,3), (4,4), (2,4), (4,2)\}

  • Reflexive? Yes
  • Irreflexive? No
  • Symmetric? Yes
  • Asymmetric? No
  • Antisymmetric? No
  • Transitive? Yes

b) R2={(1,2),(2,4),(1,4),(3,1)}R_2 = \{(1,2), (2,4), (1,4), (3,1)\}

  • Reflexive? No
  • Irreflexive? Yes
  • Symmetric? No
  • Asymmetric? Yes
  • Antisymmetric? Yes
  • Transitive? No

c) R3={(1,1),(2,2),(3,3),(4,4),(1,3),(3,1),(2,3)}R_3 = \{(1,1), (2,2), (3,3), (4,4), (1,3), (3,1), (2,3)\}

  • Reflexive? Yes
  • Irreflexive? No
  • Symmetric? No
  • Asymmetric? No
  • Antisymmetric? No
  • Transitive? No

d) R4={(1,1),(2,2),(3,3),(4,4),(4,1),(1,2)}R_4 = \{(1,1), (2,2), (3,3), (4,4), (4,1), (1,2)\}

  • Reflexive? Yes
  • Irreflexive? No
  • Symmetric? No
  • Asymmetric? No
  • Antisymmetric? Yes
  • Transitive? No

e) R5=A×AR_5 = A \times A

  • Reflexive? Yes
  • Irreflexive? No
  • Symmetric? Yes
  • Asymmetric? No
  • Antisymmetric? No
  • Transitive? Yes

f) R6={(1,1),(2,2),(3,3),(4,4),(1,3),(3,1)}R_6 = \{(1,1), (2,2), (3,3), (4,4), (1,3), (3,1)\}

  • Reflexive? Yes
  • Irreflexive? No
  • Symmetric? Yes
  • Asymmetric? No
  • Antisymmetric? No
  • Transitive? Yes

IUS Preps - Your Academic Success Partner

On this page

1) Define the following with an examplea) Composite number (Even and Odd)b) Perfect numberc) Lucas numberd) Fibonacci numbere) Deficient numberf) Abundant numberg) Prime number2) Find the Lucas numbers between 10 and 1003) Find the Fibonacci numbers between 10 and 1004) Find all the perfect numbers from 1 to 10005) Check whether numbers are perfect or nota) 496b) 520c) 320d) 6306) Explain the Quotient Remainder Theorem with an example7) Caesar cipher: Encrypt and Decrypt "SCHOLARS", key = 3Encryption (n=3n = 3)Decryption (n=3n = 3)8) Caesar cipher: Encrypt and Decrypt "ASSIGNMENT", key = 4Encryption (n=4n = 4)Decryption (n=4n = 4)9) Handshaking Lemma (20 edges)10) Handshaking Lemma (22 edges)11) Find GCD & LCM of 33 and 1212) Find GCD & LCM of 95 and 49613) MST using Prim's and Kruskal's (Start = 1)KruskalPrim's method (start at 1)14) MST using Prim's and Kruskal's (Start = a)KruskalPrim (start at aa)15) Differentiate between Bipartite & Complete Bipartite Graph16) Differentiate between Cyclic, Acyclic, and DAG17) Differentiate between Planar & Non-Planar Graph18) Searching (show all steps)a) Linear Search for 40b) Binary Search for 3019) Sorting: 14 33 27 35 10a) Bubble Sortb) Merge Sort20) Relation properties (A={1,2,3,4}A = \{1,2,3,4\})a) R1={(1,1),(2,2),(3,3),(4,4),(2,4),(4,2)}R_1 = \{(1,1), (2,2), (3,3), (4,4), (2,4), (4,2)\}b) R2={(1,2),(2,4),(1,4),(3,1)}R_2 = \{(1,2), (2,4), (1,4), (3,1)\}c) R3={(1,1),(2,2),(3,3),(4,4),(1,3),(3,1),(2,3)}R_3 = \{(1,1), (2,2), (3,3), (4,4), (1,3), (3,1), (2,3)\}d) R4={(1,1),(2,2),(3,3),(4,4),(4,1),(1,2)}R_4 = \{(1,1), (2,2), (3,3), (4,4), (4,1), (1,2)\}e) R5=A×AR_5 = A \times Af) R6={(1,1),(2,2),(3,3),(4,4),(1,3),(3,1)}R_6 = \{(1,1), (2,2), (3,3), (4,4), (1,3), (3,1)\}