Question: SECTION C 9 Semantics of Programming wLanguages (a) The…
Question Answered step-by-step Question: SECTION C 9 Semantics of Programming wLanguages (a) The… Question:SECTION C9 Semantics of Programming wLanguages(a) The integer expressions E of a programming language are given byE ::= n | X | ?E | E + Ewhere n ranges over integer constants and X ranges over identifiers. Explainthe principle of structural induction for proving that some property ?(E) holdsfor all integer expressions E. [5 marks](b) Taking states to be finite partial functions mapping identifiers to integerconstants, define a relationE, s ? ngiving 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 bothhold, 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 ? nholds? ) 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 thefollowing 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 inpolynomial time? Why? [2 marks](iii) For which values of k is the problem k-colourability NP-complete? Givea brief indication how this might be proved. [2 marks](c) The company Fon-X runs a mobile ‘phone service. It has 2000 ‘phone mastsstationed across the country. The frequency spectrum assigned to the companyis split into 20 bands. Each mast is to be assigned a frequency band in such away that masts within 50 miles of each other do not share the same frequencyband.(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 tryingto solve? [3 marks](d) Fon-X solved its frequency assignment problem by an exhaustive searchalgorithm, which took a week to run. The company has just doubled in sizethrough a merger. It intends to repeat the frequency assignment on 4000masts, setting aside two weeks for the task. As a consultant, write a shortnote to the company explaining what you think of the idea, and suggestingany alternatives you think might be better.Question:Both institutions use relational databases. Write brief notes to alert thedatabase administrators to the difficulties that they may encounter. [8 marks]SECTION C9 Semantics of Programming Languages(a) The integer expressions E of a programming language are given byE ::= n | X | ?E | E + Ewhere n ranges over integer constants and X ranges over identifiers. Explainthe principle of structural induction for proving that some property ?(E) holdsfor all integer expressions E. [5 marks](b) Taking states to be finite partial functions mapping identifiers to integerconstants, define a relationE, s ? ngiving 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 bothhold, 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 ? nholds? ) 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 thefollowing 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 inpolynomial time? Why? [2 marks](iii) For which values of k is the problem k-colourability NP-complete? Givea brief indication how this might be proved. [2 marks](c) The company Fon-X runs a mobile ‘phone service. It has 2000 ‘phone mastsstationed across the country. The frequency spectrum assigned to the companyis split into 20 bands. Each mast is to be assigned a frequency band in such away that masts within 50 miles of each other do not share the same frequencyband.(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 tryingto solve? [3 marks](d) Fon-X solved its frequency assignment problem by an exhaustive searchalgorithm, which took a week to run. The company has just doubled in sizethrough a merger. It intends to repeat the frequency assignment on 4000masts, setting aside two weeks for the task. As a consultant, write a shortnote to the company explaining what you think of the idea, and suggestingany alternatives you think might be better. (a) Write down sim (a) Write down sim Computer Science Engineering & Technology Networking DERECHO 6TO Share QuestionEmailCopy link Comments (0)


