You are on page 1of 9

HIGHER COLLEGES OF TECHNOLOGY

Computer and Information Science

Non-Exam Based Assessment Cover


Sheet/ Project

Course Name Applied Discrete Mathematics Course Code CIS2203

5th May
Issue Date 14th March 2021 Week10 Submission Date
2021

Maximum Marks 100 Percentage of Final Grade 25%

Student Names Student ID’s

College Section CRN 26096

This assessment will assess the following Course learning outcomes:


CLO1 CLO2 CLO3 CLO4

Question No. √ √ √ √

• The entire project/case study/poster is designed and developed by me (and my team members).
• The proper citation has been used when I (and my team members) used other sources.
• No part of this project has been designed, developed or written for me (and my team members)
by a third party.
• I have a copy of this project in case the submitted copy is lost or damaged.
• None of the music/graphics/animation/video/images used in this project have violated the Copy
Right/Patent/Intellectual Property rights of an individual, company or an Institution.  I have
the written permission from people who are featuring in this project.

Student Signature: Date:

For Examiner’s Use Only


Oral
Question No. Part 1 Part 2 Part 3 Part 4 Total
Defense
Marks Allocated 8 8 8 26 50 100

Marks Obtained
1
Part 1 (CLO1): Logic and proof
Express English statements in logic using propositions and logical connectives.

Let P, Q and R be the propositions:


P: You missed many classes.
Q: You take notes during class.
R: You pass the course.

a) You attended all classes, but you failed the course.

¬P∧¬R
P R ¬P ¬R ¬P∧¬R

T T F F F

T F F T F

F T T F F

F F T T T

b) The only way to pass the course is to attend all classes and to take notes during class.

R↔(¬P∧Q)
P Q R ¬P (¬P∧Q) R↔(¬P∧Q)

T T T F F F

T T F F F T

T F T F F F

T F F F F T

F T T T T T

F T F T T F

F F T T F F

F F F T F T

2
c) If you missed many classes, then you did not take notes during these classes.

P→¬Q
P Q ¬Q P→¬Q

T T F F

T F T T

F T F T

F F T T

d) You might fail the course in case you missed many classes, or you did not take notes.

¬R →(P∨¬Q)
P Q R ¬Q ¬R (P∨¬Q) ¬R→(P∨¬Q
)

T T T F F T T

T T F F T T T

T F T T F T T

T F F T T T T

F T T F F F T

F T F F T F F

F F T T F T T

F F F T T T T

Part 2 (CLO2): Sorting Algorithms:


1- Write the Algorithm that describes the process.
2- Write the algorithm as a code in Python, and test your code using any input.

3
1- Algorithm 2- Python

4
1. Set a list. def mergeSort(array):
if len(array) > 1:

2. Find the middle point to divide the array r = len(array)//2


into two halves: L = array[:r]
middle m = l+ (r-l)/2 M = array[r:]

3. Call mergeSort for first half: mergeSort(L)


Call mergeSort(arr, l, m) mergeSort(M)

i=j=k=0

4. Call mergeSort for second half: while i < len(L) and j < len(M):
Call mergeSort(arr, m+1, r) if L[i] < M[j]:
array[k] = L[i]
i += 1
else:
5. Merge the two halves sorted in step 2 and
3: array[k] = M[j]
Call merge(arr, l, m, r) j += 1
k += 1
6. Print the sort.
while i < len(L):
array[k] = L[i]
i += 1
k += 1

while j < len(M):


array[k] = M[j]
j += 1
k += 1

array = [1, -4, 14, -4, 34, 10, 7, -7, 34, 1]

def printList(array):
for i in range(len(array)):
print(array[i], end=" ")
print()

if __name__ == '__main__':
array = [1, -4, 14, -4, 34, 10, 7, -7, 34, 1]

mergeSort(array)

print("Sorted array is: ")


printList(array)

5
Part 3 (CLO3): Complexity of algorithm:

1- Calculate the total number of steps required by the algorithm, and express it as a
function of n (f(n) ).
2- Determine the Time complexity of the algorithm using Big-O notation.

Algorithm Python Calculation


1.x=n Def primeFactors(n) 0
2.while n is divisible by While n%2==0 -- n+1 n+1
s Print 2 -- 0 0
Print 2 N=n/2 -- n N
Divide n by 2
3.n must be odd For i in range n+5
4.loop from i=3 to (3,n+1,2) -- n+5
square root of n n+1
5.while I divides n While n %i ==0 -- n+1 0
Print i Print i – 0 N
Divide n by i N=n/i -- n
6.increment I by 2 1
7.if n is a prime and n > If n>2 – 1 0
2 Print n – 0
N will not become 1 F(n) = 5n+8 F(n)=5n+8
Print n if it >2

2- Time required for this algorithm is O(n)

6
Part 4 (CLO4): Structures:
1- Use Graph coloring to solve one of the following problems.

2- Construct a graph using an Adjacency matrix.

3- Analyze the following weighed graph and find the shortest path between two vertices.

7
Path Weight/cost
A→ G→ I→ J 210 + 253 + 209 = 672
A→E→F→J 235 + 174 + 480 = 889
A → V→ N → O → I → J 118 + 377 + 111 + 217 + 209 =
1032
A → V → N→ L→ K → J 118 + 377 + 251 + 192 + 123 =
1061
A→V→G→I →J 118 + 176 + 253 + 209 = 756
A → G → H→ E → F → J 210 + 98 + 115 + 174 + 480=
1077

The shortest path between A and J is 672 through A → G → I → J

4- Use Kruskal’s algorithm to construct the Minimum Spanning Tree (MST) for a graph.

8
edge dv edge dv

(7,8) 1 √ (1,9) 5 √

(4,9) 2 √ (4,9) 5 √ edg dv


(6,9) 5 √ e
(5,7) 3 √
(3,4 7 x
(2,3) 3 √ (1,6) 6 x
)
(6,7) 4 √ (9,9) 6 x
(2,7 7 x
(5,6) 5 x (6,8) 6 x )

(6,9) 5 √ (3,5) 6 √ (2,4 11 x


)

Total Cost =  dv = 34

You might also like