(a) State one potential advantage of programming languages that do…
Question Answered step-by-step (a) State one potential advantage of programming languages that do… (a) State one potential advantage of programming languages that do not have a static type system. [1 mark] (b) Consider the following language syntax: e ::= skip | b | n | if e1 then e2 else e3 | while e1 do e2 | fn x ? e | e1 e2 | x | ref e | e1 := e2 |!e | ` where b ranges over the booleans {true,false}, n ranges over the natural numbers, and ` ranges over an infinite set of locations. Design an operational semantics for this language that is well-defined and reasonable for arbitrary expressions (not just those that would be admitted by some static type system). Your semantics should: 1. involve clearly-specified notions of value v and store s; 2. define a small-step reduction relation he, si ?? he 0 , s 0 i; 3. be call-by-value; and 4. not be stuck for any configuration he, si where e is not a value. Explain any parts of your definition that differ from those in the definition of a conventional typed language, such as the typed languages in the course notes. [15 marks] (c) State property 4 precisely. [1 mark] (d) Give an outline proof of property 4, including the form of induction used and one non-trivial case. [3 marks] Let L be the language with syntax below, a call-by-value left-to-right operational semantics, and the standard simple type system. e ::= n | fn x :T ? e | e1 e2 | x T ::= int | T1 ? T2 n ? Z (a) L is not Turing-complete: there are computable functions over the integers that are not expressible as closed L expressions of type int ? int. Why not? [2 marks] (b) Define a modest extension L0 of L that is Turing-complete. Give the additional syntactic forms (for expressions and types), describe their operational semantics informally, and state their precise typing rules. [10 marks] (c) Assuming that f is an L0 expression of type int ? int, give an expression e of type int that computes the smallest x such that f x is zero. Explain how this can be used to prove completeness. [4 marks] (d) Discuss whether Turing-completeness is a necessary or sufficient property for a good programming language. [4 marks] (a) In a C++ program, suppose there is a function with the following p void foo(MyClass x) Suppose that this function is invoked in a call foo(z). (i) What does C++ do when z is passed as an argument to foo? (ii) Explain briefly in English how the MyClass class can be modified to raise compile-time errors when objects of type MyClass are passed as arguments. (iii) Why might you want to do this? (iv) In response, how should the type of foo be declared instead? Give a new function prototype for foo. [3 marks each] (b) In C, it is typical for APIs to expose functions which create values (such as fopen) and then subsequently delete them (such as fclose). For example, a C program might use files with code like: void bar(void) { FILE *fp = fopen(“example.txt”,”r”); baz(fp); fclose(fp); } (i) What makes this style of resource management problematic in C++? Your answer should explain what baz could do that creates resource-management hazards. [3 marks] (ii) Describe the preferred alternative to handling this kind of resource management issue in modern C++. [2 marks] (iii) Define a C++ class which wraps the C file API to support C++ style resource management. You only need to show how to wrap the resource management calls (fopen and fclose), and may ignore the rest of the file API. [3 marks] a) Write class called Fork with two public methods, pickUp and putDown. The methods should take no arguments and return no result. An instance of Fork should act as a lock to prevent concurrent access. In other words, once pickUp has been called, all further calls to pickUp should block until putDown is called; when putDown is called, one caller (if any) who is blocked should proceed. [7 marks] (b) Write class called Fellow which inherits from the Thread class and implements the abstract method run. The Fellow class should have a single constructor which takes two Fork objects, one representing the fork to the Fellow’s left, and one to the right. When run, an instance of Fellow should think for ten seconds, eat for ten seconds and think for ten seconds before terminating. [7 marks] (c) Describe when and why your implementation may suffer deadlock. [2 marks] (d) By altering the order in which the forks are picked up, describe how you would modify your implementation so that it does not suffer deadlock. [4 marks (a) Add another method Integer maxf(Iterator it) to the class Eval. Your method should return the maximum value computed by f for every Record returned by the iterator or null if there are no records available. The relevant portion of the Iterator interface is as follows: interface Iterator { // return true if there are more values available public boolean hasNext(); // return the available value and advance to the next one public T next(); } [5 marks] (b) Complete the methods run() and join() in the following abstract class. You may add additional fields or methods if you wish. abstract class Joinable implements Runnable { abstract void exec(); final public void run() { // … call the exec() method … } void join() throws InterruptedException { // block the calling thread until exec() completes in run() } } [7 marks] (c) Provide a method Integer parmaxf(Iterator it, int n) which is functionally equivalent to Eval.maxf, except that it should create n parallel threads of execution to speed up the calculation of the result. You may assume that Iterator is thread-safe. You may find it helpful to subclass the Joinable class. [8 marks](a) Provide a non-thread-safe implementation of the interface. Apart from NoSuchElementException you may not use classes from the Standard Library. [8 marks] (b) Provide and explain an example execution trace which demonstrates that your implementation is not thread safe. [6 marks] (c) Define fine- and coarse-grained locking for thread safety. [2 marks] (d) Describe how you would change your implementation to use a coarse-grained locking strategy. Explain why your example execution trace can no longer occur. [2 marks] (e) Would there be any significant performance benefit from using a fine-grained locking strategy? Explain why. [2 marks] Consider the following client program extract: 1 Socket s = new Socket(“localhost”,10000); 2 ObjectInputStream ois = new ObjectInputStream(s.getInputStream()); 3 Object o = ois.readObject(); 4 Class c = o.getClass(); 5 for(Field f : c.getDeclaredFields()) 6 System.out.println(f.get(o)); 7 c.getMethod(“run”).invoke(o); (a) Describe the execution of this extract, assuming that no exceptions are thrown. [5 marks] (b) Identify five distinct exceptions that may occur during execution of the client program extract. Your answers should include the line number at which the exception would be thrown and a brief description of the problem which would cause it. General virtual machine errors such as OutOfMemoryError or StackOverflowError should not be included in your answer. [2 marks each] (c) Write server program extract that is capable of communicating successfully with the client extract shown above. You should assume the existence of an Object variable called sendMe which contains the object to be sent to the client. You do not need to write any error handling code. [5 marks] In java, I need help with a MapReduce program called MovieRatings that will print all the average ratings for a movie based on user feedback. The program should work on MovieLens data set, which can be downloaded from Refernce: http://www.grouplens.org/node/73. Download the 100k data (ml-100k.zip) set into your Downloads folder. Extract the ml-100k.zip file into ~/Downloads folder itself. For this particular assignment, the program will use the u.data and u.item files under the extracted folder. On running the MovieRatings MapReduce program, it should process the u.data file, which contains a list of movie ratings by users and also process u.item file, which has movie related information. In the u.data file, each user has rated at least 20 movies. Users and items are numbered consecutively from 1. The u.data file is randomly ordered and the fields are tab separated with list of fields being user id, item id, rating and timestamp. The u.item field contains sveral pieces of information about each movie. The u.item file is pipe(|) separated. Unfortunately, the text of the README file is incorrect in terms of field separator for u.item, but it has the correct information about the fields and their order. Please look at the actual file and also the README file. The program should take 2 arguments. The first argument should be the directory where the movielens user data set (u.data) and movie information (u.item) files are placed (called /movie-and-ratings in hdfs), and the second argument is the name of directory where the results will be placed in HDFS (called /movie-rating-result).The result of the program should be a list of all movies rated with the following information per line — movie id, movie title, release date, IMDB URL, average rating, total number of unique users rated, total number of ratings for the movie Use 2 reducers by setting the number of reducers to 2. Please add combiner for efficiency. Define a custom counter that has a running count of total records processed in map, total number of unique movies in reducer. Before you begin, please split the input file into 5 files called u1.data, u2.data, u3.data, u4.data and u5.data, each having 20000 records. Use the Unix split command. Reference: https://kb.iu.edu/d/afarAll the input files – 5 user ratings file and the movie information file should be gzip compressed before processing. Reducer output files should be gzipped.It is essential in data science and related disciplines to understand how practical data science applications relate to real-world experiences.Refer to the “16 Data Science Projects with Source Code to Strengthen your Resume,”Resources.https://data-flair.training/blogs/data-science-project-ideas/. Choose one of the following data science projects in Python to review:Detecting Fake News with Python and Machine LearningDetecting Parkinson’s Disease with XGBoostGender and Age Detection with OpenCVFollow the steps to implement the code (source code is provided in each case) on your own computer. Take appropriate screenshots (with descriptions) as needed. All documentation should be completed in your Jupyter Notebook IPYNB file. Then, answer the following questions.What data sets/packages/libraries were used to implement the project? Why?What visualizations were employed to delineate the data? Why were these used compared to other options?How was the final project visualized (e.g., plot, visual report, etc.)? Do you feel this was the best way? Support your rationale.What type of data science project idea dyou feel would be worth conducting in your specific field or industry? Explain your choicecompare the nuances of working in R and Python based on the application assignments. Make sure to discuss the advantages and disadvantages.A Jupyter Notebook file to include appropriate screenshots (with descriptions).Then, address the corresponding questions, as well as the comparisons between R and Python. Make sure to justify your rationale using sound statistical arguments and associated formulas Explain the basic process of encrypting and decrypting a message with a symmetric key. The message is only encrypted, not signed nor authenticated in any way. Assume that the message is sent to a recipient, not that the same person encrypts and decrypts. Be sure to explain what key(s) are needed, who has those keys, and how keys, plaintext, and cipher text are combined to create a working system. This exercise will show you how to encrypt one file with AES. This is NOT the best way to do encryption, for starters, you need to remember which cipher you used for encryption. It’s much better to use a crypto s, such as Cryptomator, Aescrypt or GPG for single files, or Bitlocker or Veracrypt for full disks. Hint: Don’t overengineer the answer to #4, you can dream up some wild ways of exchanging the passphrase, but simpler is better, especially if you’re close geographicallyA cheat sheet for OpenSSL is at: https://www.madboa.com/geek/openssl/ YOU COULD PICK UP a text file, download a picture, choose a Word document, it doesn’t matter. encrypt your file using OpenSSL’s “enc” command to encrypt the file, using either aes-128-cbc, aes-192-cbc, or aes-256-cbc as the cipher. Choose a filename that is the original filename plus “.enc” at the end for the output file. Enter a password when prompted, this password protects your key (you don’t directly manipulate the key with OpenSSL’s way of doing AES)- record your command line here. ________________record your password here —————————————– Securely save your password and chosen cipher . This means do NOT use any method that could be intercepted by ANYONE who could tap phones, sniff internet traffic, or intercept the mail, whether that’s your employer, Google (no email!), the federal government, your ISP, or the various three-letter-agencies around the world. – Explain in a sentence to a paragraph how you could exchanged this key securely with someone . Explain further how this exchange would be complicated if you lived many thousands of miles apart. ————————————————————————————-Exchange the encrypted file with them. – explain in a few sentences to a paragraph how you can securely exchange the encrypted material (the encrypted file) with them.————————————— Decrypt their encrypted file. Use the original file name (e.g., without .enc at the end) as your output file name.1 pt – record the command line here. ________________4 pts – insert a screenshot showing THE CONTENTS OF their decrypted file – if it’s text, please open it in notepad, open an image with an image viewer, a document with Word, etc Zenac Law Firm Ltd. is a small company that rents one floor of a 5-storey building. The company employs 11 lawyers, 7 administrative assistants, 3 IT personnel, and the owner. Each employee is issued a work laptop and is expected to bring 2 additional end devices such as their personal smart phone, tablet, or laptop that are expected to be connected to a wireless router. The IT department is planning an infrastructure upgrade that will include purchasing the following: 2 Dell PowerEdge T340 tower servers using Intel Xeon E-2234 3.6 GHz with 32 GB of ECC RAM running Microsoft Server 2019 Essentials4 Dell Precision 3650 tower workstations using Intel Core i7-11700 2.5 GHz with 16 GB of Non-ECC RAM (1 will be used by the owner and 3 by the IT department)22 HP business laptops using Intel Core i3 or i5 processor with a minimum of 8 GB of DDR4 RAM (1 will be used by the owner and 21 by the staff)3 HP LaserJet Pro 500 printers have been identified to be connected within the network Microsoft Windows 10 Pro 64bit and Office Professional 2019 are the main software that will be utilized within the company. For simplicity and educational purposes, use IPv4 static addressing for all network devices. Your responsibility as a team is to collaborate with the LAN administrator directly to develop a network design proposal based on the current requirements of the company and to report to the company owner. Total Budget: $52,000.00 Suggestions on How to Begin the Case StudyFor the first progress report,Determine the number of hosts per subnet.Hint: number of end devices (such as laptop, workstation, server, printer) per departmentDetermine the number of networks or subnets neededHint: number of departmentsIdentify the network, first usable, last usable, and broadcast addresses of each network or subnet.e to assign static addressesUsing the first usable up to the last usable address, make an IPv4 allocation list of end devices with its corresponding static IP address.Note: You will use static IPv4 address.For the second progress report,Identify intermediary devices such as switches and routers.Hint: Consider the number of wired network connections from the end devices to switch to determine the number of ports or interfaces (e.g., 12-port, 24-port, or 48-port switch)Note: An estimated cost of a wired Gigabit Ethernet network cabling is set to $100 per port, which is the cost and material associated from wall panel to server rack’s cablingUsing the existing IPv4 allocation list, add the intermediary devices with its corresponding static IP address.Identify an intermediary device such as wireless router for wireless network connections.Plan and draw a physical topology using Smart Draw, Microsoft Visio, or Cisco Packet Tracer.Plan and draw a logical topology using the Smart Draw, Microsoft Visio, or Cisco Packet Tracer.Open and use the Marking Guide to complete the remaining requirements 2. Let L-M M): M is a Turing machine that accepts at least two binary strings. a) Define the notions of a recognisable language and an undecidable language. [5 marks [5 marks] b) Is L Turing-recognisable? Justify your answer with an informal argument. c) Prove that L is undecidable. (Hint: use Rice’s theorem.) |20 marks] 20 marks] d) Bonus: Justify with a formal proof your answer to b).kindly answer all the questions Computer Science Engineering & Technology Java Programming COURSE MISC Share QuestionEmailCopy link Comments (0)


