The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hello, I need all answer of this computer science questions.
Â
Thank you.ENS1161D_A2_v27_ECC_1_2017.doc School of Engineering ©ECU 3/02/2017 ENS1161 Computer Fundamentals ASSIGNMENT 2 Trimester 1, 2017 Topics covered: Relations, Functions, Bases and Number Systems, Computer representation of numbers, BCD addition and ASCII codes. Source material: Lectures 5 to 8 and tutorial exercise sheets are available on Moodle. Marks: 15% of total marks for the unit. The assignment will be marked out of 40 and scaled to a mark out of 15. Due date: Week 10 of semester (see Moodle or lecturer for details). A penalty for late submissions will apply as specified in the handbook. Submission instructions: Please ensure that you submit your assignment in the correct box. (No responsibility will be taken for assignments submitted incorrectly) If you are unsure, check with your lecturer or tutor. Applications for extension: Applications for extension (on medical or other grounds) should be made in writing to the unit coordinator before the due date, and should be accompanied by appropriate evidence (e.g. medical certificate) to support your application. Presentation: You may use a computer package to prepare your submission, but it is not essential. In some cases it may be preferable to put in diagrams and symbolic expressions by hand if you are not competent to produce an acceptable result using a computer package. You should use one side of each sheet only. Plastic covers are not required; in fact they usually complicate the processing of submissions. ENS1161D_A2_v27_ECC_1_2017.doc Page 2 of 8 Question 1 Consider the functions f, g and h, all defined on the set {0, 1, 2, 3, …, 12} x 0 1 2 3 4 5 6 7 8 9 10 11 12 f(x) 0 5 10 4 3 1 12 7 11 9 2 8 6 x 0 1 2 3 4 5 6 7 8 9 10 11 12 g(x) 5 4 11 0 6 10 2 7 1 12 9 8 3 x 0 1 2 3 4 5 6 7 8 9 10 11 12 h(x) 3 6 0 10 9 5 2 12 1 7 11 4 8 (i) Write down the values of: g(f(h(7))) and h–1 (g–1 (3)) (ii) Construct a table of values (like those shown above) for h(g–1 (x)). (iii) Construct a table for f(f(x)). What can you conclude about the inverse of f? (iv) Construct a table for h–1 (x), and draw its graph on the grid provided on the last page. [5 marks] Question 2 Suppose there is a set of growers G = {a, b, c, d}, a set of retailers R = {e, f, g} and a set of customers C = {m, n, p, q, r}. There are two relations A and B on G  R and R  C, respectively, defined by: aAf, bAe, bAg, cAg, dAf, and eBn, fBp, fBq, gBm, gBr xAy means "grower x sold goods to retailer y", and yA–1 x means "retailer y bought goods from grower x" xBy means "retailer x sold goods to customer y", and yB–1 x means "customer y bought goods from retailer x" (i) Find the matrices M(A) and M(B) that represent the relations A and B. (ii) Find the matrices M(A)T and M(B)T that represent the relations A–1 and B–1 (iii) Consider the query: Which customers have received goods that came from the same grower(s) as those goods received by customer p? Find the logical matrix products M(A) M(B) and then M(B)T M(A)T , and finally M(B)T M(A)T M(A) M(B), and hence answer the query. [ Hint: To see a similar exercise, look at the "Application" on page 13 of Lecture 5.] [1 + 1 + 3 = 5 marks] ENS1161D_A2_v27_ECC_1_2017.doc Page 3 of 8 Question 3 (a) Consider the following table: (i) Convert each of the decimal numbers in the first column to octal. (ii) Convert the two octal numbers to binary. (iii) Convert the two binary numbers to hexadecimal. (iv) Add the two hexadecimal numbers. (v) Convert the hexadecimal sum to binary, then to octal and then to decimal. (Give your answers in a table like that above.) (b) (i) Convert the decimal fraction 0.53125 to binary; (ii) Convert the decimal fraction 0.09375 to binary; (iii) Add the two binary fractions from (i) and (ii); (iv) Convert the binary fraction from (iii) to decimal. (Show your working) (c) Add the following, given that (i) is binary, (ii) is octal and (iii) is hexadecimal: (i) 1101011 (ii) 2756 (iii) 2AE5C 1001111 + 5724 + B52F7 + (d) Perform "BCD additions" on the following pairs of hexadecimal numbers. (Show all your working) (i) 29578 (ii) 138526 31495 + 490615 + [5 + 2 + 3 + 2 = 12 marks] Question 4 For each of the following, suppose that two 8-bit binary numbers have been added. In each case the 8-bit output is given and the values of the N, V and C flags. For each case give the correct answer as a decimal number: (a) if the result is interpreted as the sum of unsigned integers; (b) if the result is interpreted as the sum of signed integers. [10  1 = 10 marks] decimal octal binary hexadecimal 119 96 8-bit output N V C (i) 0011 0011 0 0 1 (ii) 0101 0000 0 1 1 (iii) 1011 1101 1 0 0 (iv) 1010 1110 1 0 1 (v) 1011 0110 1 1 0 ENS1161D_A2_v27_ECC_1_2017.doc Page 4 of 8 Question 5 Introduction – Part 1: Two functions This question uses two types of function that you may not have met before, the CEILING function CLG(x) and the MOD function MOD(x, n). Definition of the CEILING function: CLG(x) is the smallest integer that is greater than or equal to x. Or, if you prefer, it is the smallest integer that is not smaller than x. eg. CLG(4.3) = ? Which integers are not smaller than 4.3? Answer: 5, 6, 7, …, etc Of these, which is the smallest? Answer: 5 So CLG(4.3) = 5 eg. CLG(7.5) = ? Which integers are not smaller than 7.5? Answer: 8, 9, 10, …, etc Of these, which is the smallest? Answer: 8 So CLG(7.5) = 8 eg. CLG(6) = ? Which integers are not smaller than 6? Answer: 6, 7, 8, …, etc Of these, which is the smallest? Answer: 6 So CLG(6) = 6 Practice exercises: (i) CLG(3.8) = ………….. (ii) CLG(12.6) = …………… (iii) CLG(11) = ………….. (iv) CLG(13.7) = …………… (v) CLG(5) = ………….. (vi) CLG(6.9) = …………… (vii) CLG(5.7) = ………….. (viii) CLG(15.6) = …………… Answers: (i) 4; (ii) 13; (iii) 11; (iv) 14; (v) 5; (vi) 7; (vii) 6; (viii) 15 ENS1161D_A2_v27_ECC_1_2017.doc Page 5 of 8 Definition of the MOD function: MOD(x, n) is the remainder when x is divided by the whole number n. eg. MOD(38, 5) = ? When 38 is divided by 5, what is the remainder? Answer: 3 So, MOD(38, 5) = 3 eg. MOD(29, 8) = ? When 29 is divided by 8, what is the remainder? Answer: 5 So, MOD(29, 8) = 5 eg. MOD(13, 4) = ? When 13 is divided by 4, what is the remainder? Answer: 1 So, MOD(13, 4) = 1 eg. MOD(6, 10) = ? When 6 is divided by 10, what is the remainder? Answer: 6 So, MOD(6, 10) = 6 eg. MOD(47, 12) = ? When 47 is divided by 12, what is the remainder? Answer: 11 So, MOD(47, 12) = 11 Practice exercises: (i) MOD(17, 5) = ………….. (ii) MOD(75, 12) = …………… (iii) MOD(36, 9) = ………….. (iv) MOD(45, 10) = …………… (v) MOD(3, 8) = ………….. (vi) MOD(29, 6) = …………… (vii) MOD(24, 4) = ………….. (viii) MOD(55, 7) = …………… (ix) MOD(21, 5) = ………….. (x) MOD(5, 7) = …………… Answers: (i) 2; (ii) 3; (iii) 0; (iv) 5; (v) 3; (vi) 5; (vii) 0; (viii) 6; (ix) 1; (x) 5 ENS1161D_A2_v27_ECC_1_2017.doc Page 6 of 8 Introduction – Part 2: Application to Computer Science Computer scientists often use matrices or rectangular arrays of numbers. Although they may appear on a computer monitor as a rectangular array, they are usually stored in memory locations as linear sequences of numbers. As a very simple case, suppose we have an array with 5 columns, such as: and we want to store the array in a linear sequence starting with the first row, then the second and so on. So the sequence of stored values would begin: 18 12 5 16 13 6 7 21 20 11 22 10 4 8 16 2 19 11 … etc There are two important types of questions concerning the storage and retrieval of such a set of numbers: Type A: Given the row number and column number of an element in the array, how to determine its position in the linear sequence? Type B: Given the position of an element in the linear sequence, how to determine its row number and column number in the array? There are formulae that can be used to answer such questions, and they make use of the CEILING and MOD functions. They also use the variables: num_cols –– the number of columns in the array row_num –– the row number of the element col_num –– the column number of the element seq_pos –– the position of the element in the linear sequence Here are the formulae that provide the answers: seq_pos = (row_num – 1)  num_cols + col_num (answer to Type A) row_num = CLG(seq_pos / num_cols) (answers to Type B) col_num = MOD(seq_pos – 1, num_cols) + 1 For example, consider the element in the 3rd row and 4th column of the array given above (which happens to be an 8). Notice also that the array has 5 columns. The Type A question is: Given that the element is in the 3 rd row and 4th column, what is its position in the linear sequence? 18 12 5 16 13 6 7 21 20 11 22 10 4 8 16 2 19 11 21 12 9 1 19 10 5 14 9 17 11 19 4 3 21 9 10 ENS1161D_A2_v27_ECC_1_2017.doc Page 7 of 8 Answer: seq_pos = (row_num – 1)  num_cols + col_num = (3 – 1)  5 + 4 = 14 So the element is the 14th in the linear sequence (which is obviously true.) The Type B question is: Given that the element is in the 14th position in the linear sequence, what are its row and column numbers in the array? Answer: row_num = CLG(seq_pos / num_cols) = CLG( 14 / 5 ) = CLG(2.8) = 3 col_num = MOD(seq_pos – 1, num_cols) + 1 = MOD(14 – 1, 5) + 1 = MOD(13, 5) + 1 = 3 + 1 = 4 So the element is in the 3rd row and 4th column. Practice examples: Fill in the blanks in the table Number of columns in array Row number Column number Sequence position (i) 8 5 3 (ii) 12 6 2 (iii) 15 50 (iv) 30 200 Answers: (i) 35; (ii) 62; (iii) 4, 5; (iv) 7, 20 Your task for Question 5 First work through the above examples in detail to make sure that you understand the process. Then calculate the missing entries for the seven exercises in the table below. (Give your answers in a table like the one below.) Number of columns in array Row number Column number Sequence position (i) 16 7 9 (ii) 35 1 25 (iii) 12 5 5 (iv) 25 13 17 (v) 20 53 (vi) 40 324 (vii) 22 117 [8 marks] ENS1161D_A2_v27_ECC_1_2017.doc Page 8 of 8 Grid for graph in Question 1 0 2 4 6 8 10 12 2 4 6 8 10 12 0 x h –1 (x)
Attachments:
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly