Briefly explain what undefined behaviour is in the C standard. Under what circumstance(s) would calling the following
Fantastic news! We've Found the answer you've been seeking!
Question:
Briefly explain what undefined behaviour is in the C standard. Under what circumstance(s) would calling the following C function result in undefined behaviour? int32_t divide(int32_t a, int32_t b) { return a / b; } [4 marks] 2 CST.2015.2.2 4 Programming in C and C++ (a.ii) Consider unspecified behaviour in C. (i) Define what unspecified behaviour means in the C standard and give two examples of such behaviour. [3 marks] (ii) Briefly explain why it is important to have unspecified behaviour in the definition of the C language. [1 mark] (b.ii) Compare and contrast the struct and union keywords in C, supplying an example of a situation where it would be more appropriate to use a union rather than a struct. [4 marks] Question: What is a principal type scheme? Give the principal type scheme for N1, or explain informally why it does not have one. The owner (patient) may read from its own EHR. A qualified and employed doctor may read and write the EHR of a patient registered with him/her. (iv.a) Object: The solution to online coursework. Policy: The coursework setter has read and access. A candidate has no access until after the marks have been published. [9 marks each] 4 CST.2003.14.6 5 Computer Graphics and Image Processing (a.a) Explain why display devices appear to be able to reproduce (almost) all the colours of the spectrum using only red, green and blue light. [5 marks] (b.a) Describe an algorithm (other than thresholding) which will convert a greyscale image (6 bits per pixel) to a bi-level black and white image (1 bit per pixel), with the same number of pixels, while retaining as much detail as possible. [8 marks] (c.a) Explain what specular and diffuse reflection are in the real world. State and explain equations for calculating approximations to both in a computer. [8 marks] 5 [TURN OVER CST.2005.24.7 6 Compiler Construction (a.i) Explain the differences (illustrating each with a small program) between (i.i) static and dynamic binding (scoping); [4 marks] (ii.i) static and dynamic typing. [2 marks] (b.i) Java is sometimes said to be "dynamically typed" in that a variable whose type is (class) C can be assigned a value of (class) D provided that D extends C; conversely a variable of type D can be assigned a value of type C using a cast. By considering storage layouts, explain why the former assignment is always valid and the latter sometimes invalid. [4 marks] (c.i) A new programming language has the notion of "statically scoped exceptions" in which the program exception foo; void f() { try { void g() { raise foo; } try { g(); } except (foo) { C2 } } except (foo) { C1 } } would execute C1 rather than C2 as the former was in scope at the raise point. By analogy with statically scoped variables, or otherwise, explain how such exceptions might be implemented on a stack. [10 marks] 6 CST.2005.23.6 8 Artificial Intelligence In the following, N is a feedforward neural n Structures and Algorithms (a.ii) Describe how the Lempel Ziv text compression algorithm works, illustrating your answer by deriving the sequence of numbers and corresponding bit patterns it would generate when applied to a string starting with the following 25 characters:AAA... You may assume that the initial table is of size 345 (containing bytes 0 to 255) and that the codes for "A", "B", "C" and "D" are 12, 13, 14 and 10, respectively. [10 marks] You are expected to plan a geography revelation convention for an organization of exchanging hubs interconnected by joins. There are n hubs, l connections, the greatest level of any hub is k and there is a way between any two hubs of not more than d bounces. All connections are bi-directional. Every hub has a remarkable identifier of four bytes which it knows. II.i Look at the general benefits of the two calculations. It depending on the shape and structure of A: tall, square, symmetric. Give one example of a unique names axiom and one example of a unique actions axiom that might appear in Evil Robot's knowledge base for this problem. [5 marks] (b) Suppose that the target virtual machine is stack-oriented and that the stack elements are integer values, and addresses can be stored as integers. Explain which other features are required in such a virtual machine. Invent a simple language of instructions for such a machine and show how it would be used to implement each of the expressions. [10 marks]
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: