Question
The function should have the side effect of reversing the order of the bits in the n contiguous bytes, seen as a bitstring of length
The function should have the side effect of reversing the order of the bits in the n contiguous bytes, seen as a bitstring of length 8n. For example, the first bit of the first char should be swapped with last bit of the last char. [6 marks] (c) You have been assigned the following seemingly working C code, which processes files controlling the behaviour of a system. You observe that, after obtaining several ERR_MALFORMED errors, subsequent calls to fopen fail due to too many files being open: int process_file(char *name) { FILE *p = fopen(name, "r"); if (p == NULL) return ERR_NOTFOUND; while (...) { ... if (...) return ERR_MALFORMED; process_one_option(); ... } fclose(p); return SUCCESS; } (i) Explain how to fix the program using facilities in C. [2 marks] (ii) Now suppose the function above was part of a system written in C++ (but still using the C file-processing commands such as fopen and fclose), and that process_one_option() might raise one or more exceptions. Using a class with a destructor, show how to fix the "too many files open" bug above.
(a) Consider two ethical principles of your choice. What is the best justification of these principles? Consider some reasonable alternative justification of these principles. Why is your justification better? (Remember, if you think your justification is the best, then you must have some reason for thinking so!) [6 marks] (b) Give four characteristics that distinguish a professional body from other social organisations. [4 marks] (c) The Computer Misuse Act was passed in 1990. What shortcomings of the law at the time led to this new Act? How was this Act amended by the Police and Justice Bill of 2006, and why were these amendments introduced? Which aspect of the Police and Justice Bill raises problems for Security professionals who test for security vulnerabilities in computing systems, and why? [4 marks] (d) The Seventh and Eighth Principles of the Data Protection Act concern data security. The Seventh concerns security within the borders of the UK, the Eighth concerns security outside the borders of the UK. State two of the requirements of the Seventh Principle and one of the Eighth Principle. [3 marks] (e) Offer the best argument you can either for the institution of proprietary software, or for the institution of free (as in free speech) software. [3 marks] 8 CST.2010.2.9 8 Probability (a) A coin that comes up "heads" with probability p is tossed n times independently. (i) What is the likelihood that k of these n tosses will be "heads", and the remainder "tails"? [2 marks] (ii) Give the mean and the variance expected for the number of "heads" outcomes. [1 mark each] (b) In a different experiment with this same coin, you monitor how many tosses are needed before getting the first outcome of a "head". (i) What is the likelihood that the first "head" occurs on the k th trial? [2 marks] (ii) What is the mean trial number k for the first "head", and what is the variance for this number? [1 mark each] (c) In a Poisson process with hazard parameter : (i) What is the likelihood of observing k events? [2 marks] (ii) What is the mean, and what is the variance, expected for the number of observed events? [1 mark each] (d) If X and Y are random variables having expectations E(X) and E(Y ) respectively: (i) What is their covariance Cov(X, Y )? [2 marks] (ii) In terms of their covariance Cov(X, Y ), and their respective variances V ar(X) and V ar(Y ), what is their correlation coefficient (X, Y )? [2 marks] (e) For a continuous random variable X that is exponentially distributed, having density function f(x) = exp(x) for x > 0 and f(x) = 0 for x 0: (i) Derive the expectation E(X) of this random variable. [2 marks] (ii) Derive its variance V ar(X). [2 marks] 9 (TURN OVER) CST.2010.2.10 9 Regular Languages and Finite Automata (a) Let M be a finite automaton and let M0 be obtained from M by interchanging the collections of accepting and non-accepting states. (i) What does it mean for M to be deterministic? [2 marks] (ii) If M is deterministic, explain why the language accepted by M0 is the complement of the language accepted by M. [3 marks] (iii) Give an example, with justification, to show that the property in part (ii) can fail to hold if M is non-deterministic.
(a) Explain in general how the actions that a user takes are related to the user's goals. Your answer should make reference to the function of perception, and to the nature of the cognitive processing that must occur. [8 marks] (b) Describe a class of problems for which it is not possible to formulate goals. Give a specific example of a problem in this class, and with reference to that example, explain how it illustrates two significant attributes of the class. [6 marks] (c) If an interactive system has several alternative models to describe the user's goal, how can Bayes' theorem be used to improve the system usability?
(a) In a particular computer system, numbers are represented using words having a length of 4 bits. (i) What is the range of positive numbers that can be represented using unsigned binary numbers? [2 marks] (ii) Explain how the 2's complement representation can be used to describe signed binary numbers, using 4-bit words as an example. [3 marks] (iii) Using decimal (base 10) representation for the answers, perform the following 2's complement 4-bit additions, noting any problems: 0110 + 1101 1010 + 1011 [4 marks]
(c) Show how 4 single-bit full-adders can be combined to implement a 4-bit ripple carry-adder. [2 marks] (d) Briefly describe how the speed of operation of the approach in part (c) could be improved. [4 marks] (e) Show how COUT in part (b) can be implemented using only NAND gates.
: Write program that first gets a list of six integers from input. The first five values are the integer list. The last value is the upper threshold. Then output all integers less than or equal to the threshold value.
Write function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Assume that the list will always contain less than 20 integers.
(a) With the aid of appropriate diagrams, briefly explain the operation of Moore and Mealy finite state machines and highlight their differences. [7 marks] (b) A Boolean output Y is to be set to binary "1" for one clock cycle when the sequence 10010 is detected in a stream of serial digital data. The system is only to respond to non-overlapping sequences. Draw the state diagram for this system.
Talk about the moral and lawful ramifications. [4 marks] (b) Your client chooses to fuse an amplifier so the robot can likewise perceive spoken orders. To save battery duration, the discourse acknowledgment will be done in the server. What impact does this have on the moral and legitimate circumstance? [4 marks] (c) What down to earth counsel would you be able to give your client about moderating the legitimate gambles? [4 marks] (d) Your client currently needs to incorporate a camera with the goal that the robot can perceive signals also. Does this make any further moral or legitimate dangers, and provided that this is true, what may be done about them?
(a) with regards to multithreaded calculations, characterize work and range, and express the work regulation and the range regulation. [3 marks] (b) Prove that the presentation of a covetous scheduler is ideal to inside a variable of 2. (Demonstrating all halfway hypotheses isn't needed assuming you state them accurately.) [4 marks] (c) Version An of a multithreaded calculation requires 500 seconds on a uniprocessor machine and 50 seconds on a 32-processor machine. Form B takes something very similar time as An on a solitary processor yet just 24 seconds on the 32-processor machine. (I) Define the parallelism of a calculation and register the parallelism of calculations An and B. Which of the two has higher parallelism, and by how much? (Hint: utilize one of the covetous scheduler hypotheses to determine an estimation for one of the questions.) [6 marks] (ii) Estimate the running seasons of calculations An and B on a 4-processor and on a 1024-processor machine, clarifying how you acquire them. [3 marks] (iii) Sketch conceivable calculation DAGs for calculations An and B and use them to talk about the outcomes got. As the quantity of processors in the host machine changes, is An or B quicker?
. (I) On its own for decipherability, draw the littlest vEB tree putting away keys 0, 3, 6, 7. The rightness of the construction and the precision of all fields of all hubs are significant. Once done, compose every one of the keys under the bunch in which it is intelligently put away. [8 marks] (ii) vEB trees store the base and greatest key of a subtree in the root hub, yet don't store the base key in any of the descendent bunches. Clarify every one of the justifications for why this gives an exhibition advantage contrasted and proto-vEB trees. [4 marks] (b) Consider proto-vEB trees. The accompanying pseudocode endeavors to execute a technique to erase a key from a proto-vEB hub. Give a reasonable clarification of the procedure that it utilizes. Fix any bugs that it might contain. Give more significant identifiers for the factors c and s. Give proper remarks for the four positions stamped "Remark HERE". Clarify why the technique returns a worth and what the worth means. [8 marks] 0 boolean delete(self, key) 1 # HEADER COMMENT HERE (1) 2 if self.u == 2: 3 if self.A[key] == 0 4 # COMMENT HERE (2) 5 get back False 6 else: 7 c = self.cluster[high(key)].delete(low(key)) 8 if c: 9 # COMMENT HERE (3) 10 s = self.summary.delete(high(key)) 11 # COMMENT HERE (4) 12 bring s back 13 else: 14 get back
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started