ECC Trimester 3 2018: ENS1161D Computer Fundamentals Assignment 2

Verified

Added on  2023/04/21

|12
|2022
|306
Homework Assignment
AI Summary
This document presents a detailed solution to a Computer Fundamentals assignment (ENS1161D) focusing on several key areas of theoretical computer science. The assignment covers functions defined on a set, including calculations of composite and inverse functions. It also delves into relations between sets, represented by matrices, and explores the logical matrix product to determine relationships. A significant portion of the assignment is dedicated to number systems, including conversions between decimal, octal, binary, and hexadecimal representations, as well as binary and hexadecimal addition. Additionally, the solution addresses the conversion of decimal fractions to binary and performs binary addition. The document also includes solutions for BCD addition and explores the interpretation of binary numbers with flags for carry, negative, and overflow conditions. Finally, the assignment concludes with calculating row and column positions in arrays based on sequence positions, utilizing ceiling and modulo functions.
Document Page
Running head: COMPUTER FUNDAMENTALS
ENS1161D COMPUTER FUNDAMENTALS
Name of the Student
Name of the University
Author Note
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
1COMPUTER FUNDAMENTALS
Question 1:
The functions f, g and h are defined on the set {0,1,2,3,….,12} is given below.
i) Hence, f(g(h(10))) = f(g(10)) = f(12) = 12.
Now, f1 (h1 ( 6 ) ) = f1 (7) = 11
ii) For constructing the table of values for g( f1 ( x )) at first f 1 ( x ) is calculated and
then the g function of that value is calculated.
x 0 1 2 3 4 5 6 7 8 9 10 11 12
g(f1 ( x ) ) 0 1 5 1 12 5 5 8 8 1 12 8 12
iii) The table for h(h(x) is shown below.
x 0 1 2 3 4 5 6 7 8 9 10 11 12
h( h ( x ) ) 0 1 2 3 4 5 6 7 8 9 10 11 12
Hence, as h(x) = x hence, h1 ( x ) = h(x).
Document Page
2COMPUTER FUNDAMENTALS
iv) The table for f1 ( x ) is the following.
x 0 1 2 3 4 5 6 7 8 9 10 11 12
f1 ( x ) 0 1 6 9 10 5 2 11 8 3 4 7 12
Question 2:
The set of Growers G = {a,b,c,d} and the set of retailers R = {e,f,g} and a set of customers
C = {m,n,p,q,r}. The relations A and B are given by G x R and R x C which are defined by:
{aAe, bAg, cAf, dAe, dAg} and {eBn, eBr, fBm, fBq, gBp} respectively.
i) Hence, the relationship matrix
f 1 ( x )
Document Page
3COMPUTER FUNDAMENTALS
M(A) =
e f g
a 1 0 0
b 0 0 1
c 0 1 0
d 1 0 1
M(B) =
M n p q r
e 0 1 0 0 1
f 1 0 0 1 0
g 0 0 1 0 0
ii) The inverse of relation A = A1 ¿ M ( A ) T =
A b c d
e 1 0 0 1
f 0 0 1 0
g 0 1 0 1
The inverse of the relation B = B1 = M ( B )T =
e f g
m 0 1 0
n 1 0 0
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
4COMPUTER FUNDAMENTALS
p 0 0 1
q 0 1 0
r 1 0 0
iii) The logical matrix product of M(A)M(B) will follow the Boolean OR convention.
Hence, after computing M(A)M(B) and ( M ( A ) T ) ( M ( B ) T ) and then finally
computing M(A)M(B)( M ( A )T ) ( M ( B )T ) the query can be answered. Now, it is
found that the customer p has the relation with retailer g. Now, the retailer g gets
goods from growers’ b and d. Now, d also supplies goods to retailer e and e
supplies to the customers n and r. Hence, customers n and r receives goods from
same grower as received by p.
Question 3:
a)
i) 11910 = 7*8^0 + 6*8^1 + 1*8^2= 1678.
9610 = 0*8^0 + 4*8^1 + 1*8^2 = 1408
ii) Now, for converting the octal numbers into binary each of the octal numbers
are represented by three binary digits.
Hence, 1678 = ((001)(110)(111))2 = (1110111)2
1408 = ((001)(100)(000))2 = (1100000)2
iii) Now, the binary numbers are converted to hexadecimal by grouping the
numbers by 4 digits.
(1110111)2 = ((0111)(0111))2 = (7716)
(1100000)2 = ((0110)(0000))2 = (6016)
Document Page
5COMPUTER FUNDAMENTALS
iv) Now, the hex addition rule is same as the decimal addition rule except the
carry is forwarded to the next upper bit when the result of addition exceeds F(15).
Hence, (7716) + (6016) = (D7)16.
v) The hexadecimal sum is then converted to binary.
(D7)16 = ((1101)(0111))2 = (11010111)2
Then the binary is converted to octal.
(11010111)2 = ((011)(010)(111))2 = 3278.
Now, 3278 is converted to decimal by the following method.
3278 = 3*8^2 + 2*8^1 + 7*8^0 = 3*64 + 16 + 7 = (215)10
Hence, in table format
Decimal octal binary hexadecimal
119 167 1110111 77
96 140 1100000 60
215 327 11010111 D7
b) i) The decimal fraction 0.53125 is converted to binary by the following method.
53125 is divided repeatedly by 2 and then the remainder in each division is
assigned from top to bottom order.
Hence, the result is (0.10001)2
It can be verified that (0.10001)2 = 1*2^(-1) + 0*2^(-2) + 0*2^(-3) + 0*2^(-4) +
1*2^(-5) = 0.5 + 0.0313 = 0.5313. Now, 0.53125 can be approximated to 0.5313.
ii) (0.09375)10 = (0.00011)2.
Document Page
6COMPUTER FUNDAMENTALS
It can be verified that,
(0.00011)2 = 0*2^(-1) + 0*2^(-2) + 0*2^(-3) + 1*2^(-4) + 1*2^(-5) = 0.0938.
0.09375 ~ 0.0938.
iii) Now, the binary fractions are added in binary addition method where
1+1 = 0 (carry 1), 1+0 = 1(carry 0), 0+1 = 1 (carry 0) and 0+0 = 0(carry 0).
0.10001
+ 0.00011
= (0.10100)2
iv) Now, the fractional binary is converted to decimal in the following way.
(0.10100)2 = 0.6250.
c) i)
1101011
+1001111
= (10111010)2
Rules for binary addition followed: 1+1 = 0(carry 1), 1+0 = 1(carry 0),
0+1 = 1(carry 0), 0+0 = 0 (carry 0).
ii)
(2756)8
+(5724)8
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7COMPUTER FUNDAMENTALS
= (10702)8
Rules for octal addition followed: if sum exceeds 7 carry 1 is forwarded to
next bit addition and result is (sum – 8). Otherwise if sum is less or equals 7
then result is sum and carry is 0.
iii) The hexadecimal addition is given below.
(2AE5C)16
+(B52F7)16
= (E0153)16
Now, the hex addition rule is as follows: when the sum is over F then the carry
to the next bit addition is 1 and result is (sum-16). Otherwise carry is zero and
result is the sum.
c) The rules BCD addition of hex numbers is the following. At first each hex digit is
converted to 4 bit binary digits. Then individual addition of each 4 bits are
performed by the following rule.
i) The carry is zero and sum is less than or equal to 9 then result is sum.
ii) If the sum is more than 9 then 6 in BCD form is added to the result.
Now, if there is carry in MSB bit addition the carry is put in the MSB of result.
d)
i) 29578 = 0010 1001 0101 0111 1000
+31495 = 0011 0001 0100 1001 0101
Document Page
8COMPUTER FUNDAMENTALS
Hence, 0010 1001 0101 0111 1000
0011 0001 0100 1001 0101
=0101 =1010 =1001 =10000 =1101
=0101 =1010 =1010 + 0110
= =0000 =1101
Question 4:
i)
a)
The provided number = 0010 1010
As, C = 1 hence the decimal equivalent of 0000 0001 0010 1010 will be 298
b)
The number given is 1100 1001
As, C = 0 hence the decimal equivalent of 1100 1001 will be 201
c)
The number given is 1011 1100
As, C = 1 hence the decimal equivalent of 0000 0001 1011 1100 will be 444
d)
The number given is 0110 1011
As, C = 0 hence the decimal equivalent of 0110 1011 will be 107
Document Page
9COMPUTER FUNDAMENTALS
e)
The number given is 0111 0011
As, C = 1 hence the decimal equivalent of 0000 0001 0111 0011 will be 371
ii)
a)
The number given is 0010 1010
As, N= 0, V = 0 hence the decimal equivalent of 0010 1010 will be 42
b)
The number given is 1100 1001
As, N = 1 and V= 0 hence the decimal equivalent of 0011 0110 + 1 = 00110111 = -55
c)
The number given is 1011 1100
As, N = 1 and V = 0 hence the decimal equivalent of 0100 0011 + 1 = -68
d)
The number given is 0110 1011
As, N = 0, V = 0 hence the decimal equivalent of 0110 1011 = 107
e)
The number given is 0111 0011
As, N = 0, V = 1 hence the decimal equivalent of 1000 1100 + 1 = 10001101 = -141
Question 5:
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
10COMPUTER FUNDAMENTALS
Sequence position = (row number -1)*(number of columns) + column number
Row number = CLG(sequence position / number of columns)
Column number = MOD(sequence position -1, number of columns) +1
So, by using these formulas the table below is filled up.
Number of
columns in
array
Row number Column number Sequence
position
(i) 14 5 11 (5-1)*14 +11 =
67
(ii) 36 1 27 (1-1)*36 + 27 =
27
(iii) 9 4 8 (4-1)*9 + 8 =
35
(iv) 28 17 11 (17-1)*28 + 11
= 459
(v) 30 CLG(98/30) = 4 MOD(98-
1,30)+1 = 8
98
(vi) 45 CLG(300,45) =
7
MOD(300-
1,45)+1 = 30
300
(vii) 24 CLG(85,24) = 4 MOD(85-
1,24)+1 = 13
85
Document Page
11COMPUTER FUNDAMENTALS
chevron_up_icon
1 out of 12
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]