JDK 8 Lambdas and Streams MOOC: Lesson 3 Homework. The homework this ... a for loop when processing each value to generate the distance from the other ... strings then experiment with adding things like mapping to lower or upper case,.
JDK 8 Lambdas and Streams MOOC: Lesson 3 Homework The homework this week is in three parts. The goal of the exercise is to give you a better understanding of the differences in performance of sequential and parallel stream processing. Part 1: A file called “words” is provided containing a large collection of words. A template file, RandomWords.java, is also provided. In the constructor you need to read all the words (which are one per line) from the source file into a list (remember to use a stream to do this). You also need to write the body of the createList() method. This generates a list of the size specified as a parameter selecting words at random from the list read in the constructor. HINT: You can use the ints() method of the Random class, which returns a stream of random integers. You can specify the size of the stream using a parameter. Part 2: In order to provide a relatively compute-intensive task we will calculate the Levenshtein distance between two strings. This distance is a measure of how many changes need to be made to the first string to convert it to the second string (see https://en.wikipedia.org/wiki/Levenshtein_distance for a more detailed description of what this involves). Since we’re focusing on streams programming, a source file, Levenshtein.java containing a lev() function is provided that will calculate the distance for you. A second template file, Lesson3.java, is provided. This contains the code necessary to measure the time taken to execute the code of the get() method of a Supplier (as you will see in the main() method this is simple to do with a lambda expression). Your task is to write the necessary code in the computeLevenshtein method to calculate the distances between each pair of strings in the wordList using the streams API. You will need to process this sequentially or in parallel based on the flag passed as a parameter. Try modifying the size of the wordList to see what impact this has on the performance, and in particular, how the difference between sequential and parallel performance is affected by the input size. Part 3: As another demonstration of the differences in sequential and parallel stream processing there is a second method, processWords() for you to implement. Take the list of strings passed and process these using a sequential or parallel stream as required to generate a new list. Start by simply sorting the strings then experiment with adding things like mapping to lower or upper case, filtering out certain words (such as those beginning with a certain letter). See what impact adding distinct() to the stream has. For each of these vary the size
of the input list to see how this affects the performance. Find the threshold below which sequential will give a faster answer than parallel. NOTE: Because this is a micro-benchmark the results will not give you a totally accurate measure of the difference between sequential and parallel stream operations. It is good enough, however, to illustrate the differences between the two forms of stream processing in this case.
complete using the things you have learned in during the lesson. For lesson 1 we will ... exercises called Lesson1.java. To simplify ... equivalent method reference.
Oct 20, 2010 - where Î t denotes dividends (profits) obtained from firms which the ... (d) Now suppose that the government taxes labor in order to pay for government spending. In ... 2. Consider the following general equilibrium model. Households cho
Oct 20, 2010 - Solow Model with Investment Specific Technological Change: Suppose that the production ... (c) What is the long run growth rate of output?
(c) Estimate the size of the population after 20 hours ? (a) Fifteen hours srepresents 5 doubling ... (e) eax = Cebx where a = b. (a) x = âe. (b) x = âln(5). (c) x = ee.
What we do wrong! We consume and waste too much energy and water. We exhaust natural resources in order to produce energy. We pollute the air we breathe ...
widely used MPEG-2 one. The aim of ..... Beside its traditional tasks, the video encoder takes the ... them into the systematic error correction encoder to generate.
STUDENT GUIDE. Copyright DASSAULT SYSTEMES. 3-1. C o p y rig h t D. A. S. S ... Use a circle sweep tool with a single guide and tangency .... Using the Spine tool, you can calculate: ... Calculating a Spine Regards to Plane or Guide Curve.
Assembly. Structural. Analysis. â¢Exercises. Master Project. (Case Study). The case .... In CATIA, computation tasks are handled by program called ELFINI Solver.
attached to the front door, for design feasibility study. â Create a cross-section surface for 'Key-pad'. (for Electronic control) at a measured distance from the Arm ...
The diffusion problem for the density Ï(x, t) in a 1D box is defined by. â. ât Ï(x, t) = D ... (2 â E)2 + δ2. ] . 5. Prove the Thouless formula ... 2. ¯u(θ), where V (θ) = kcosθ, and show that for a state with a quasienergy Ï. â r. Jn
On evenings and at weekends,. My friends have just one rule: We all prefer doing things. That we don't do at school. Elizabeth loves swimming. She's always at ...
Sep 17, 2000 - amounts and at unpredictable times, processes them one byte at-a-time, ..... on the specified path), #mustBeOld (user is asked what to do if the.
... the Exercises (3A, 3B, 3C) to practice your ability to recognise these signs. Hieratic Value Hieroglyph Hieratic Value Hieroglyph. sA km. mA pr nfr nb. pH. Htp.
Oct 20, 2010 - Suppose production has the following CES (constant-elasticity of ... 2. Consider a profit maximizing firm that chooses inputs Kt and Lt to ...
It has been nine years since the Congestion Charge was set up in. London. For those who still haven't heard about the Congestion Charge, it is a fee charged ...
Macroeconomics I. Homework 2. October 20, 2010. 1. Consider an infinitely-lived household who makes consumption and savings decisions to maxi- mize. â.
The great mathematician Al-Kindi made the apparently innocuous observation ... Al-Kindi³s code-breaking technique is most easily explained by imagining. ½.
Sep 1, 2013 - This document details all actions that we will be run during Oracle ... through how to migrate your Red Hat guest to Oracle Linux by downloading the ..... ider purchasing Oracle Linux Support via the online store, or via your sa.