The simple task of testing whether two lists are equal can be…

Question Answered step-by-step The simple task of testing whether two lists are equal can be… The simple task of testing whether two lists are equal can be generalised to allowa certain number of errors. We consider three forms of error:• element mismatch, as in [1,2,3] versus [1,9,3] or [1,2,3] versus [0,2,3]• left deletion, as in [1,3] versus [1,2,3] or [1,2] versus [1,2,3]• right deletion, as in [1,2,3] versus [1,3] or [1,2,3] versus [1,2]Write  a function genEquals n xs ys that returns true if the two lists xs andys are equal with no more than n errors, and otherwise false. You may assumethat n is a non-negative integer. [8 marks]All ML code must be explained clearly and should be free of needless complexity.3 (TURN OVER)CST.2014.1.4SECTION B3Object-Oriented Programming(a) (i) Explain the purpose of access modififiers in OOP languages. [2 marks](ii) Copy and complete the table below to show the access restrictions for thefour access modififiers in Java. [2 marks]Access ModififierDefifining classClass in same packageSubclass in difffferent packageNon-subclass in difffferent package(b) A Java game designer wishes to store all the game preferences (e.g., player name,screen size, music volume, etc.) within a custom Preference class.(i) Assuming each preference is stored as a unique String key mapping toa String value, give a simple implementation of Preference that allowsfor effiffifficiently setting or updating preferences and retrieving previously setones. Your implementation should defifine an exception that is thrown whena preference key is requested but not present. [5 marks](ii) It is important that only one Preference object exists in a running game.Show how to apply access modififiers and the Singleton design pattern toensure this. Your implementation should lazily instantiate the object. Is itnecessary to make your class final or Cloneable? Explain your answer.[6 marks](c) The designer also implements other Singleton classes in the game and proposesto create a SingletonBase base class from which all such classes would inheritthe singleton behaviour. By providing example Java code, explain why this isnot viable. [5 marks]4CST.2014.1.54Object-Oriented ProgrammingA Lecturer wishes to create a program that lists his students sorted by the numberof practical assignments they have completed. The listing should be greatest numberof assignments fifirst, sub-sorted by name in lexicographical order (A to Z).A class StudentInfo stores the name and number of assignments completed for astudent. Amongst other methods, it contains a void setCompleted(int n) methodthat allows changes to the number of completed assignments.(a) Provide a defifinition of StudentInfo with an equals() method and a naturalordering that matches the given requirement. [9 marks](b) A TreeSet is used to maintain the StudentInfo objects in appropriate order.When setCompleted(…) is called on a StudentInfo object it is necessaryto remove the object from the set, change the value and then reinsert it toensure the correct ordering. This is to be automated by applying the Observerdesign pattern via classes UpdatableTreeSet and SubscribableStudentInfo.A partial defifinition of UpdatableTreeSet is provided below.public class UpdatableTreeSet extendsTreeSet {// To be called just before the StudentInfo object is updatedpublic void beforeUpdate(SubscribableStudentInfo s) {remove(s);}// To be called just after the StudentInfo object is updatedpublic void afterUpdate(SubscribableStudentInfo s) {add(s);}}(i) Extend StudentInfo to create SubscribableStudentInfo such that: multiple UpdatableTreeSet objects can subscribe and unsubscribe to receiveupdates from it; and the beforeUpdate(…) and afterUpdate(…)methods are called appropriately on the subscribed UpdatableTreeSetobjects whenever setCompleted(…) is called. [6 marks](ii) Give a complete defifinition of UpdatableTreeSet that overrides the inherited methods boolean add(SubscribableStudentInfo) and booleanremove(Object) to automatically subscribe and unsubscribe to theirarguments, as appropriate. You may ignore all other methods inheritedfrom TreeSet. [5 marks]    Image transcription textExercise 7 15 points Let A, B bedecidable languages. Give a high-leveldescription of a Turing m… Show more… Show more    Image transcription text(6 points) Assume we are using asimple model for floating-pointrepresentation similar to t… Show more… Show more  Computer Science Engineering & Technology Information Security COMPUTER S 1102 Share QuestionEmailCopy link Comments (0)