he first parameter is a pointer to memory containing n contiguous…

Question Answered step-by-step he first parameter is a pointer to memory containing n contiguous… he first parameter is a pointer to memory containing n contiguous bytes (eachof type char), and the second is the number of bytes. The function should havethe side effect of reversing the order of the bits in the n contiguous bytes, seenas a bitstring of length 8n. For example, the first bit of the first char should beswapped with last bit of the last char. [6 marks](c) You have been assigned the following seemingly working C code, which processesfiles controlling the behaviour of a system. You observe that, after obtainingseveral ERR_MALFORMED errors, subsequent calls to fopen fail due to too manyfiles 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++ (butstill using the C file-processing commands such as fopen and fclose), andthat process_one_option() might raise one or more exceptions. Usinga class with a destructor, show how to fix the “too many files open” bugabove. (a) Consider two ethical principles of your choice. What is the best justificationof these principles? Consider some reasonable alternative justification of theseprinciples. Why is your justification better? (Remember, if you think yourjustification 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 socialorganisations. [4 marks](c) The Computer Misuse Act was passed in 1990. What shortcomings of the lawat the time led to this new Act? How was this Act amended by the Policeand Justice Bill of 2006, and why were these amendments introduced? Whichaspect of the Police and Justice Bill raises problems for Security professionalswho test for security vulnerabilities in computing systems, and why?[4 marks](d) The Seventh and Eighth Principles of the Data Protection Act concern datasecurity. The Seventh concerns security within the borders of the UK, theEighth concerns security outside the borders of the UK. State two of therequirements of the Seventh Principle and one of the Eighth Principle.[3 marks](e) Offer the best argument you can either for the institution of proprietarysoftware, or for the institution of free (as in free speech) software. [3 marks]8CST.2010.2.98 Probability(a) A coin that comes up “heads” with probability p is tossed n timesindependently.(i) What is the likelihood that k of these n tosses will be “heads”, and theremainder “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 tossesare needed before getting the first outcome of a “head”.(i) What is the likelihood that the first “head” occurs on the kth trial?[2 marks](ii) What is the mean trial number k for the first “head”, and what is thevariance 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 ofobserved 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 variancesV 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, havingdensity 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.109 Regular Languages and Finite Automata(a) Let M be a finite automaton and let M0be obtained from M by interchangingthe 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 M0is thecomplement 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’sgoals. Your answer should make reference to the function of perception, and tothe 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. Givea 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’sgoal, how can Bayes’ theorem be used to improve the system usability? (a) In a particular computer system, numbers are represented using words havinga length of 4 bits.(i) What is the range of positive numbers that can be represented usingunsigned binary numbers? [2 marks](ii) Explain how the 2’s complement representation can be used to describesigned binary numbers, using 4-bit words as an example. [3 marks](iii) Using decimal (base 10) representation for the answers, perform thefollowing 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 ripplecarry-adder. [2 marks](d) Briefly describe how the speed of operation of the approach in part (c) couldbe 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 Mooreand 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 thesequence 10010 is detected in a stream of serial digital data. The system isonly to respond to non-overlapping sequences. Draw the state diagram for thissystem. ANSWER ALL QUESTIONS Computer Science Engineering & Technology Object-Oriented Programming DSD 22 Share QuestionEmailCopy link Comments (0)