fsentence) justification of why it holds, a counterexample or other…
Question Answered step-by-step fsentence) justification of why it holds, a counterexample or other… fsentence) justification of why it holds, a counterexample or other explanation of why it fails, or corrected statement. (a) In a language with stack-allocated free variables, the static chain pointer always points to the caller’s stack frame. (b) If each procedure sets up one exception handler whose scope includes all of the procedure calls it makes, then the entries in the exception handler stack and those in the dynamic chain will be in 1-1 correspondence. (c) Fortran gives semantic meaning to parentheses, i.e. a+b+c permits compiler re-arrangement whereas (a+b)+c does not. This matters for floating point. However, since Fortran ‘+’ is left associative the above two expressions yield the same parse tree, and we have a contradiction. (d) Two alternatives to conservative garbage collection are liberal garbage collection or new labour style de-allocation. (e) Any type 3 (regular) grammar is also a type 2 (context-free) grammar. Hence any lexer generated by lex (or JLex) could instead be generated by yacc (or Cup). (f ) When a compiler for a language like Java compiles e1+e2, it computes the types of e1 and e2 so that it can treat it as e1+(float)e2 if e1 is of type float and e2 is of type int. (g) A syntax-tree interpreter can fail (give an error) when evaluating a variable name which does not appear in the current environment. Any program which fails using static scoping will fail using dynamic scoping. (h) A syntax-tree interpreter can fail (give an error) when evaluating a variable name which does not appear in the current environment. Any program which fails using dynamic scoping will fail using static scoping. (i) A dynamically-typed language is one in which the type of a value is carried around at run-time; a type error is given at run-time if values are used inappropriately. Such languages must be dynamically linked otherwise type errors will occur. (j) Java .class files and ELF-style .o (or .obj) object files represent similar information, i.e. compiled code, a list of symbols made available to other functions, and a list of undefined symbols which the file expects to be defined elsewhere. [2 marks each] 6ollowing statements may be true, false, or nonsensical. Indicate which and (respectively) provide a (one- CST.2003.6.7 7 Artificial Intelligence I A simple game works as follows. We have a board divided into n by m square cells. We also have an unlimited number of L-shaped tiles, each made to cover exactly three squares. The tiles can appear in any of the four possible orientations. Our aim is to cover the board completely with non-overlapping tiles. (a) A single tile on the board can be described using a list such as [[1,1],[1,2],[2,1]] containing three tuples, specifying the position of each part of the tile on the board. Consider the following Prolog predicate, which is true if the six variables describe a correct, L-shaped tile. tile([[A,B],[C,D],[E,F]]) :- C is A+1, D is B, E is A, F is B-1; C is A+1, D is B, E is A, F is B+1; C is A-1, D is B, E is A, F is B+1; C is A-1, D is B, E is A, F is B-1. Explain what happens in response to a query of the form tile([[4,5],[B,C],[D,E]]). Keep in mind the effects of backtracking. [2 marks] (b) Write a Prolog predicate goodplace([[A,B],[C,D],[E,F]],[N,M]) that is true if [[A,B],[C,D],[E,F]] is a validly shaped tile and all of its parts lie within an N by M board. Your predicate should behave under backtracking in such a way that the response to a query of the form goodplace([[10,4],[B,C],[D,E]],[10,10]). is to find the unspecified values for all tiles which have a valid shape and fall within the board. In this example there would be two such tiles. [6 marks] (c) Write a Prolog predicate tiling(Available,Solution,Size). Here, Size is the size of the board represented as above, Solution is a list of tiles that solves the .rkImage transcription textThe Discrete Delta (Impulse) and Unit Step Functions In the lecture we have discussed the continuous delta(impulse function) as well as the continuous Unit Step functions and their relation. Try using the analogy (andsearching the book and/or internet) to find out the definition of the delta function and the unit ste… Show more… Show more Engineering & Technology Computer Science COMP CCISO Share QuestionEmailCopy link Comments (0)


