Question: CSE 232, Lab Exercise 8 Partner Choose a partner in the lab to work with on this exercise. Two people should work at one computer.


CSE 232, Lab Exercise 8 Partner Choose a partner in the lab to work with on this exercise. Two people should work at one computer. Occasionally switch who is typing The Problem You remember the Collatz http:en.wikipedia.org/wiki Collatz conjecture One of the problems is that, by doing the calculation over from the beginning for every number, you waste a lot of time redoing work that already has been done. Look at the first 6 sequences sequence, don't ya? Here is a little reminder in case you didn't 2 2,1 3 3, 10, 5, 1, 8, 4,2,1 4 4,2,1 5 5, 1, 8, 4, 2, 1 6 6, 3, 10, 5, 16, 8, 4,2, 1 Subsequences, whose value we already know, are recalculated. For example, the entire sequence of 3 is already known, but we recalculate the entire sequence when starting from 6. Memoization Memoization note the spelling, no is a simple optimization technique used in algorithms where repeat calculations occur (http:en.wikipedia.oeg/wiki Memoization). The idea is simple. We remember a sequence when we first calculate it. Subsequently, for any value we calculate we check first to see if we already know the remaining sequence. If so, we stop the calculation and just copy the known sequence in. For this lab, we will use a map to memorize Collatz sequences. Pay attention to this technique, it comes up in many guises and is very useful! Programming Task Make a new project directory called laboB. Copy lab08 functions. to your directory. You need to write both labos unctions.epp and laboain.epp. You will turn in lab0BEunetions.cpp to Mimir for testing. Data structure, map of 1ong to vector
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
