Question: Question: SECTION C 9 Semantics of Programming wLanguages (a) The integer expressions E of a programming language are given by E ::= n | X
Question: SECTION C 9 Semantics of Programming wLanguages (a) The integer expressions E of a programming language are given by E ::= n | X | E | E + E where n ranges over integer constants and X ranges over identifiers. Explain the principle of structural induction for proving that some property (E) holds for all integer expressions E. [5 marks] (b) Taking states to be finite partial functions mapping identifiers to integer constants, define a relation E, s n giving the result n (if any) of evaluating integer expression E in state s. [7 marks]
(c) Use structural induction to prove that if E, s n1 and E, s n2 both hold, then n1 = n2. [Hint: Consider the property (E) given by s, n1, n2((E, s n1) & (E, s n2) n1 = n2).] [7 marks] (d) What property of the pair E, s ensures that there is some n for which E, s n holds?
) Write java program that takes both n (as input) and n integer inputs and add the given values to a defined array. , write program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number.
Write \ program that asks for a number and then prints as many lines as the user inputs. Each line contains as many pairs of characters ("*#") as the number of this line.
(a) Give precise definition of the complexity class NP and of NP-completeness.
(b) For any natural number k, the problem k-colourability is defined as the following decision problem. Given a graph G = (V, E), is there a mapping : V {c1, . . . , ck} such that if (u, v) E, then (u) 6= (v)? (i) Explain why, for each k, the problem k-colourability is in the class NP. [2 marks] (ii) For what values of k is the problem k-colourability decidable in polynomial time? Why? [2 marks] (iii) For which values of k is the problem k-colourability NP-complete? Give a brief indication how this might be proved. [2 marks] (c) The company Fon-X runs a mobile 'phone service. It has 2000 'phone masts stationed across the country. The frequency spectrum assigned to the company is split into 20 bands. Each mast is to be assigned a frequency band in such a way that masts within 50 miles of each other do not share the same frequency band. (i) What is the relationship between this problem and k-colourability? [2 marks] (ii) What can you say about the complexity of the problem Fon-X is trying to solve? [3 marks] (d) Fon-X solved its frequency assignment problem by an exhaustive search algorithm, which took a week to run. The company has just doubled in size through a merger. It intends to repeat the frequency assignment on 4000 masts, setting aside two weeks for the task. As a consultant, write a short note to the company explaining what you think of the idea, and suggesting any alternatives you think might be better.
Question:
Both institutions use relational databases. Write brief notes to alert the database administrators to the difficulties that they may encounter. [8 marks] SECTION C 9 Semantics of Programming Languages (a) The integer expressions E of a programming language are given by E ::= n | X | E | E + E where n ranges over integer constants and X ranges over identifiers. Explain the principle of structural induction for proving that some property (E) holds for all integer expressions E. [5 marks] (b) Taking states to be finite partial functions mapping identifiers to integer constants, define a relation E, s n giving the result n (if any) of evaluating integer expression E in state s. [7 marks]
(c) Use structural induction to prove that if E, s n1 and E, s n2 both hold, then n1 = n2. [Hint: Consider the property (E) given by s, n1, n2((E, s n1) & (E, s n2) n1 = n2).] [7 marks] (d) What property of the pair E, s ensures that there is some n for which E, s n holds?
) Write java program that takes both n (as input) and n integer inputs and add the given values to a defined array. , write program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number.
Write \ program that asks for a number and then prints as many lines as the user inputs. Each line contains as many pairs of characters ("*#") as the number of this line.
(a) Give precise definition of the complexity class NP and of NP-completeness.
(b) For any natural number k, the problem k-colourability is defined as the following decision problem. Given a graph G = (V, E), is there a mapping : V {c1, . . . , ck} such that if (u, v) E, then (u) 6= (v)? (i) Explain why, for each k, the problem k-colourability is in the class NP. [2 marks] (ii) For what values of k is the problem k-colourability decidable in polynomial time? Why? [2 marks] (iii) For which values of k is the problem k-colourability NP-complete? Give a brief indication how this might be proved. [2 marks] (c) The company Fon-X runs a mobile 'phone service. It has 2000 'phone masts stationed across the country. The frequency spectrum assigned to the company is split into 20 bands. Each mast is to be assigned a frequency band in such a way that masts within 50 miles of each other do not share the same frequency band. (i) What is the relationship between this problem and k-colourability? [2 marks] (ii) What can you say about the complexity of the problem Fon-X is trying to solve? [3 marks] (d) Fon-X solved its frequency assignment problem by an exhaustive search algorithm, which took a week to run. The company has just doubled in size through a merger. It intends to repeat the frequency assignment on 4000 masts, setting aside two weeks for the task. As a consultant, write a short note to the company explaining what you think of the idea, and suggesting any alternatives you think might be better.
(a) Write down sim
(a) Write down sim
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
