<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse231/core/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Benjaminchoi</id>
	<title>CSE231 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse231/core/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Benjaminchoi"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Special:Contributions/Benjaminchoi"/>
	<updated>2026-11-27T00:31:09Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=AllOrNothingLocks&amp;diff=1959</id>
		<title>AllOrNothingLocks</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=AllOrNothingLocks&amp;diff=1959"/>
		<updated>2018-04-26T19:09:21Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* BankAccountTryLocking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;credit for this assignment: [http://jcip.net/ Java Concurrency in Practice], Ben Choi, and Dennis Cosgrove&lt;br /&gt;
&lt;br /&gt;
=Motivation=&lt;br /&gt;
In addition to [[Ordered_Locks]] we can employ an all-or-nothing strategy for acquiring locks for mutual exclusion.&lt;br /&gt;
&lt;br /&gt;
We gain experience with explicit locks and trying to acquire them and responding appropriately to success and failure.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
Check out the [[Lock_Ordering#Background]] studio.&lt;br /&gt;
&lt;br /&gt;
In Java, locks are a synchronization tool that exists to ensure whatever is protected by the lock is only accessed one thread at a time, as to avoid a possible data race. In this studio we will explore the second type of locks: explicitly created &amp;lt;code&amp;gt;Lock&amp;lt;/code&amp;gt; objects from the &amp;lt;code&amp;gt;java.util.concurrent.locks&amp;lt;/code&amp;gt; package.&lt;br /&gt;
&lt;br /&gt;
Every object has an intrinsic lock associated with the object, but &amp;lt;code&amp;gt;Lock&amp;lt;/code&amp;gt; objects are explicitly defined and instantiated locks which can be called to lock or unlock. Lock objects are acted upon just like any other object, but we are mostly interested in the &amp;lt;code&amp;gt;lock()&amp;lt;/code&amp;gt; method, the &amp;lt;code&amp;gt;tryLock()&amp;lt;/code&amp;gt; method, and the &amp;lt;code&amp;gt;unlock()&amp;lt;/code&amp;gt; method. For this studio, we will specifically use the &amp;lt;code&amp;gt;ReentrantLock&amp;lt;/code&amp;gt; object, a class which implements the general &amp;lt;code&amp;gt;Lock&amp;lt;/code&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
To demonstrate how to avoid both data races and deadlock issues, we will create a method designed to transfer money between two bank accounts. Two parties should be able to asynchronously and continuously transfer money between each other without a data race (courtesy of locks) or deadlock (something you will address).&lt;br /&gt;
&lt;br /&gt;
For this approach, we will make use of the &amp;lt;code&amp;gt;tryLock()&amp;lt;/code&amp;gt; method in order to attempt to acquire an object’s lock. If the object’s lock is not available at the time, we will continue to try to acquire the lock until it finally succeeds, after which we can successfully transfer funds from one bank account to another. In this approach, an asynchronous pair of transfers from A to B and B to A will not lead to deadlock as the two processes will give up on acquiring the lock until it becomes available, at which point it will finally acquire the lock. This approach does not make use of ordering, but simply relies on making lock attempts give up if the desired lock is not immediately available (and then try again later).&lt;br /&gt;
&lt;br /&gt;
==Java Util Concurrent==&lt;br /&gt;
Refer to Oracle's official documentation for more information:&lt;br /&gt;
* [https://docs.oracle.com/javase/tutorial/essential/concurrency/newlocks.html Lock Objects Tutorial] &lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/package-summary.html package java.util.concurrent.locks]&lt;br /&gt;
&lt;br /&gt;
*[https://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html while loops]&lt;br /&gt;
*[https://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html finally]&lt;br /&gt;
*[https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#yield-- Thread yield]&lt;br /&gt;
&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html-- Lock]&lt;br /&gt;
** [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html#tryLock-- tryLock]&lt;br /&gt;
** [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html#unlock--- unlock]&lt;br /&gt;
&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/ReentrantLock.html--- ReentrantLock]&lt;br /&gt;
** [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/ReentrantLock.html#isHeldByCurrentThread--- isHeldByCurrentThread ]&lt;br /&gt;
&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/ListIterator.html ListIterator&amp;lt;E&amp;gt;]&lt;br /&gt;
** [https://docs.oracle.com/javase/8/docs/api/java/util/ListIterator.html#hasNext-- boolean hasNext()]&lt;br /&gt;
** [https://docs.oracle.com/javase/8/docs/api/java/util/ListIterator.html#next-- E next()]&lt;br /&gt;
** [https://docs.oracle.com/javase/8/docs/api/java/util/ListIterator.html#hasPrevious-- boolean hasPrevious()]&lt;br /&gt;
** [https://docs.oracle.com/javase/8/docs/api/java/util/ListIterator.html#previous-- E previous()]&lt;br /&gt;
&lt;br /&gt;
=Code To Implement=&lt;br /&gt;
As mentioned in the background section, this implementation will avoid deadlock by giving up on acquiring a lock if it is not immediately available before coming back to it later (when it might actually be available). This implementation will need to make use of the ReentrantLocks associated with the sender and recipient bank account objects. More specifically, it will have to make use of the &amp;lt;code&amp;gt;tryLock()&amp;lt;/code&amp;gt; method. For an example of how to format a tryLock, look below:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Lock lock = ...&lt;br /&gt;
if (lock.tryLock()) {&lt;br /&gt;
	try {&lt;br /&gt;
		doSomething();&lt;br /&gt;
	} finally {&lt;br /&gt;
		lock.unlock();&lt;br /&gt;
	}&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===BankAccountTryLocking===&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|BankAccountLockTrying|tryTransferMoney|lock.allornothing.studio}}&lt;br /&gt;
&lt;br /&gt;
{{ThreadSafe|public static TransferResult tryTransferMoney(AccountWithLock sender, AccountWithLock recipient, int amount)}}&lt;br /&gt;
&lt;br /&gt;
Open &amp;lt;code&amp;gt;BankAccountTryLocking.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;tryLock()&amp;lt;/code&amp;gt; will immediately give up and return false if the lock is not available when it is called. Thus, you will need to construct a loop that will continuously run until the desired lock is available. You can exit out of this loop in two ways: with the break keyword or by returning a valid value for the method. We do this for you so you will not need to write any loops.&lt;br /&gt;
*&amp;lt;code&amp;gt;tryLock()&amp;lt;/code&amp;gt; will grab the lock if it can. There's no need to call &amp;lt;code&amp;gt;lock()&amp;lt;/code&amp;gt; after &amp;lt;code&amp;gt;tryLock()&amp;lt;/code&amp;gt;.&lt;br /&gt;
*We recommend you call the &amp;lt;code&amp;gt;AccountUtils.checkBalanceAndTransfer(sender, receiver, amount)&amp;lt;/code&amp;gt; method for the sake of simplicity. This method will check that the sender and recipient are not the same people and that the sender has enough money in her account to send the specified amount to the recipient.&lt;br /&gt;
*Anytime you lock a lock object, you should/must use a &amp;lt;code&amp;gt;try/finally&amp;lt;/code&amp;gt; block to unlock the lock.&lt;br /&gt;
*Your implementation will have to make use of a nested &amp;lt;code&amp;gt;try/finally&amp;lt;/code&amp;gt; block (one &amp;lt;code&amp;gt;try/finally&amp;lt;/code&amp;gt; call within another).&lt;br /&gt;
&lt;br /&gt;
===LockUtils runWithAllLocksOrDontRunAtAll===&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LockUtils|tryLockAll&amp;lt;br&amp;gt;unlockAllHeldLocks&amp;lt;br&amp;gt;runWithAllLocksOrDontRunAtAll|lock.allornothing.studio}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|public static boolean tryLockAll(List&amp;lt;ReentrantLock&amp;gt; locks)}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|public static void unlockAllHeldLocks(List&amp;lt;ReentrantLock&amp;gt; locks)}}&lt;br /&gt;
&lt;br /&gt;
{{ThreadSafe|public static boolean runWithAllLocksOrDontRunAtAll(List&amp;lt;ReentrantLock&amp;gt; locks, Runnable body)}}&lt;br /&gt;
&lt;br /&gt;
Open &amp;lt;code&amp;gt;LockUtils.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For this part of the studio you will need to implement:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;public static boolean tryLockAll(List&amp;lt;ReentrantLock&amp;gt; locks)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;public static void unlockAllHeldLocks(List&amp;lt;ReentrantLock&amp;gt; locks)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so that the useful utility (shouldn't they all be useful?) &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static boolean runWithAllLocksOrDontRunAtAll(List&amp;lt;ReentrantLock&amp;gt; locks, Runnable body) {&lt;br /&gt;
	boolean status = tryLockAll(locks);&lt;br /&gt;
	if (status) {&lt;br /&gt;
		try {&lt;br /&gt;
			body.run();&lt;br /&gt;
		} finally {&lt;br /&gt;
			unlockAllHeldLocks(locks);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return status;&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
produces correct thread safe behavior.&lt;br /&gt;
&lt;br /&gt;
Note: in &amp;lt;code&amp;gt;tryLockAll&amp;lt;/code&amp;gt;, you will need to call &amp;lt;code&amp;gt;tryLock&amp;lt;/code&amp;gt; on all of the given locks. However, if one fails, you will need to unlock everything you have currently locked. A lock cannot be unlocked from a thread that doesn't hold the lock. Consider using the [https://docs.oracle.com/javase/8/docs/api/java/util/ListIterator.html ListIterator] interface.&lt;br /&gt;
&lt;br /&gt;
{{Warning | If tryLockAll fails to acquire all of the locks, make sure to unlock any of the locks you did acquire.}}&lt;br /&gt;
&lt;br /&gt;
{{Warning | If tryLockAll fails, when rolling back a ListIterator to unlock any locks you acquired, be sure to do an initial prev() to set the iterator in the correct location before looping through to unlock the rest.}}&lt;br /&gt;
&lt;br /&gt;
=Testing Your Solution=&lt;br /&gt;
==Correctness==&lt;br /&gt;
{{TestSuite|TryLockingTestSuite|lock.allornothing.studio}}&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=K_Mer_Counting_Assignment&amp;diff=1946</id>
		<title>K Mer Counting Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=K_Mer_Counting_Assignment&amp;diff=1946"/>
		<updated>2018-04-20T20:34:24Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* ConcurrentBucketHashMapKMerCounter */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;credit for this assignment: John Gibson and Dennis Cosgrove&lt;br /&gt;
=Motivation=&lt;br /&gt;
K-mer counting is a real world application which provides the opportunity to build thread safe data structures which alleviate contention.&lt;br /&gt;
&lt;br /&gt;
Pulling real data from the National Institutes of Health forces us to address balancing our work.&lt;br /&gt;
&lt;br /&gt;
Finally, k-mer counting provides opportunities for performance engineering.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
The term k-mer refers to a substring of length k and k-mer counting refers to the process of finding the number of occurrences of a k-mer in a given string. This computational problem has many real-world applications, the most notable being in the field of computational genomics. In this assignment, you will design a program that will ultimately take in a human X-chromosome and count the number of k-mers in the string of DNA. You will be making use of everything you have learned thus far, including atomic variables. It is useful to know that given a string of length n, the amount of possible k-mers is equal to '''n - k + 1'''.&lt;br /&gt;
&lt;br /&gt;
=Code To Investigate=&lt;br /&gt;
==Java Util Concurrent==&lt;br /&gt;
[https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html ConcurrentHashMap]&lt;br /&gt;
&lt;br /&gt;
[https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicIntegerArray.html AtomicIntegerArray].&lt;br /&gt;
&lt;br /&gt;
[https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html ReentrantReadWriteLock]&lt;br /&gt;
: [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html#readLock-- readLock]&lt;br /&gt;
: [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html#writeLock-- writeLock]&lt;br /&gt;
&lt;br /&gt;
[https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html Lock]&lt;br /&gt;
: [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html#lock-- lock]&lt;br /&gt;
: [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html#lock-- unlock]&lt;br /&gt;
&lt;br /&gt;
==KMerUtils==&lt;br /&gt;
The following methods should be useful as you build the assignment.&lt;br /&gt;
&lt;br /&gt;
Check out the Javadocs either [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/apidocs/kmer/core/KMerUtils.html on the web], or in the comments in KMerUtils.java for further details on how they work.&lt;br /&gt;
&lt;br /&gt;
===long calculatePossibleKMers(int kMerLength)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static long calculatePossibleKMers(int kMerLength) {&lt;br /&gt;
	int bitsPerBase = 2;&lt;br /&gt;
	int bitsPerKMer = kMerLength * bitsPerBase;&lt;br /&gt;
	long possibleKMers = 1L &amp;lt;&amp;lt; bitsPerKMer;&lt;br /&gt;
	return possibleKMers;&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===int toArrayLength(long possibleKMers)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static int toArrayLength(long possibleKMers) {&lt;br /&gt;
	// maximum array length is VM dependent, but must be indexed by an int.&lt;br /&gt;
	// reportedly some vms reserve some header words (see ArrayList) which puts its&lt;br /&gt;
	// limit as just below 2^31.&lt;br /&gt;
	// we will choose 2^30 (inclusive) as the maximum since it will hold the largest&lt;br /&gt;
	// potential k-mer (4^15)&lt;br /&gt;
	final long MAX_K_MER_ARRAY_LENGTH_INCLUSIVE = 1 &amp;lt;&amp;lt; 30;&lt;br /&gt;
	if (possibleKMers &amp;lt;= MAX_K_MER_ARRAY_LENGTH_INCLUSIVE) {&lt;br /&gt;
		return (int) possibleKMers;&lt;br /&gt;
	} else {&lt;br /&gt;
		throw new IllegalArgumentException(possibleKMers + &amp;quot; &amp;gt; &amp;quot; + MAX_K_MER_ARRAY_LENGTH_INCLUSIVE);&lt;br /&gt;
	}&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===int calculateSumOfAllKMers(List&amp;lt;byte[]&amp;gt; sequences, int kMerLength)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static int calculateSumOfAllKMers(List&amp;lt;byte[]&amp;gt; sequences, int kMerLength) {&lt;br /&gt;
	int sum = 0;&lt;br /&gt;
	for (byte[] sequence : sequences) {&lt;br /&gt;
		int i = (sequence.length - kMerLength + 1);&lt;br /&gt;
		if( i &amp;gt; 0 ) {&lt;br /&gt;
			sum += i;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return sum;&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String toString(byte[] sequence, int offset, int kMerLength)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static String toString(byte[] sequence, int offset, int kMerLength) {&lt;br /&gt;
	return new String(sequence, offset, kMerLength, StandardCharsets.UTF_8);&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String toString(byte[] kMer)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static String toString(byte[] kMer) {&lt;br /&gt;
	return new String(kMer, StandardCharsets.UTF_8);&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===int toPackedInt(byte[] sequence, int offset, int kMerLength)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static int toPackedInt(byte[] sequence, int offset, int kMerLength) {&lt;br /&gt;
	int result = 0;&lt;br /&gt;
	for (int i = 0; i &amp;lt; kMerLength; i++) {&lt;br /&gt;
		switch (sequence[offset + i]) {&lt;br /&gt;
		// case A:&lt;br /&gt;
		// result |= (A_MASK_INT &amp;lt;&amp;lt; (i + i));&lt;br /&gt;
		// break;&lt;br /&gt;
		case T:&lt;br /&gt;
			result |= (T_MASK_INT &amp;lt;&amp;lt; (i + i));&lt;br /&gt;
			break;&lt;br /&gt;
		case C:&lt;br /&gt;
			result |= (C_MASK_INT &amp;lt;&amp;lt; (i + i));&lt;br /&gt;
			break;&lt;br /&gt;
		case G:&lt;br /&gt;
			result |= (G_MASK_INT &amp;lt;&amp;lt; (i + i));&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return result;&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===int toPackedInt(byte[] kMer)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static int toPackedInt(byte[] kMer) {&lt;br /&gt;
	return toPackedInt(kMer, 0, kMer.length);&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===byte[] unpackInt(int kMer, int kMerLength)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static byte[] unpackInt(int kMer, int kMerLength) {&lt;br /&gt;
	byte[] result = new byte[kMerLength];&lt;br /&gt;
&lt;br /&gt;
	for (int i = 0; i &amp;lt; kMerLength; i++) {&lt;br /&gt;
		int v = (kMer &amp;gt;&amp;gt; (i + i)) &amp;amp; 0x3;&lt;br /&gt;
		switch (v) {&lt;br /&gt;
		case A_MASK_INT:&lt;br /&gt;
			result[i] = A;&lt;br /&gt;
			break;&lt;br /&gt;
		case T_MASK_INT:&lt;br /&gt;
			result[i] = T;&lt;br /&gt;
			break;&lt;br /&gt;
		case C_MASK_INT:&lt;br /&gt;
			result[i] = C;&lt;br /&gt;
			break;&lt;br /&gt;
		case G_MASK_INT:&lt;br /&gt;
			result[i] = G;&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return result;&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===long toPackedLong(byte[] sequence, int offset, int kMerLength)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static long toPackedLong(byte[] sequence, int offset, int kMerLength) {&lt;br /&gt;
	long result = 0;&lt;br /&gt;
	for (int i = 0; i &amp;lt; kMerLength; i++) {&lt;br /&gt;
		switch (sequence[offset + i]) {&lt;br /&gt;
		// case A:&lt;br /&gt;
		// result |= (A_MASK_LONG &amp;lt;&amp;lt; (i + i));&lt;br /&gt;
		// break;&lt;br /&gt;
		case T:&lt;br /&gt;
			result |= (T_MASK_LONG &amp;lt;&amp;lt; (i + i));&lt;br /&gt;
			break;&lt;br /&gt;
		case C:&lt;br /&gt;
			result |= (C_MASK_LONG &amp;lt;&amp;lt; (i + i));&lt;br /&gt;
			break;&lt;br /&gt;
		case G:&lt;br /&gt;
			result |= (G_MASK_LONG &amp;lt;&amp;lt; (i + i));&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return result;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===long toPackedLong(byte[] sequence)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static long toPackedLong(byte[] sequence) {&lt;br /&gt;
	return toPackedLong(sequence, 0, sequence.length);&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===byte[] unpackLong(long kMer, int kMerLength)===&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static byte[] unpackLong(long kMer, int kMerLength) {&lt;br /&gt;
	byte[] result = new byte[kMerLength];&lt;br /&gt;
&lt;br /&gt;
	for (int i = 0; i &amp;lt; kMerLength; i++) {&lt;br /&gt;
		long v = (kMer &amp;gt;&amp;gt; (i + i)) &amp;amp; 0x3;&lt;br /&gt;
		switch ((int) v) {&lt;br /&gt;
		case A_MASK_INT:&lt;br /&gt;
			result[i] = A;&lt;br /&gt;
			break;&lt;br /&gt;
		case T_MASK_INT:&lt;br /&gt;
			result[i] = T;&lt;br /&gt;
			break;&lt;br /&gt;
		case C_MASK_INT:&lt;br /&gt;
			result[i] = C;&lt;br /&gt;
			break;&lt;br /&gt;
		case G_MASK_INT:&lt;br /&gt;
			result[i] = G;&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return result;&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==KMerCounts==&lt;br /&gt;
===MapKMerCount===&lt;br /&gt;
In order to provide a KMerCount that works with different k-mer type representations we have added an interface KMerCodec which provides functions to go to an from the byte[] representation:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public interface KMerCodec&amp;lt;T&amp;gt; {&lt;br /&gt;
	BiFunction&amp;lt;T, Integer, byte[]&amp;gt; decoder();&lt;br /&gt;
&lt;br /&gt;
	Function&amp;lt;byte[], T&amp;gt; encoder();&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As an example the instance for long -&amp;gt; byte[] and back simply utilizes the pack and unpack methods in KMerUtils:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public enum LongKMerCodec implements KMerCodec&amp;lt;Long&amp;gt; {&lt;br /&gt;
	INSTANCE;&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public Function&amp;lt;byte[], Long&amp;gt; encoder() {&lt;br /&gt;
		return KMerUtils::toPackedLong;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public BiFunction&amp;lt;Long, Integer, byte[]&amp;gt; decoder() {&lt;br /&gt;
		return KMerUtils::unpackLong;&lt;br /&gt;
	}&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creating an instance of a MapKMerCount to return from your KMerCounters will need to use the appropriate codec.  For example, if you have a map of type &amp;lt;code&amp;gt;Map&amp;lt;Long, Integer&amp;gt;&amp;lt;/code&amp;gt; which you wish to wrap and return, your code would look something like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;return new MapKMerCount&amp;lt;&amp;gt;(k, map, LongKMerCodec.INSTANCE);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===IntArrayKMerCount===&lt;br /&gt;
===AtomicIntegerArrayKMerCount===&lt;br /&gt;
&lt;br /&gt;
=Warmups=&lt;br /&gt;
&lt;br /&gt;
The warm-ups associated with this assignment can be found under the &amp;lt;code&amp;gt;kmer.warmup&amp;lt;/code&amp;gt; packages.&lt;br /&gt;
&lt;br /&gt;
==String HashMap Implementation==&lt;br /&gt;
{{CodeToImplement|StringHashMapKMerCounter|parse|kmer.warmup.stringmap}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|public KMerCount parse(List&amp;lt;byte[]&amp;gt; sequences, int k)}}&lt;br /&gt;
&lt;br /&gt;
In this completely sequential implementation, you will have to write the parse method. The method takes in a list of arrays of bytes and a k-mer length. It should return an instance of MapKMerCount(which takes in a map), a class provided to you which does exactly what its name suggests. In order to implement this method, we recommend taking a look at the KMerUtils class and more specifically the toString method, which converts a given byte array into a String in order to make it compatible with the String HashMap.&lt;br /&gt;
&lt;br /&gt;
parse should go through the amount of possible k-mers for every byte array in the list of sequences. As it goes through the bytes in the array, use the KMerUtils.toString() method to create a string to use for the HashMap. The map should take in a String as the key and an Integer as the value. We recommend using the map.compute() method and reviewing how to use lambdas.&lt;br /&gt;
&lt;br /&gt;
==String ConcurrentHashMap Implementation==&lt;br /&gt;
{{CodeToImplement|StringConcurrentHashMapKMerCounter|parse|kmer.warmup.stringmap}}&lt;br /&gt;
&lt;br /&gt;
{{Parallel|public KMerCount parse(List&amp;lt;byte[]&amp;gt; sequences, int k)}}&lt;br /&gt;
&lt;br /&gt;
This implementation will make your sequential String HashMap implementation into a parallel one. To do so, you will be making use of Java’s atomic version of a HashMap: a ConcurrentHashMap. Like before, you will be need to complete the parse method. You can choose to finish this method with a forall loop or a finish/async approach, which is completely up to you.&lt;br /&gt;
&lt;br /&gt;
==ByteArrayRange Implementation==&lt;br /&gt;
{{CodeToImplement|ByteArrayRangeConcurrentHashMapKMerCounter|parse|kmer.warmup.bytearrayrangemap}}&lt;br /&gt;
&lt;br /&gt;
{{Parallel|public KMerCount parse(List&amp;lt;byte[]&amp;gt; sequences, int k)}}&lt;br /&gt;
&lt;br /&gt;
This parallel implementation will overlap greatly with your previous two implementations, but it will use ByteArrayRange instead of Strings. Refer to the ByteArrayRange class in order to get a better idea of how to implement this method and instantiate an instance of the class. The class closely resembles the Slice class you worked on earlier in the semester.&lt;br /&gt;
&lt;br /&gt;
=Lab=&lt;br /&gt;
{{ tip | Get ThresholdSlices working and then use it to balance all of your parallel KMerCounter implementations. }}&lt;br /&gt;
==ThresholdSlices==&lt;br /&gt;
===slicing===&lt;br /&gt;
{{CodeToImplement|ThresholdSlices|addToCollectionKernel&amp;lt;br&amp;gt;createSlicesBelowThreshold&amp;lt;br&amp;gt;calculateReasonableThreshold|kmer.lab.util}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|private static void addToCollectionKernel(Collection&amp;lt;Slice&amp;lt;byte[]&amp;gt;&amp;gt; slices, byte[] sequence, int min, int max, int sliceThreshold)}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|public static List&amp;lt;Slice&amp;lt;byte[]&amp;gt;&amp;gt; createSlicesBelowThreshold(List&amp;lt;byte[]&amp;gt; sequences, int k, int sliceThreshold)}}&lt;br /&gt;
&lt;br /&gt;
This class is designed to take in a list of bytes and convert it into a list of slices. The slice class should be familiar to you from earlier in the semester, but feel free to refer back to the documentation on [[Slices]] for a quick recap. You should perform this task recursively and there are two methods you will need to implement. The createSlicesBelowThreshold method should call the addToCollectionKernel once, but the kernel should take over the recursion from there.&lt;br /&gt;
&lt;br /&gt;
In the createSlicesBelowThreshold method, you should call the recursive kernel for each sequence in the list of sequences. When defining the min and max values, keep the information mentioned in the &amp;quot;Background&amp;quot; section in mind. As for the kernel, it should add a new slice to the collection of slices once the length of the slice dips below the provided threshold, but it should otherwise split itself into two smaller slices using recursion.&lt;br /&gt;
&lt;br /&gt;
In our previous uses of Slices we leveraged sliceIndexId (and not originalData) since it was a n-way split/coarsening scenario.  Here we are recursively splitting each item in a collection of sub-sequences so originalData will be used (and sliceIndexId is unnecessary and can be specified as invalid (-1))..&lt;br /&gt;
&lt;br /&gt;
{{warning | be sure to slice the offset (a.k.a. startingIndex) space}}&lt;br /&gt;
&lt;br /&gt;
for N=10 and K=3, you should be slicing like this:&lt;br /&gt;
&lt;br /&gt;
[[File:ThresholdSlices.svg|320px]]&lt;br /&gt;
&lt;br /&gt;
===threshold calculation===&lt;br /&gt;
{{Sequential|public static int calculateReasonableThreshold(List&amp;lt;byte[]&amp;gt; sequences, int k)}}&lt;br /&gt;
&lt;br /&gt;
Question to ask yourself: given a list of sequences which are to be k-mer counted, how would you calculate a reasonable threshold?&lt;br /&gt;
&lt;br /&gt;
==LongConcurrentHashMapKMerCounter==&lt;br /&gt;
{{CodeToImplement|LongConcurrentHashMapKMerCounter|parse|kmer.lab.longconcurrenthashmap}}&lt;br /&gt;
&lt;br /&gt;
{{Parallel|public KMerCount parse(List&amp;lt;byte[]&amp;gt; sequences, int k)}}&lt;br /&gt;
&lt;br /&gt;
This parallel implementation will also overlap greatly with everything you have done previously, but instead of using Strings or SequenceSlice, we will be using Longs to represent DNA data. In order to do this, refer to the KMerUtils class, more specifically the toPackedLong method which will convert a sequence of bytes into a Long for our purposes. As the data that this implementation can take is much larger than the previous implementations, consider how to instantiate the ConcurrentHashMap in order to avoid dynamically resizing the map. KMerUtils has a method which will calculate this number for you, but think about which one to use, why you would use it, and how that would differ from simply calculating n - k + 1 yourself.&lt;br /&gt;
&lt;br /&gt;
Hint: calculatePossibleKmers and calculateSumOfAllKmers are distinct and take different input parameters. calculateSumOfAllKmers performs the n - k + 1 calculation on a list of arrays of sequences and sums the total. calculatePossibleKmers only takes the length of the k-mer (k) as the input parameter, meaning it will calculate possibilities independent of the size of the sequence. Thus, the n - k + 1 calculation would yield a value ranging from 0 (inclusive) to the result of calculatePossibleKmers (exclusive).&lt;br /&gt;
&lt;br /&gt;
==IntArrayKMerCounter==&lt;br /&gt;
{{CodeToImplement|IntArrayKMerCounter|parse|kmer.lab.intarray}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|public KMerCount parse(List&amp;lt;byte[]&amp;gt; sequences, int k)}}&lt;br /&gt;
&lt;br /&gt;
Like the String HashMap implementation, this implementation should be completed sequentially. However, unlike the previous implementations, we will be using an array instead of a map. This means that you must keep in mind what size to make the array in order to instantiate it. KMerUtils has a method which will calculate this number for you, but think about which one to use, why you would use it, and how that would differ from simply calculating n - k + 1 yourself. Think of using the int array as similar to using the map, but with ints as the key/value pairs. Use KMerUtils.toPackedInt() in order to convert the sequence into an int for our purposes.&lt;br /&gt;
&lt;br /&gt;
Hint: calculatePossibleKmers and calculateSumOfAllKmers are distinct and take different input parameters. calculateSumOfAllKmers performs the n - k + 1 calculation on a list of arrays of sequences and sums the total. calculatePossibleKmers only takes the length of the k-mer (k) as the input parameter, meaning it will calculate possibilities independent of the size of the sequence. Thus, the n - k + 1 calculation would yield a value ranging from 0 (inclusive) to the result of calculatePossibleKmers (exclusive).&lt;br /&gt;
&lt;br /&gt;
==AtomicIntegerArrayKMerCounter==&lt;br /&gt;
{{CodeToImplement|AtomicIntegerArrayKMerCounter|parse|kmer.lab.atomicintegerarray}}&lt;br /&gt;
&lt;br /&gt;
{{Parallel|public KMerCount parse(List&amp;lt;byte[]&amp;gt; sequences, int k)}}&lt;br /&gt;
&lt;br /&gt;
This implementation is simply the parallel equivalent of the int array implementation. To do so, you will be making use of Java’s atomic version of an array: an AtomicIntegerArray. Like before, you will be need to complete the parse method. You can choose to finish this method with a forall loop or a finish/async approach, which is completely up to you.&lt;br /&gt;
&lt;br /&gt;
==ConcurrentBucketHashMapKMerCounter==&lt;br /&gt;
{{CodeToImplement|ConcurrentBucketHashMapKMerCounter|parse|kmer.lab.concurrentbuckethashmap}}&lt;br /&gt;
&lt;br /&gt;
{{Parallel|public KMerCount parse(List&amp;lt;byte[]&amp;gt; sequences, int k)}}&lt;br /&gt;
&lt;br /&gt;
This parallel implementation will go a step beyond the previous implementations and divide entries into 1024 buckets. Although a different number of buckets can be used, we will simply stick to 1024. Every time an entry is added to the bucket dictionary, it will create a hash based on the entry's key and place the entry into one of the 1024 buckets. Because we would only need to search one bucket for an entry based on a key's hash, this mainly serves the purpose of cutting down on search time. The compute method of the ConcurrentBucketHashMap should automatically compute the correct bucket for the entry, so this implementation should closely resemble the previous ConcurrentHashMap implementations. When instantiating the ConcurrentBucketHashMap, we recommend making the key/value pairs a Long and an Integer.&lt;br /&gt;
&lt;br /&gt;
===ConcurrentBucketHashMap===&lt;br /&gt;
{{CodeToImplement|ConcurrentBucketHashMap|constructor&amp;lt;br&amp;gt;getIndex&amp;lt;br&amp;gt;getBucket&amp;lt;br&amp;gt;getLock&amp;lt;br&amp;gt;getEntry&amp;lt;br&amp;gt;get&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;compute|kmer.lab.concurrentbuckethashmap}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|public ConcurrentBucketHashMap(int bucketCount)}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|private int getIndex(Object key)}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|private List&amp;lt;Entry&amp;lt;K, V&amp;gt;&amp;gt; getBucket(Object key)}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|private ReadWriteLock getLock(Object key)}}&lt;br /&gt;
&lt;br /&gt;
{{Sequential|private static &amp;lt;K, V&amp;gt; Entry&amp;lt;K, V&amp;gt; getEntry(List&amp;lt;Entry&amp;lt;K, V&amp;gt;&amp;gt; bucket, Object key)}}&lt;br /&gt;
&lt;br /&gt;
{{ThreadSafe|public V get(Object key)}}&lt;br /&gt;
&lt;br /&gt;
{{ThreadSafe|public V put(K key, V value)}}&lt;br /&gt;
&lt;br /&gt;
{{ThreadSafe|public V compute(K key, BiFunction&amp;lt;? super K, ? super V, ? extends V&amp;gt; remappingFunction)}}&lt;br /&gt;
&lt;br /&gt;
{{ warning | Do '''NOT''' call get() from compute().  It will result in a nonintuitive error.  getEntry(bucket, key) gives you everything you need. }}&lt;br /&gt;
&lt;br /&gt;
{{ tip | Be sure to make your ConcurrentBucketHashMap thread-safe.  If any code is going to access shared mutable data, it needs to do so in a thread-safe manner. }}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
A simple example of how to use the many incantations of isolated:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;@ThreadSafe&lt;br /&gt;
public class IsolatedInteger {&lt;br /&gt;
    private int value;&lt;br /&gt;
&lt;br /&gt;
    public IsolatedInteger(int value) {&lt;br /&gt;
        this.value = value;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public int getValue() {&lt;br /&gt;
        return isolatedWithReturn(objectBased(readMode(this)), () -&amp;gt; {&lt;br /&gt;
            return value;&lt;br /&gt;
        });&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void increment() {&lt;br /&gt;
        isolated(objectBased(this), () -&amp;gt; {&lt;br /&gt;
            value++;&lt;br /&gt;
        });&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=Extra Credit=&lt;br /&gt;
==Open-ended K-mer Counter==&lt;br /&gt;
&lt;br /&gt;
This implementation is worth up to 4.5 extra credit points.&lt;br /&gt;
&lt;br /&gt;
It is intended as an opportunity to build a high-performing, thread-safe data structure.&lt;br /&gt;
&lt;br /&gt;
One possible path was outlined at a high level in class.  However, students are encouraged to think of alternate solutions.&lt;br /&gt;
&lt;br /&gt;
We have explicitly disallowed implementations akin to our matrix map reduce assignment, since we have already done the &amp;quot;give everyone their own data and combine in post&amp;quot; pattern to death.&lt;br /&gt;
&lt;br /&gt;
Partial credit is possible for solutions which demonstrate significant ingenuity.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
* Correct ThresholdSlices (10)&lt;br /&gt;
* Correct Long ConcurrentHashMap (15)&lt;br /&gt;
* Correct Int Array (15)&lt;br /&gt;
* Correct AtomicIntegerArray (15)&lt;br /&gt;
* Correct ConcurrentBucketHashMapCounter (10)&lt;br /&gt;
* Correct ConcurrentBucketHashMap implementation (25)&lt;br /&gt;
* Clarity and efficiency (10)&lt;br /&gt;
&lt;br /&gt;
=Research=&lt;br /&gt;
[https://en.wikipedia.org/wiki/K-mer wikipedia article on k-mers]&lt;br /&gt;
&lt;br /&gt;
paper: [https://academic.oup.com/bioinformatics/article-lookup/doi/10.1093/bioinformatics/btr011 A fast, lock-free approach for efficient parallel counting of occurrences of k-mers] (Jellyfish)&lt;br /&gt;
&lt;br /&gt;
paper: [https://peerj.com/articles/cs-94/ Multiple comparative metagenomics using multiset k-mer counting]&lt;br /&gt;
&lt;br /&gt;
[http://homolog.us/Tutorials/index.php?p=3.7&amp;amp;s=2 Collection of approaches to k-mer counting]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform Burrows–Wheeler transform]&lt;br /&gt;
&lt;br /&gt;
[http://biology.stackexchange.com/questions/45016/what-is-the-biological-significance-of-k-mer-counting Significance of k-mer Counting]&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=1199</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=1199"/>
		<updated>2018-01-26T19:57:57Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* (Optional WarmUp) LoneCollectionMap and (Required) BucketsHashMap */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Motivation=&lt;br /&gt;
We gain experience with interfaces and classes.  In addition we will deal with generic types.  &lt;br /&gt;
&lt;br /&gt;
We implement our own Iterator, Collection, and Map @NotThreadSafe classes.  Later in the semester we will implement a @ThreadSafe version of a Map.&lt;br /&gt;
&lt;br /&gt;
In the creation of our Map class, we will gain experience with hashing which we will leverage throughout the semester.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
* [[Rundown_on_Everything_Java]]&lt;br /&gt;
* [[Interfaces]]&lt;br /&gt;
==Java Util Documentation==&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html Iterator]&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html Collection]&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Map]&lt;br /&gt;
==VisuAlgo==&lt;br /&gt;
* [https://visualgo.net/en/list linked list] &lt;br /&gt;
* [https://visualgo.net/en/hashtable hash table]&lt;br /&gt;
=Mistakes To Avoid=&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT use &amp;lt;nowiki&amp;gt;==&amp;lt;/nowiki&amp;gt;  Use Objects.equals(a,b) }}&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT parallelize. }}&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT simply remove and add for put on a Map.  Look for the entry and set its value if you find it.  Otherwise add it. }}&lt;br /&gt;
&lt;br /&gt;
=Code to Implement=&lt;br /&gt;
To be an [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html Iterable] object a class must implement all of the abstract methods on Iterable.  There happens to be only 1: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Iterator&amp;lt;T&amp;gt; iterator()&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you have an instance of Iterable you can then obviously invoke the iterator() method, then loop over the resulting iterator to process the elements in the Iterable:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	private static void printAllViaIterator(Iterable&amp;lt;String&amp;gt; iterable) {&lt;br /&gt;
		Iterator&amp;lt;String&amp;gt; iterator = iterable.iterator();&lt;br /&gt;
		while(iterator.hasNext()) {&lt;br /&gt;
			String element = iterator.next();&lt;br /&gt;
			System.out.println(element);&lt;br /&gt;
		}&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a bit of sweet syntactic sugar, any Iterable can be used in a [https://docs.oracle.com/javase/8/docs/technotes/guides/language/foreach.html for-each loop]:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	private static void printAllViaForEach(Iterable&amp;lt;String&amp;gt; iterable) {&lt;br /&gt;
		for (String element : iterable) {&lt;br /&gt;
			System.out.println(element);&lt;br /&gt;
		}&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any class that implements Iterable must implement the iterator() method.  A Collection isa Iterable.  The interface Collection extends the interface Iterable.  To be an Iterable&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;		List&amp;lt;String&amp;gt; states = new LinkedList&amp;lt;&amp;gt;();&lt;br /&gt;
		states.add(&amp;quot;Delaware&amp;quot;);&lt;br /&gt;
		states.add(&amp;quot;Idaho&amp;quot;);&lt;br /&gt;
		states.add(&amp;quot;Alaska&amp;quot;);&lt;br /&gt;
		&lt;br /&gt;
		printAllViaIterator(states);&lt;br /&gt;
		printAllViaForEach(states);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ Tip | It is good practice to declare variables, parameters, and fields to be of the least specific type possible (but no less specific :). This is commonly an interface. }}&lt;br /&gt;
&lt;br /&gt;
{{ Warning | A common mistake we see is students attempting to create an instance of an interface when they need to create an instance of a class (e.g. &amp;lt;nowiki&amp;gt;List&amp;lt;String&amp;gt; states = new LinkedList&amp;lt;&amp;gt;();&amp;lt;/nowiki&amp;gt;). }}&lt;br /&gt;
&lt;br /&gt;
==LinkedNodesCollection==&lt;br /&gt;
The most notable subinterface of Iterable is [https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html Collection].  Collection in turn has often used subiterfaces [https://docs.oracle.com/javase/8/docs/api/java/util/List.html List], [https://docs.oracle.com/javase/8/docs/api/java/util/Set.html Set], and [https://docs.oracle.com/javase/8/docs/api/java/util/Queue.html Queue].&lt;br /&gt;
&lt;br /&gt;
The [https://docs.oracle.com/javase/8/docs/api/java/util/package-tree.html class and interface heirarchy doc] has the complete tree for the java.util package.&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LinkedNodesCollection|iterator&amp;lt;br&amp;gt;size&amp;lt;br&amp;gt;add|util.lab.collection}}&lt;br /&gt;
&lt;br /&gt;
We will be creating our own implementation of Collection &amp;lt;code&amp;gt;class LinkedNodesCollection&amp;lt;/code&amp;gt;.  Like many of the Collections you may have used in the past (e.g. LinkedList, HashSet) we will inherit functionality from [https://docs.oracle.com/javase/8/docs/api/java/util/AbstractCollection.html AbstractCollection].  In fact, we will only need to implement three of the public methods: size(), iterator(), and add().  The bulk of AbstractCollection's implementation relies on our correct implementation of iterator().&lt;br /&gt;
&lt;br /&gt;
Correctly implementing size() should be trivial.  Just be sure to increment and decrement size when adding or removing elements respectively.&lt;br /&gt;
&lt;br /&gt;
{{Warning | remove is achieved via the iterator.  Be sure to keep the Collection up to date by invoking decrementSize(). }}&lt;br /&gt;
&lt;br /&gt;
add() will want to use the provided &amp;lt;code&amp;gt;class LinkedNode&amp;lt;E&amp;gt;&amp;lt;/code&amp;gt;.  Simply insert new elements in at the head of your collection as [https://docs.oracle.com/javase/7/docs/api/java/util/Deque.html#offerFirst(E) deque.offerFirst(element)] does.&lt;br /&gt;
&lt;br /&gt;
Providing the required iterator() method will in turn require us to build [[LinkedNodesIterator]].&lt;br /&gt;
&lt;br /&gt;
Note: The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
&lt;br /&gt;
==LinkedNodesIterator==&lt;br /&gt;
{{CodeToImplement|LinkedNodesIterator|hasNext&amp;lt;br&amp;gt;next&amp;lt;br&amp;gt;remove|util.lab.collection}}&lt;br /&gt;
&lt;br /&gt;
Iterator should keep track of the previous, current, and (optionally) next node as you march through the LinkedNodesCollection. This means you will need to think about what member variables to create for this class.&lt;br /&gt;
&lt;br /&gt;
Check out the docs for [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#next-- next()] of when to throw [https://docs.oracle.com/javase/8/docs/api/java/util/NoSuchElementException.html NoSuchElementException] and [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#remove-- remove()] for when to throw [https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html IllegalStateException]. Think of edge cases like when the collection is empty or when the iterator tries to remove the sentinel node.&lt;br /&gt;
&lt;br /&gt;
{{Warning | The iterator should start at the head (sentinel) node. }}&lt;br /&gt;
&lt;br /&gt;
==(Optional WarmUp) LoneCollectionMap and (Required) BucketsHashMap==&lt;br /&gt;
You will most likely want to complete your Collection and Iterator implementations before moving on to the Map implementations as they will be built with them.&lt;br /&gt;
&lt;br /&gt;
A Map (also sometimes referred to as a Dictionary or a Hashtable) is an abstract data structure which has the capabilities of associating a value with a key: &amp;lt;code&amp;gt;map.put(key, value)&amp;lt;/code&amp;gt;, looking up the associated value with a key: &amp;lt;code&amp;gt;map.get(key)&amp;lt;/code&amp;gt;, and removing &amp;lt;code&amp;gt;map.remove(key)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The standard Java Collections Framework [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Map] provides a number of other nice methods, but put, get, and remove are the core of any Map in any programming language.&lt;br /&gt;
&lt;br /&gt;
If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to [[BucketsHashMap]]. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LoneCollectionMap|size&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;remove&amp;lt;br&amp;gt;get|util.warmup.map}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
https://en.wikipedia.org/wiki/Hash_table#/media/File:Hash_table_5_0_1_1_1_1_1_LL.svg&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if it is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|BucketsHashMap|hash&amp;lt;br&amp;gt;getBucketFor&amp;lt;br&amp;gt;size&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;remove&amp;lt;br&amp;gt;get|util.lab.map}}&lt;br /&gt;
&lt;br /&gt;
A simple way to provide the correct semantics of a map is to simply keep a single collection of key value pairs.  The standard interface for a key value pair is [https://docs.oracle.com/javase/8/docs/api/java/util/Map.Entry.html Map's Entry] with the critical methods:&lt;br /&gt;
&lt;br /&gt;
* K getKey()&lt;br /&gt;
* V getValue()&lt;br /&gt;
* V setValue(V value)&lt;br /&gt;
&lt;br /&gt;
We have provided an implementation of Entry for you called [https://www.cse.wustl.edu/~cosgroved/courses/cse231/s18/apidocs/edu/wustl/cse231s/util/KeyMutableValuePair.html KeyMutableValuePair&amp;lt;K,V&amp;gt;].&lt;br /&gt;
&lt;br /&gt;
LoneListMap will be your implementation of a very simple map, while BucketsHashMap will use an entry’s key to place an entry into one of several buckets. &lt;br /&gt;
&lt;br /&gt;
If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Hash_table hash table on wikipedia]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Hash_table_5_0_1_1_1_1_1_LL.svg|frame|[https://commons.wikimedia.org/wiki/File:Hash_table_5_0_1_1_1_1_1_LL.svg mediawiki hash table image]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this class, you will use the entry’s key’s hashcode to determine which of the buckets it should fall into. In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
reference material: [https://www.cs.cmu.edu/~adamchik/15-121/lectures/Hashing/hashing.html Concept of Hashing]&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT implement put as a remove followed by an add.  While correct, it is undesirable.  First look for the key and set its value if you find it before resorting to adding a new entry when you cannot find a previous entry with the key. }}&lt;br /&gt;
&lt;br /&gt;
=Testing Your Solution=&lt;br /&gt;
==Correctness==&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
{{TestSuite|UtilTestSuite|util.lab}}&lt;br /&gt;
&lt;br /&gt;
==Optional WarmUp LoneMap Correctness==&lt;br /&gt;
{{TestSuite|OptionalLoneMapTestSuite|util.warmup.map}}&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
LinkedNodesIterator subtotal: 25&lt;br /&gt;
* Correct hasNext (5)&lt;br /&gt;
* Correct next (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
&lt;br /&gt;
LinkedNodesCollection subtotal: 20&lt;br /&gt;
* Correct iterator (5)&lt;br /&gt;
* Correct size (5)&lt;br /&gt;
* Correct add (10)&lt;br /&gt;
&lt;br /&gt;
BucketsHashMap subtotal: 45&lt;br /&gt;
* Correct hash (2.5)&lt;br /&gt;
* Correct getBucketFor (2.5)&lt;br /&gt;
* Correct size (5)&lt;br /&gt;
* Correct put (15)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=1190</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=1190"/>
		<updated>2018-01-25T19:35:19Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* LinkedNodesIterator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Motivation=&lt;br /&gt;
We gain experience with interfaces and classes.  In addition we will deal with generic types.  &lt;br /&gt;
&lt;br /&gt;
We implement our own Iterator, Collection, and Map @NotThreadSafe classes.  Later in the semester we will implement a @ThreadSafe version of a Map.&lt;br /&gt;
&lt;br /&gt;
In the creation of our Map class, we will gain experience with hashing which we will leverage throughout the semester.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
* [[Rundown_on_Everything_Java]]&lt;br /&gt;
* [[Interfaces]]&lt;br /&gt;
==Java Util Documentation==&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html Iterator]&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html Collection]&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Map]&lt;br /&gt;
==VisuAlgo==&lt;br /&gt;
* [https://visualgo.net/en/list linked list] &lt;br /&gt;
* [https://visualgo.net/en/hashtable hash table]&lt;br /&gt;
=Mistakes To Avoid=&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT use &amp;lt;nowiki&amp;gt;==&amp;lt;/nowiki&amp;gt;  Use Objects.equals(a,b) }}&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT parallelize. }}&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT simply remove and add for put on a Map.  Look for the entry and set its value if you find it.  Otherwise add it. }}&lt;br /&gt;
&lt;br /&gt;
=Code to Implement=&lt;br /&gt;
To be an [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html Iterable] object a class must implement all of the abstract methods on Iterable.  There happens to be only 1: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Iterator&amp;lt;T&amp;gt; iterator()&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you have an instance of Iterable you can then obviously invoke the iterator() method, then loop over the resulting iterator to process the elements in the Iterable:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	private static void printAllViaIterator(Iterable&amp;lt;String&amp;gt; iterable) {&lt;br /&gt;
		Iterator&amp;lt;String&amp;gt; iterator = iterable.iterator();&lt;br /&gt;
		while(iterator.hasNext()) {&lt;br /&gt;
			String element = iterator.next();&lt;br /&gt;
			System.out.println(element);&lt;br /&gt;
		}&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a bit of sweet syntactic sugar, any Iterable can be used in a [https://docs.oracle.com/javase/8/docs/technotes/guides/language/foreach.html for-each loop]:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	private static void printAllViaForEach(Iterable&amp;lt;String&amp;gt; iterable) {&lt;br /&gt;
		for (String element : iterable) {&lt;br /&gt;
			System.out.println(element);&lt;br /&gt;
		}&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any class that implements Iterable must implement the iterator() method.  A Collection isa Iterable.  The interface Collection extends the interface Iterable.  To be an Iterable&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;		List&amp;lt;String&amp;gt; states = new LinkedList&amp;lt;&amp;gt;();&lt;br /&gt;
		states.add(&amp;quot;Delaware&amp;quot;);&lt;br /&gt;
		states.add(&amp;quot;Idaho&amp;quot;);&lt;br /&gt;
		states.add(&amp;quot;Alaska&amp;quot;);&lt;br /&gt;
		&lt;br /&gt;
		printAllViaIterator(states);&lt;br /&gt;
		printAllViaForEach(states);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ Tip | It is good practice to declare variables, parameters, and fields to be of the least specific type possible (but no less specific :). This is commonly an interface. }}&lt;br /&gt;
&lt;br /&gt;
{{ Warning | A common mistake we see is students attempting to create an instance of an interface when they need to create an instance of a class (e.g. &amp;lt;nowiki&amp;gt;List&amp;lt;String&amp;gt; states = new LinkedList&amp;lt;&amp;gt;();&amp;lt;/nowiki&amp;gt;). }}&lt;br /&gt;
&lt;br /&gt;
==LinkedNodesCollection==&lt;br /&gt;
The most notable subinterface of Iterable is [https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html Collection].  Collection in turn has often used subiterfaces [https://docs.oracle.com/javase/8/docs/api/java/util/List.html List], [https://docs.oracle.com/javase/8/docs/api/java/util/Set.html Set], and [https://docs.oracle.com/javase/8/docs/api/java/util/Queue.html Queue].&lt;br /&gt;
&lt;br /&gt;
The [https://docs.oracle.com/javase/8/docs/api/java/util/package-tree.html class and interface heirarchy doc] has the complete tree for the java.util package.&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LinkedNodesCollection|iterator&amp;lt;br&amp;gt;size&amp;lt;br&amp;gt;add|util.lab.collection}}&lt;br /&gt;
&lt;br /&gt;
We will be creating our own implementation of Collection &amp;lt;code&amp;gt;class LinkedNodesCollection&amp;lt;/code&amp;gt;.  Like many of the Collections you may have used in the past (e.g. LinkedList, HashSet) we will inherit functionality from [https://docs.oracle.com/javase/8/docs/api/java/util/AbstractCollection.html AbstractCollection].  In fact, we will only need to implement three of the public methods: size(), iterator(), and add().  The bulk of AbstractCollection's implementation relies on our correct implementation of iterator().&lt;br /&gt;
&lt;br /&gt;
Correctly implementing size() should be trivial.  Just be sure to increment and decrement size when adding or removing elements respectively.&lt;br /&gt;
&lt;br /&gt;
{{Warning | remove is achieved via the iterator.  Be sure to keep the Collection up to date by invoking decrementSize(). }}&lt;br /&gt;
&lt;br /&gt;
add() will want to use the provided &amp;lt;code&amp;gt;class LinkedNode&amp;lt;E&amp;gt;&amp;lt;/code&amp;gt;.  Simply insert new elements in at the head of your collection as [https://docs.oracle.com/javase/7/docs/api/java/util/Deque.html#offerFirst(E) deque.offerFirst(element)] does.&lt;br /&gt;
&lt;br /&gt;
Providing the required iterator() method will in turn require us to build [[LinkedNodesIterator]].&lt;br /&gt;
&lt;br /&gt;
Note: The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
&lt;br /&gt;
==LinkedNodesIterator==&lt;br /&gt;
{{CodeToImplement|LinkedNodesIterator|hasNext&amp;lt;br&amp;gt;next&amp;lt;br&amp;gt;remove|util.lab.collection}}&lt;br /&gt;
&lt;br /&gt;
Iterator should keep track of the previous, current, and (optionally) next node as you march through the LinkedNodesCollection. This means you will need to think about what member variables to create for this class.&lt;br /&gt;
&lt;br /&gt;
Be sure to throw [https://docs.oracle.com/javase/8/docs/api/java/util/NoSuchElementException.html NoSuchElementException] where appropriate. Think of edge cases like when the collection is empty or when the iterator tries to remove the sentinel node.&lt;br /&gt;
&lt;br /&gt;
{{Warning | The iterator should start at the head (sentinel) node. }}&lt;br /&gt;
&lt;br /&gt;
==(Optional WarmUp) LoneCollectionMap and (Required) BucketsHashMap==&lt;br /&gt;
You will most likely want to complete your Collection and Iterator implementations before moving on to the Map implementations as they will be built with them.&lt;br /&gt;
&lt;br /&gt;
A Map (also sometimes referred to as a Dictionary or a Hashtable) is an abstract data structure which has the capabilities of associating a value with a key: &amp;lt;code&amp;gt;map.put(key, value)&amp;lt;/code&amp;gt;, looking up the associated value with a key: &amp;lt;code&amp;gt;map.get(key)&amp;lt;/code&amp;gt;, and removing &amp;lt;code&amp;gt;map.remove(key)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The standard Java Collections Framework [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Map] provides a number of other nice methods, but put, get, and remove are the core of any Map in any programming language.&lt;br /&gt;
&lt;br /&gt;
If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to [[BucketsHashMap]]. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LoneCollectionMap|size&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;remove&amp;lt;br&amp;gt;get|util.warmup.map}}&lt;br /&gt;
&lt;br /&gt;
A simple way to provide the correct semantics of a map is to simply keep a single collection of key value pairs.  The standard interface for a key value pair is [https://docs.oracle.com/javase/8/docs/api/java/util/Map.Entry.html Map's Entry] with the critical methods:&lt;br /&gt;
&lt;br /&gt;
* K getKey()&lt;br /&gt;
* V getValue()&lt;br /&gt;
* V setValue(V value)&lt;br /&gt;
&lt;br /&gt;
We have provided and implementation of Entry for you called [https://www.cse.wustl.edu/~cosgroved/courses/cse231/s18/apidocs/edu/wustl/cse231s/util/KeyMutableValuePair.html KeyMutableValuePair&amp;lt;K,V&amp;gt;].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
https://en.wikipedia.org/wiki/Hash_table#/media/File:Hash_table_5_0_1_1_1_1_1_LL.svg&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if it is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|BucketsHashMap|hash&amp;lt;br&amp;gt;getBucketFor&amp;lt;br&amp;gt;size&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;remove&amp;lt;br&amp;gt;get|util.lab.map}}&lt;br /&gt;
&lt;br /&gt;
LoneListMap will be your implementation of a very simple map, while BucketsHashMap will use an entry’s key to place an entry into one of several buckets. &lt;br /&gt;
&lt;br /&gt;
If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Hash_table hash table on wikipedia]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Hash_table_5_0_1_1_1_1_1_LL.svg|frame|[https://commons.wikimedia.org/wiki/File:Hash_table_5_0_1_1_1_1_1_LL.svg mediawiki hash table image]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this class, you will use the entry’s key’s hashcode to determine which of the buckets it should fall into. In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
reference material: [https://www.cs.cmu.edu/~adamchik/15-121/lectures/Hashing/hashing.html Concept of Hashing]&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT implement put as a remove followed by an add.  While correct, it is undesirable.  First look for the key and set its value if you find it before resorting to adding a new entry when you cannot find a previous entry with the key. }}&lt;br /&gt;
&lt;br /&gt;
=Testing Your Solution=&lt;br /&gt;
==Correctness==&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
{{TestSuite|UtilTestSuite|util.lab}}&lt;br /&gt;
&lt;br /&gt;
==Optional WarmUp LoneMap Correctness==&lt;br /&gt;
{{TestSuite|OptionalLoneMapTestSuite|util.warmup.map}}&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
LinkedNodesIterator subtotal: 25&lt;br /&gt;
* Correct hasNext (5)&lt;br /&gt;
* Correct next (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
&lt;br /&gt;
LinkedNodesCollection subtotal: 20&lt;br /&gt;
* Correct iterator (5)&lt;br /&gt;
* Correct size (5)&lt;br /&gt;
* Correct add (10)&lt;br /&gt;
&lt;br /&gt;
BucketsHashMap subtotal: 45&lt;br /&gt;
* Correct hash (2.5)&lt;br /&gt;
* Correct getBucketFor (2.5)&lt;br /&gt;
* Correct size (5)&lt;br /&gt;
* Correct put (15)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=1189</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=1189"/>
		<updated>2018-01-25T19:33:41Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* LinkedNodesIterator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Motivation=&lt;br /&gt;
We gain experience with interfaces and classes.  In addition we will deal with generic types.  &lt;br /&gt;
&lt;br /&gt;
We implement our own Iterator, Collection, and Map @NotThreadSafe classes.  Later in the semester we will implement a @ThreadSafe version of a Map.&lt;br /&gt;
&lt;br /&gt;
In the creation of our Map class, we will gain experience with hashing which we will leverage throughout the semester.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
* [[Rundown_on_Everything_Java]]&lt;br /&gt;
* [[Interfaces]]&lt;br /&gt;
==Java Util Documentation==&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html Iterator]&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html Collection]&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Map]&lt;br /&gt;
==VisuAlgo==&lt;br /&gt;
* [https://visualgo.net/en/list linked list] &lt;br /&gt;
* [https://visualgo.net/en/hashtable hash table]&lt;br /&gt;
=Mistakes To Avoid=&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT use &amp;lt;nowiki&amp;gt;==&amp;lt;/nowiki&amp;gt;  Use Objects.equals(a,b) }}&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT parallelize. }}&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT simply remove and add for put on a Map.  Look for the entry and set its value if you find it.  Otherwise add it. }}&lt;br /&gt;
&lt;br /&gt;
=Code to Implement=&lt;br /&gt;
To be an [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html Iterable] object a class must implement all of the abstract methods on Iterable.  There happens to be only 1: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Iterator&amp;lt;T&amp;gt; iterator()&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you have an instance of Iterable you can then obviously invoke the iterator() method, then loop over the resulting iterator to process the elements in the Iterable:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	private static void printAllViaIterator(Iterable&amp;lt;String&amp;gt; iterable) {&lt;br /&gt;
		Iterator&amp;lt;String&amp;gt; iterator = iterable.iterator();&lt;br /&gt;
		while(iterator.hasNext()) {&lt;br /&gt;
			String element = iterator.next();&lt;br /&gt;
			System.out.println(element);&lt;br /&gt;
		}&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a bit of sweet syntactic sugar, any Iterable can be used in a [https://docs.oracle.com/javase/8/docs/technotes/guides/language/foreach.html for-each loop]:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	private static void printAllViaForEach(Iterable&amp;lt;String&amp;gt; iterable) {&lt;br /&gt;
		for (String element : iterable) {&lt;br /&gt;
			System.out.println(element);&lt;br /&gt;
		}&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any class that implements Iterable must implement the iterator() method.  A Collection isa Iterable.  The interface Collection extends the interface Iterable.  To be an Iterable&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;		List&amp;lt;String&amp;gt; states = new LinkedList&amp;lt;&amp;gt;();&lt;br /&gt;
		states.add(&amp;quot;Delaware&amp;quot;);&lt;br /&gt;
		states.add(&amp;quot;Idaho&amp;quot;);&lt;br /&gt;
		states.add(&amp;quot;Alaska&amp;quot;);&lt;br /&gt;
		&lt;br /&gt;
		printAllViaIterator(states);&lt;br /&gt;
		printAllViaForEach(states);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ Tip | It is good practice to declare variables, parameters, and fields to be of the least specific type possible (but no less specific :). This is commonly an interface. }}&lt;br /&gt;
&lt;br /&gt;
{{ Warning | A common mistake we see is students attempting to create an instance of an interface when they need to create an instance of a class (e.g. &amp;lt;nowiki&amp;gt;List&amp;lt;String&amp;gt; states = new LinkedList&amp;lt;&amp;gt;();&amp;lt;/nowiki&amp;gt;). }}&lt;br /&gt;
&lt;br /&gt;
==LinkedNodesCollection==&lt;br /&gt;
The most notable subinterface of Iterable is [https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html Collection].  Collection in turn has often used subiterfaces [https://docs.oracle.com/javase/8/docs/api/java/util/List.html List], [https://docs.oracle.com/javase/8/docs/api/java/util/Set.html Set], and [https://docs.oracle.com/javase/8/docs/api/java/util/Queue.html Queue].&lt;br /&gt;
&lt;br /&gt;
The [https://docs.oracle.com/javase/8/docs/api/java/util/package-tree.html class and interface heirarchy doc] has the complete tree for the java.util package.&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LinkedNodesCollection|iterator&amp;lt;br&amp;gt;size&amp;lt;br&amp;gt;add|util.lab.collection}}&lt;br /&gt;
&lt;br /&gt;
We will be creating our own implementation of Collection &amp;lt;code&amp;gt;class LinkedNodesCollection&amp;lt;/code&amp;gt;.  Like many of the Collections you may have used in the past (e.g. LinkedList, HashSet) we will inherit functionality from [https://docs.oracle.com/javase/8/docs/api/java/util/AbstractCollection.html AbstractCollection].  In fact, we will only need to implement three of the public methods: size(), iterator(), and add().  The bulk of AbstractCollection's implementation relies on our correct implementation of iterator().&lt;br /&gt;
&lt;br /&gt;
Correctly implementing size() should be trivial.  Just be sure to increment and decrement size when adding or removing elements respectively.&lt;br /&gt;
&lt;br /&gt;
{{Warning | remove is achieved via the iterator.  Be sure to keep the Collection up to date by invoking decrementSize(). }}&lt;br /&gt;
&lt;br /&gt;
add() will want to use the provided &amp;lt;code&amp;gt;class LinkedNode&amp;lt;E&amp;gt;&amp;lt;/code&amp;gt;.  Simply insert new elements in at the head of your collection as [https://docs.oracle.com/javase/7/docs/api/java/util/Deque.html#offerFirst(E) deque.offerFirst(element)] does.&lt;br /&gt;
&lt;br /&gt;
Providing the required iterator() method will in turn require us to build [[LinkedNodesIterator]].&lt;br /&gt;
&lt;br /&gt;
Note: The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
&lt;br /&gt;
==LinkedNodesIterator==&lt;br /&gt;
{{CodeToImplement|LinkedNodesIterator|hasNext&amp;lt;br&amp;gt;next&amp;lt;br&amp;gt;remove|util.lab.collection}}&lt;br /&gt;
&lt;br /&gt;
Iterator should keep track of the previous, current, and (optionally) next node as you march through the LinkedNodesCollection. This means you will need to think about what member variables to create for this class.&lt;br /&gt;
&lt;br /&gt;
Be sure to throw [https://docs.oracle.com/javase/8/docs/api/java/util/NoSuchElementException.html NoSuchElementException] where appropriate.&lt;br /&gt;
&lt;br /&gt;
{{Warning | The iterator should start at the head (sentinel) node. }}&lt;br /&gt;
&lt;br /&gt;
==(Optional WarmUp) LoneCollectionMap and (Required) BucketsHashMap==&lt;br /&gt;
You will most likely want to complete your Collection and Iterator implementations before moving on to the Map implementations as they will be built with them.&lt;br /&gt;
&lt;br /&gt;
A Map (also sometimes referred to as a Dictionary or a Hashtable) is an abstract data structure which has the capabilities of associating a value with a key: &amp;lt;code&amp;gt;map.put(key, value)&amp;lt;/code&amp;gt;, looking up the associated value with a key: &amp;lt;code&amp;gt;map.get(key)&amp;lt;/code&amp;gt;, and removing &amp;lt;code&amp;gt;map.remove(key)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The standard Java Collections Framework [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Map] provides a number of other nice methods, but put, get, and remove are the core of any Map in any programming language.&lt;br /&gt;
&lt;br /&gt;
If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to [[BucketsHashMap]]. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LoneCollectionMap|size&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;remove&amp;lt;br&amp;gt;get|util.warmup.map}}&lt;br /&gt;
&lt;br /&gt;
A simple way to provide the correct semantics of a map is to simply keep a single collection of key value pairs.  The standard interface for a key value pair is [https://docs.oracle.com/javase/8/docs/api/java/util/Map.Entry.html Map's Entry] with the critical methods:&lt;br /&gt;
&lt;br /&gt;
* K getKey()&lt;br /&gt;
* V getValue()&lt;br /&gt;
* V setValue(V value)&lt;br /&gt;
&lt;br /&gt;
We have provided and implementation of Entry for you called [https://www.cse.wustl.edu/~cosgroved/courses/cse231/s18/apidocs/edu/wustl/cse231s/util/KeyMutableValuePair.html KeyMutableValuePair&amp;lt;K,V&amp;gt;].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
https://en.wikipedia.org/wiki/Hash_table#/media/File:Hash_table_5_0_1_1_1_1_1_LL.svg&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if it is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|BucketsHashMap|hash&amp;lt;br&amp;gt;getBucketFor&amp;lt;br&amp;gt;size&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;remove&amp;lt;br&amp;gt;get|util.lab.map}}&lt;br /&gt;
&lt;br /&gt;
LoneListMap will be your implementation of a very simple map, while BucketsHashMap will use an entry’s key to place an entry into one of several buckets. &lt;br /&gt;
&lt;br /&gt;
If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Hash_table hash table on wikipedia]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Hash_table_5_0_1_1_1_1_1_LL.svg|frame|[https://commons.wikimedia.org/wiki/File:Hash_table_5_0_1_1_1_1_1_LL.svg mediawiki hash table image]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this class, you will use the entry’s key’s hashcode to determine which of the buckets it should fall into. In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
reference material: [https://www.cs.cmu.edu/~adamchik/15-121/lectures/Hashing/hashing.html Concept of Hashing]&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT implement put as a remove followed by an add.  While correct, it is undesirable.  First look for the key and set its value if you find it before resorting to adding a new entry when you cannot find a previous entry with the key. }}&lt;br /&gt;
&lt;br /&gt;
=Testing Your Solution=&lt;br /&gt;
==Correctness==&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
{{TestSuite|UtilTestSuite|util.lab}}&lt;br /&gt;
&lt;br /&gt;
==Optional WarmUp LoneMap Correctness==&lt;br /&gt;
{{TestSuite|OptionalLoneMapTestSuite|util.warmup.map}}&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
LinkedNodesIterator subtotal: 25&lt;br /&gt;
* Correct hasNext (5)&lt;br /&gt;
* Correct next (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
&lt;br /&gt;
LinkedNodesCollection subtotal: 20&lt;br /&gt;
* Correct iterator (5)&lt;br /&gt;
* Correct size (5)&lt;br /&gt;
* Correct add (10)&lt;br /&gt;
&lt;br /&gt;
BucketsHashMap subtotal: 45&lt;br /&gt;
* Correct hash (2.5)&lt;br /&gt;
* Correct getBucketFor (2.5)&lt;br /&gt;
* Correct size (5)&lt;br /&gt;
* Correct put (15)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=1188</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=1188"/>
		<updated>2018-01-25T19:31:04Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* LinkedNodesIterator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Motivation=&lt;br /&gt;
We gain experience with interfaces and classes.  In addition we will deal with generic types.  &lt;br /&gt;
&lt;br /&gt;
We implement our own Iterator, Collection, and Map @NotThreadSafe classes.  Later in the semester we will implement a @ThreadSafe version of a Map.&lt;br /&gt;
&lt;br /&gt;
In the creation of our Map class, we will gain experience with hashing which we will leverage throughout the semester.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
* [[Rundown_on_Everything_Java]]&lt;br /&gt;
* [[Interfaces]]&lt;br /&gt;
==Java Util Documentation==&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html Iterator]&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html Collection]&lt;br /&gt;
* [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Map]&lt;br /&gt;
==VisuAlgo==&lt;br /&gt;
* [https://visualgo.net/en/list linked list] &lt;br /&gt;
* [https://visualgo.net/en/hashtable hash table]&lt;br /&gt;
=Mistakes To Avoid=&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT use &amp;lt;nowiki&amp;gt;==&amp;lt;/nowiki&amp;gt;  Use Objects.equals(a,b) }}&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT parallelize. }}&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT simply remove and add for put on a Map.  Look for the entry and set its value if you find it.  Otherwise add it. }}&lt;br /&gt;
&lt;br /&gt;
=Code to Implement=&lt;br /&gt;
To be an [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html Iterable] object a class must implement all of the abstract methods on Iterable.  There happens to be only 1: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Iterator&amp;lt;T&amp;gt; iterator()&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you have an instance of Iterable you can then obviously invoke the iterator() method, then loop over the resulting iterator to process the elements in the Iterable:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	private static void printAllViaIterator(Iterable&amp;lt;String&amp;gt; iterable) {&lt;br /&gt;
		Iterator&amp;lt;String&amp;gt; iterator = iterable.iterator();&lt;br /&gt;
		while(iterator.hasNext()) {&lt;br /&gt;
			String element = iterator.next();&lt;br /&gt;
			System.out.println(element);&lt;br /&gt;
		}&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a bit of sweet syntactic sugar, any Iterable can be used in a [https://docs.oracle.com/javase/8/docs/technotes/guides/language/foreach.html for-each loop]:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	private static void printAllViaForEach(Iterable&amp;lt;String&amp;gt; iterable) {&lt;br /&gt;
		for (String element : iterable) {&lt;br /&gt;
			System.out.println(element);&lt;br /&gt;
		}&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any class that implements Iterable must implement the iterator() method.  A Collection isa Iterable.  The interface Collection extends the interface Iterable.  To be an Iterable&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;		List&amp;lt;String&amp;gt; states = new LinkedList&amp;lt;&amp;gt;();&lt;br /&gt;
		states.add(&amp;quot;Delaware&amp;quot;);&lt;br /&gt;
		states.add(&amp;quot;Idaho&amp;quot;);&lt;br /&gt;
		states.add(&amp;quot;Alaska&amp;quot;);&lt;br /&gt;
		&lt;br /&gt;
		printAllViaIterator(states);&lt;br /&gt;
		printAllViaForEach(states);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ Tip | It is good practice to declare variables, parameters, and fields to be of the least specific type possible (but no less specific :). This is commonly an interface. }}&lt;br /&gt;
&lt;br /&gt;
{{ Warning | A common mistake we see is students attempting to create an instance of an interface when they need to create an instance of a class (e.g. &amp;lt;nowiki&amp;gt;List&amp;lt;String&amp;gt; states = new LinkedList&amp;lt;&amp;gt;();&amp;lt;/nowiki&amp;gt;). }}&lt;br /&gt;
&lt;br /&gt;
==LinkedNodesCollection==&lt;br /&gt;
The most notable subinterface of Iterable is [https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html Collection].  Collection in turn has often used subiterfaces [https://docs.oracle.com/javase/8/docs/api/java/util/List.html List], [https://docs.oracle.com/javase/8/docs/api/java/util/Set.html Set], and [https://docs.oracle.com/javase/8/docs/api/java/util/Queue.html Queue].&lt;br /&gt;
&lt;br /&gt;
The [https://docs.oracle.com/javase/8/docs/api/java/util/package-tree.html class and interface heirarchy doc] has the complete tree for the java.util package.&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LinkedNodesCollection|iterator&amp;lt;br&amp;gt;size&amp;lt;br&amp;gt;add|util.lab.collection}}&lt;br /&gt;
&lt;br /&gt;
We will be creating our own implementation of Collection &amp;lt;code&amp;gt;class LinkedNodesCollection&amp;lt;/code&amp;gt;.  Like many of the Collections you may have used in the past (e.g. LinkedList, HashSet) we will inherit functionality from [https://docs.oracle.com/javase/8/docs/api/java/util/AbstractCollection.html AbstractCollection].  In fact, we will only need to implement three of the public methods: size(), iterator(), and add().  The bulk of AbstractCollection's implementation relies on our correct implementation of iterator().&lt;br /&gt;
&lt;br /&gt;
Correctly implementing size() should be trivial.  Just be sure to increment and decrement size when adding or removing elements respectively.&lt;br /&gt;
&lt;br /&gt;
{{Warning | remove is achieved via the iterator.  Be sure to keep the Collection up to date by invoking decrementSize(). }}&lt;br /&gt;
&lt;br /&gt;
add() will want to use the provided &amp;lt;code&amp;gt;class LinkedNode&amp;lt;E&amp;gt;&amp;lt;/code&amp;gt;.  Simply insert new elements in at the head of your collection as [https://docs.oracle.com/javase/7/docs/api/java/util/Deque.html#offerFirst(E) deque.offerFirst(element)] does.&lt;br /&gt;
&lt;br /&gt;
Providing the required iterator() method will in turn require us to build [[LinkedNodesIterator]].&lt;br /&gt;
&lt;br /&gt;
Note: The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
&lt;br /&gt;
==LinkedNodesIterator==&lt;br /&gt;
{{CodeToImplement|LinkedNodesIterator|hasNext&amp;lt;br&amp;gt;next&amp;lt;br&amp;gt;remove|util.lab.collection}}&lt;br /&gt;
&lt;br /&gt;
Iterator should keep track of the previous, current, and (optionally) next node as you march through the LinkedNodesCollection. This means you will need to think about what member variables to create for this class.&lt;br /&gt;
&lt;br /&gt;
Be sure to throw [https://docs.oracle.com/javase/8/docs/api/java/util/NoSuchElementException.html NoSuchElementException] where appropriate.&lt;br /&gt;
&lt;br /&gt;
==(Optional WarmUp) LoneCollectionMap and (Required) BucketsHashMap==&lt;br /&gt;
You will most likely want to complete your Collection and Iterator implementations before moving on to the Map implementations as they will be built with them.&lt;br /&gt;
&lt;br /&gt;
A Map (also sometimes referred to as a Dictionary or a Hashtable) is an abstract data structure which has the capabilities of associating a value with a key: &amp;lt;code&amp;gt;map.put(key, value)&amp;lt;/code&amp;gt;, looking up the associated value with a key: &amp;lt;code&amp;gt;map.get(key)&amp;lt;/code&amp;gt;, and removing &amp;lt;code&amp;gt;map.remove(key)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The standard Java Collections Framework [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Map] provides a number of other nice methods, but put, get, and remove are the core of any Map in any programming language.&lt;br /&gt;
&lt;br /&gt;
If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to [[BucketsHashMap]]. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|LoneCollectionMap|size&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;remove&amp;lt;br&amp;gt;get|util.warmup.map}}&lt;br /&gt;
&lt;br /&gt;
A simple way to provide the correct semantics of a map is to simply keep a single collection of key value pairs.  The standard interface for a key value pair is [https://docs.oracle.com/javase/8/docs/api/java/util/Map.Entry.html Map's Entry] with the critical methods:&lt;br /&gt;
&lt;br /&gt;
* K getKey()&lt;br /&gt;
* V getValue()&lt;br /&gt;
* V setValue(V value)&lt;br /&gt;
&lt;br /&gt;
We have provided and implementation of Entry for you called [https://www.cse.wustl.edu/~cosgroved/courses/cse231/s18/apidocs/edu/wustl/cse231s/util/KeyMutableValuePair.html KeyMutableValuePair&amp;lt;K,V&amp;gt;].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
https://en.wikipedia.org/wiki/Hash_table#/media/File:Hash_table_5_0_1_1_1_1_1_LL.svg&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if it is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{CodeToImplement|BucketsHashMap|hash&amp;lt;br&amp;gt;getBucketFor&amp;lt;br&amp;gt;size&amp;lt;br&amp;gt;put&amp;lt;br&amp;gt;remove&amp;lt;br&amp;gt;get|util.lab.map}}&lt;br /&gt;
&lt;br /&gt;
LoneListMap will be your implementation of a very simple map, while BucketsHashMap will use an entry’s key to place an entry into one of several buckets. &lt;br /&gt;
&lt;br /&gt;
If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Hash_table hash table on wikipedia]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Hash_table_5_0_1_1_1_1_1_LL.svg|frame|[https://commons.wikimedia.org/wiki/File:Hash_table_5_0_1_1_1_1_1_LL.svg mediawiki hash table image]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this class, you will use the entry’s key’s hashcode to determine which of the buckets it should fall into. In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
reference material: [https://www.cs.cmu.edu/~adamchik/15-121/lectures/Hashing/hashing.html Concept of Hashing]&lt;br /&gt;
&lt;br /&gt;
{{Warning | Do NOT implement put as a remove followed by an add.  While correct, it is undesirable.  First look for the key and set its value if you find it before resorting to adding a new entry when you cannot find a previous entry with the key. }}&lt;br /&gt;
&lt;br /&gt;
=Testing Your Solution=&lt;br /&gt;
==Correctness==&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
{{TestSuite|UtilTestSuite|util.lab}}&lt;br /&gt;
&lt;br /&gt;
==Optional WarmUp LoneMap Correctness==&lt;br /&gt;
{{TestSuite|OptionalLoneMapTestSuite|util.warmup.map}}&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
LinkedNodesIterator subtotal: 25&lt;br /&gt;
* Correct hasNext (5)&lt;br /&gt;
* Correct next (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
&lt;br /&gt;
LinkedNodesCollection subtotal: 20&lt;br /&gt;
* Correct iterator (5)&lt;br /&gt;
* Correct size (5)&lt;br /&gt;
* Correct add (10)&lt;br /&gt;
&lt;br /&gt;
BucketsHashMap subtotal: 45&lt;br /&gt;
* Correct hash (2.5)&lt;br /&gt;
* Correct getBucketFor (2.5)&lt;br /&gt;
* Correct size (5)&lt;br /&gt;
* Correct put (15)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Slices&amp;diff=1142</id>
		<title>Slices</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Slices&amp;diff=1142"/>
		<updated>2018-01-22T15:23:55Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Strict Specification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Motivation=&lt;br /&gt;
Coarsening, or n-way split as we tend to call it in this course, comes up a fair amount.  This studio has you implement a utility that you can use over and over throughout the semester.&lt;br /&gt;
&lt;br /&gt;
In order to support future testing well, we are strict about exactly how the data is split up among the slices.&lt;br /&gt;
&lt;br /&gt;
=Code to Implement=&lt;br /&gt;
{{CodeToImplement|Slices|createNSlicesForArrayObject|slices.studio}}&lt;br /&gt;
&lt;br /&gt;
==createNSlicesForArrayObject==&lt;br /&gt;
In order to support primitive arrays (e.g. byte[], int[], et cetera) and non-primitive arrays (e.g. Object[]) we provide all of the public methods, each which simply call the single method requiring implementation:&lt;br /&gt;
&lt;br /&gt;
{{Sequential|createNSlicesForArrayObject}}&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;	public static &amp;lt;T&amp;gt; List&amp;lt;Slice&amp;lt;T[]&amp;gt;&amp;gt; createNSlices(T[] data, int numSlices) {&lt;br /&gt;
		return createNSlicesForArrayObject(data, numSlices);&lt;br /&gt;
	}&lt;br /&gt;
	public static List&amp;lt;Slice&amp;lt;byte[]&amp;gt;&amp;gt; createNSlices(byte[] data, int numSlices) {&lt;br /&gt;
		return createNSlicesForArrayObject(data, numSlices);&lt;br /&gt;
	}&lt;br /&gt;
	public static List&amp;lt;Slice&amp;lt;char[]&amp;gt;&amp;gt; createNSlices(char[] data, int numSlices) {&lt;br /&gt;
		return createNSlicesForArrayObject(data, numSlices);&lt;br /&gt;
	}&lt;br /&gt;
	public static List&amp;lt;Slice&amp;lt;short[]&amp;gt;&amp;gt; createNSlices(short[] data, int numSlices) {&lt;br /&gt;
		return createNSlicesForArrayObject(data, numSlices);&lt;br /&gt;
	}&lt;br /&gt;
	public static List&amp;lt;Slice&amp;lt;int[]&amp;gt;&amp;gt; createNSlices(int[] data, int numSlices) {&lt;br /&gt;
		return createNSlicesForArrayObject(data, numSlices);&lt;br /&gt;
	}&lt;br /&gt;
	public static List&amp;lt;Slice&amp;lt;long[]&amp;gt;&amp;gt; createNSlices(long[] data, int numSlices) {&lt;br /&gt;
		return createNSlicesForArrayObject(data, numSlices);&lt;br /&gt;
	}&lt;br /&gt;
	public static List&amp;lt;Slice&amp;lt;float[]&amp;gt;&amp;gt; createNSlices(float[] data, int numSlices) {&lt;br /&gt;
		return createNSlicesForArrayObject(data, numSlices);&lt;br /&gt;
	}&lt;br /&gt;
	public static List&amp;lt;Slice&amp;lt;double[]&amp;gt;&amp;gt; createNSlices(double[] data, int numSlices) {&lt;br /&gt;
		return createNSlicesForArrayObject(data, numSlices);&lt;br /&gt;
	}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To pull this off we will need to use the [https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Array.html#getLength-java.lang.Object- Array.getLength(Object)] method.&lt;br /&gt;
&lt;br /&gt;
=Strict Specification=&lt;br /&gt;
We are overly strict about the specification of how the data '''must''' be sliced up.  This is to allow to accurately compare results intermediate results throughout the semester.&lt;br /&gt;
==Example: array.length=7; numSlices=4==&lt;br /&gt;
Distribute the remainder 1 each to the lower end slices (the first few slices or the lower index slices).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|A&lt;br /&gt;
|A&lt;br /&gt;
|B&lt;br /&gt;
|B&lt;br /&gt;
|C&lt;br /&gt;
|C&lt;br /&gt;
|D&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{Warning|Do NOT slice up the data by giving all of the remainder to one slice}} &lt;br /&gt;
&amp;lt;s&amp;gt;&lt;br /&gt;
A&lt;br /&gt;
|B&lt;br /&gt;
|C&lt;br /&gt;
|D&lt;br /&gt;
|D&lt;br /&gt;
|D&lt;br /&gt;
|D&lt;br /&gt;
&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Mistakes To Avoid=&lt;br /&gt;
{{warning | Do NOT Parallelize}}&lt;br /&gt;
&lt;br /&gt;
{{warning | Do NOT Copy The Data Into SubArrays}}&lt;br /&gt;
&lt;br /&gt;
=class Slice&amp;lt;T&amp;gt;=&lt;br /&gt;
use: [https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/slice/core/Slice.html class Slice]&lt;br /&gt;
&lt;br /&gt;
This class has everything you need for [[Nucleobase_Counting#Coarsening_N-Way_Split|n-way split]] problems, specifically: [https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/slice/core/Slice.html#getSliceIndexId-- getSliceIndexId()], [https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/slice/core/Slice.html#getMinInclusive-- getMinInclusive()], and [https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/slice/core/Slice.html#getMaxExclusive-- getMaxExclusive()].&lt;br /&gt;
&lt;br /&gt;
[https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/slice/core/Slice.html#getOriginalUnslicedData-- getOriginalUnslicedData()] is not necessary until the [[K-MerCounting_Assignment|K-Mer Counting Lab]]&lt;br /&gt;
&lt;br /&gt;
=Testing Your Solution=&lt;br /&gt;
==Correctness==&lt;br /&gt;
{{TestSuite|SlicesTestSuite|slice.studio}}&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=N-Queens/Sudoku_Assignment&amp;diff=597</id>
		<title>N-Queens/Sudoku Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=N-Queens/Sudoku_Assignment&amp;diff=597"/>
		<updated>2017-10-30T19:57:42Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Sudoku */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
The n-queens problem is a fundamental coding puzzle which asks: how can N queens be placed on an NxN chessboard so that they cannot attack each other? In chess, a queen can move horizontally, vertically, and diagonally across the board. Thus, to solve the n-queens problem, we must effectively figure out how to place the queens in such a way that no two of them occupy the same row, column, or diagonal.&lt;br /&gt;
&lt;br /&gt;
We will be using a similar algorithm to solve a Sudoku puzzle. A Sudoku puzzle is composed of a 9-by-9 grid of squares. This grid is also divided into 9 large boxes, each of which is a 3-by-3 of the smaller squares. In a completed puzzle, each of the smaller squares contains a single number from 1 to 9 (inclusive). However, if a square contains a given number, that same number cannot be anywhere else in the same row, column, or box. Thus, for Sudoku, we are given an incomplete board and must fill in the remaining squares while meeting these requirements. For more explanation, take a look at [http://norvig.com/sudoku.html Peter Norvig's essay about solving Sudoku].&lt;br /&gt;
&lt;br /&gt;
In this assignment, you will implement solutions to both the n-queens and Sudoku problems.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
All of the classes you will need to implement can be found under &amp;lt;code&amp;gt;nqueens.assignment&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sudoku.assignment&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;nqueens.core&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sudoku.core&amp;lt;/code&amp;gt; packages are utility and building block classes we created for you and the '''viz''' source folder contains visualization apps that might help you understand your code from a visual standpoint. Take a look at these classes to get a better understanding of how to use them for your assignment.&lt;br /&gt;
&lt;br /&gt;
==N-Queens==&lt;br /&gt;
&lt;br /&gt;
There are three classes you will need to modify: &amp;lt;code&amp;gt;DefaultImmutableQueenLocations.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SequentialNQueens.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ParallelNQueens.java&amp;lt;/code&amp;gt;. Start with &amp;lt;code&amp;gt;QueenLocations&amp;lt;/code&amp;gt; and then we recommend moving on to the sequential solution before the parallel one. Take a look at the javadocs to see what everything does and what you will need to implement.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*There is an outdated comment in &amp;lt;code&amp;gt;DefaultImmutableQueenLocations&amp;lt;/code&amp;gt;. There is no &amp;lt;code&amp;gt;NQueensUtils&amp;lt;/code&amp;gt; class; you should look at &amp;lt;code&amp;gt;AbstractQueenLocations&amp;lt;/code&amp;gt; instead.&lt;br /&gt;
*As &amp;lt;code&amp;gt;ImmutableQueenLocations&amp;lt;/code&amp;gt; is immutable, you will need to create a new instance of the object whenever you move on from one row to the next. This is where &amp;lt;code&amp;gt;createNext&amp;lt;/code&amp;gt; comes in, along with the private constructor of this class.&lt;br /&gt;
*The &amp;lt;code&amp;gt;isNextRowThreatFree&amp;lt;/code&amp;gt; method can easily be completed with a method in &amp;lt;code&amp;gt;AbstractQueenLocations&amp;lt;/code&amp;gt;. Refer to that for help.&lt;br /&gt;
*The sequential solution uses &amp;lt;code&amp;gt;MutableQueenLocations&amp;lt;/code&amp;gt; while the parallel solution uses your implementation of &amp;lt;code&amp;gt;ImmutableQueenLocations&amp;lt;/code&amp;gt;. Be careful to use the correct &amp;lt;code&amp;gt;QueenLocations&amp;lt;/code&amp;gt; implementation.&lt;br /&gt;
*As the name suggests, &amp;lt;code&amp;gt;placeQueenInRow&amp;lt;/code&amp;gt; will go through the columns of the given row to check if a queen can fit in that location. If it can, it will set that value in &amp;lt;code&amp;gt;MutableQueenLocations&amp;lt;/code&amp;gt;. If the examined row is that last row of the board, you have found one valid solution to the n-queens problem. Update the correct parameter accordingly. Otherwise, recurse and keep going until you reach the last row.&lt;br /&gt;
*For the parallel implementation of &amp;lt;code&amp;gt;placeQueenInRow&amp;lt;/code&amp;gt;, we are using the &amp;quot;one-finish&amp;quot; pattern. Do not call &amp;lt;code&amp;gt;finish&amp;lt;/code&amp;gt; in the recursive method.&lt;br /&gt;
*The syntax for instantiating a &amp;lt;code&amp;gt;FinishAccumulator&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;Integer&amp;lt;/code&amp;gt; is: &amp;lt;code&amp;gt;FinishAccumulator&amp;lt;Integer&amp;gt; acc = newIntegerFinishAccumulator(NumberReductionOperator.SUM);&amp;lt;/code&amp;gt;&lt;br /&gt;
*The syntax for using a &amp;lt;code&amp;gt;FinishAccumulator&amp;lt;/code&amp;gt; is: &amp;lt;code&amp;gt;finish(register(acc), () -&amp;gt; { //body });&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sudoku==&lt;br /&gt;
&lt;br /&gt;
There are three classes you will need to modify: &amp;lt;code&amp;gt;DefaultImmutableSudokuPuzzle.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SquareSearchAlgorithms.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ParallelSudoku.java&amp;lt;/code&amp;gt; (we would recommend moving through these classes in this order). Take a look at the javadocs to see what everything does and what you will need to implement.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*As the name suggests, &amp;lt;code&amp;gt;ImmutableSudokuPuzzle&amp;lt;/code&amp;gt; is immutable, and you will need to create a new instance of the object whenever you move on from one square to the next. This is analogous to the immutable n-queens board.&lt;br /&gt;
*The &amp;lt;code&amp;gt;getOptions&amp;lt;/code&amp;gt; method in &amp;lt;code&amp;gt;SudokuPuzzle&amp;lt;/code&amp;gt; should find what value the given square could represent by searching the value of its peers (same row, same column, and same box). Starting with &amp;lt;code&amp;gt;ALL_OPTIONS&amp;lt;/code&amp;gt;, the number of options should be removed depending on the peer. If the square is already filled in, it should simply return the correct value.&lt;br /&gt;
*If you have two Lists, &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;, and you set &amp;lt;code&amp;gt;a = b&amp;lt;/code&amp;gt;, then any changes you make to &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; will also be made to &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;. Both variables reference the same objects; they are not copies.&lt;br /&gt;
*The &amp;lt;code&amp;gt;getValue&amp;lt;/code&amp;gt; method is already done for you, but it might be useful for a later portion of the assignment.&lt;br /&gt;
*Your solvers should be able to handle two different approaches to picking the next square in the puzzle to examine: row major and fewest options first. Row major just means going through the puzzle row by row, while fewest options first means solving the puzzle in the order of which squares has the fewest options.&lt;br /&gt;
**The row major approach is already done for you&lt;br /&gt;
**For fewest options first, go through every square (you can do this by calling &amp;lt;code&amp;gt;Square.values()&amp;lt;/code&amp;gt;) and see how many options are available for each square. Return the square with the minimal number of options. However, check to make sure the puzzle is not already completed or that you are returning already filled squares.&lt;br /&gt;
*Just like n-queens, your &amp;lt;code&amp;gt;solveKernel&amp;lt;/code&amp;gt; is the recursive method that will be called in the solve method. Again, watch where you put your &amp;lt;code&amp;gt;finish&amp;lt;/code&amp;gt;.&lt;br /&gt;
*In your &amp;lt;code&amp;gt;solveKernel&amp;lt;/code&amp;gt; method, you should use your desired search algorithm (row major or fewest options first) to select which square you will fill. After selecting a square, you should recursively call the kernel to check every viable option in the context of the puzzle. If there are no more unfilled squares, you should set the value of the solution to the finished puzzle and exit out of the recursion.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
N-Queens subtotal: 40&lt;br /&gt;
* Correct ImmutableQueenLocations (10)&lt;br /&gt;
* Correct sequential implementation (10)&lt;br /&gt;
* Correct parallel implementation (20)&lt;br /&gt;
&lt;br /&gt;
Sudoku subtotal: 50&lt;br /&gt;
* Correct ImmutableSudokuPuzzle (10)&lt;br /&gt;
* Correct SquareSearchAlgorithm (15)&lt;br /&gt;
* Correct ParallelSudoku (25)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=357</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=357"/>
		<updated>2017-09-21T20:47:58Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In the following assignment, you will use your knowledge of Java to create your own implementation of a '''SinglyLinkedList''' and an '''ArrayOfBucketsHashMap'''.  As a warm up exercise for the '''ArrayOfBucketsHashMap''' you are encouraged to build a '''LoneListMap'''. If you are not sure what a list or a map is, please refer to the relevant documentation to familiarize yourself with these data structures. As a good visualization, check out VisuAlgo's interactive demo for a [https://visualgo.net/en/list linked list] and [https://visualgo.net/en/hashtable hash table]. This assignment is designed to make sure you have a firm grasp on Java’s data structures.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''src/main/java''' directory. Go into the '''list.core''' and '''map.core''' packages and take a look at &amp;lt;code&amp;gt;SimpleList.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SimpleMap.java&amp;lt;/code&amp;gt;, repectively. These are the interfaces you must implement in &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ArrayOfBucketsHashMap.java&amp;lt;/code&amp;gt;. SinglyLinkedList, as the name suggests, will be your implementation of a singly linked list. LoneListMap will be your implementation of a very simple map, while ArrayOfBucketsHashMap will use an entry’s key to place an entry into one of several buckets. If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
&lt;br /&gt;
==SinglyLinkedList==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to either of the two maps as the maps will use your list. The only class you have to modify is &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class. Refer to the associated SimpleList interface in order to see descriptions of what each method should do and then get started! Alternatively, you can hover your mouse over the name of the method and the javadocs should pop up for you. All of this should look extremely familiar if you took CSE 131.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*Remember to update your next reference and size when inserting and deleting.&lt;br /&gt;
*The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
*While you do not have to use LinkedListIterator to correctly implement all of the methods, feel free to do so as it might make your life easier. If you are not familiar with iterators, we recommend at least attempting this in order to familiarize yourself with them.&lt;br /&gt;
**When using the iterator, remember that the &amp;quot;head&amp;quot; is a sentinel node. For the purpose of this assignment, you will want to put the call to iterator.next() at the start of the loop as opposed to the end.&lt;br /&gt;
*For the get method, remember to account for when the user attempts to feed an index value that is less than zero or greater than size. Refer to the javadocs for more detail, but it should return null and not throw an exception for such a scenario.&lt;br /&gt;
*You must implement the addFirst method before any of the others if you want your tests to work.&lt;br /&gt;
&lt;br /&gt;
==LoneListMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as both maps uses your implementation of a singly linked list. If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to ArrayOfBucketsHashMap. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the list is equivalent to the size of the map.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if it is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
&lt;br /&gt;
==ArrayOfBucketsHashMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. In this class, you will use the entry’s key’s hashcode to determine which of 1024 buckets it should fall into. The reasoning for why we do this is explained under “Where to Start.” In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the map is equal to the size of the sum of the 1024 buckets, with each bucket containing one list.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if the new value is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to create the method.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
SinglyLinkedList subtotal: 40&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct addFirst (7.5)&lt;br /&gt;
* Correct remove (7.5)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct indexOf (10)&lt;br /&gt;
&lt;br /&gt;
ArrayOfBucketsHashMap subtotal: 50&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct put (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct compute (15)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MergeSort&amp;diff=355</id>
		<title>MergeSort</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MergeSort&amp;diff=355"/>
		<updated>2017-09-21T20:04:54Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* MergeSort Studio */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In computer science, merge sort refers to a sorting algorithm which splits an array of data into continuously smaller halves until the arrays reach a size of 1, after which the elements are continuously compared and merged into a sorted array. For more information on how this process works, visit [https://en.wikipedia.org/wiki/Merge_sort this] page. If you took CSE 247, this algorithm should look extremely familiar to you.&lt;br /&gt;
&lt;br /&gt;
==Visualization==&lt;br /&gt;
&lt;br /&gt;
If you've never seen mergesort before, it may be helpful to take a look at [https://visualgo.net/en/sorting?slide=10 this] page which gives a visual demonstration of the algorithm in practice.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''sort.studio.merge''' package and look at the &amp;lt;code&amp;gt;MergeSort.java&amp;lt;/code&amp;gt; class. The '''sort.core.merg''' packagecontains some useful building block classes we created for you. Take a look at the &amp;lt;code&amp;gt;MergeableData&amp;lt;/code&amp;gt; interface as you will need to use its methods to assist you in this studio.&lt;br /&gt;
&lt;br /&gt;
=MergeSort Studio=&lt;br /&gt;
&lt;br /&gt;
You will need to implement merge sort sequentially and in parallel, but you will need to do both implementations recursively. The kernel method should call itself using recursion, but the mergesort method should only call the kernel once. We do this in order to manipulate where we can place our async/finish blocks. When completing this studio, think carefully about where to put your async/finish calls.&lt;br /&gt;
&lt;br /&gt;
==Sequential Implementation==&lt;br /&gt;
&lt;br /&gt;
The only thing you will need to edit is the kernel method. As this is a sequential implementation, there is no need to call an async or finish. Using the description of merge sort provided to you in the background, try to consider what the base case would be. Then, further consider how to call the method recursively. When the array reaches the base case, you will need to complete the “merging” aspect of merge sort. As mentioned above, there is a method in the utils class that should help with this.&lt;br /&gt;
&lt;br /&gt;
Hint: Follow the Wikipedia links and look at the pseudocode for help.&lt;br /&gt;
&lt;br /&gt;
==Parallel Implementation==&lt;br /&gt;
&lt;br /&gt;
This should look exactly like the sequential implementation, but it should also include async/finish calls. Think carefully about where to place them to maximize concurrency.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=329</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=329"/>
		<updated>2017-09-18T21:00:03Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* ArrayOfBucketsHashMap */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In the following assignment, you will use your knowledge of Java to create your own implementation of a '''SinglyLinkedList''' and an '''ArrayOfBucketsHashMap'''.  As a warm up exercise for the '''ArrayOfBucketsHashMap''' you are encouraged to build a '''LoneListMap'''. If you are not sure what a list or a map is, please refer to the relevant documentation to familiarize yourself with these data structures. As a good visualization, check out VisuAlgo's interactive demo for a [https://visualgo.net/en/list linked list] and [https://visualgo.net/en/hashtable hash table]. This assignment is designed to make sure you have a firm grasp on Java’s data structures.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''src/main/java''' directory. Go into the '''list.core''' and '''map.core''' packages and take a look at &amp;lt;code&amp;gt;SimpleList.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SimpleMap.java&amp;lt;/code&amp;gt;, repectively. These are the interfaces you must implement in &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ArrayOfBucketsHashMap.java&amp;lt;/code&amp;gt;. SinglyLinkedList, as the name suggests, will be your implementation of a singly linked list. LoneListMap will be your implementation of a very simple map, while ArrayOfBucketsHashMap will use an entry’s key to place an entry into one of several buckets. If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
&lt;br /&gt;
==SinglyLinkedList==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to either of the two maps as the maps will use your list. The only class you have to modify is &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class. Refer to the associated SimpleList interface in order to see descriptions of what each method should do and then get started! Alternatively, you can hover your mouse over the name of the method and the javadocs should pop up for you. All of this should look extremely familiar if you took CSE 131.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*Remember to update your next reference and size when inserting and deleting.&lt;br /&gt;
*The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
*While you do not have to use LinkedListIterator to correctly implement all of the methods, feel free to do so as it might make your life easier. If you are not familiar with iterators, we recommend at least attempting this in order to familiarize yourself with them.&lt;br /&gt;
**When using the iterator, remember that the &amp;quot;head&amp;quot; is a sentinel node. For the purpose of this assignment, you will want to put the call to iterator.next() at the start of the loop as opposed to the end.&lt;br /&gt;
*For the get method, remember to account for when the user attempts to feed an index value that is less than zero or greater than size. Refer to the javadocs for more detail, but it should return null and not throw an exception for such a scenario.&lt;br /&gt;
*You must implement the addFirst method before any of the others if you want your tests to work.&lt;br /&gt;
&lt;br /&gt;
==LoneListMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as both maps uses your implementation of a singly linked list. If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to ArrayOfBucketsHashMap. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the list is equivalent to the size of the map.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if it is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
&lt;br /&gt;
==ArrayOfBucketsHashMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. In this class, you will use the entry’s key’s hashcode to determine which of 1024 buckets it should fall into. The reasoning for why we do this is explained under “Where to Start.” In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the map is equal to the size of the sum of the 1024 buckets, with each bucket containing one list.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if it is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to create the method.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
SinglyLinkedList subtotal: 40&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct addFirst (7.5)&lt;br /&gt;
* Correct remove (7.5)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct indexOf (10)&lt;br /&gt;
&lt;br /&gt;
ArrayOfBucketsHashMap subtotal: 50&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct put (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct compute (15)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=328</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=328"/>
		<updated>2017-09-18T20:59:37Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* LoneListMap */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In the following assignment, you will use your knowledge of Java to create your own implementation of a '''SinglyLinkedList''' and an '''ArrayOfBucketsHashMap'''.  As a warm up exercise for the '''ArrayOfBucketsHashMap''' you are encouraged to build a '''LoneListMap'''. If you are not sure what a list or a map is, please refer to the relevant documentation to familiarize yourself with these data structures. As a good visualization, check out VisuAlgo's interactive demo for a [https://visualgo.net/en/list linked list] and [https://visualgo.net/en/hashtable hash table]. This assignment is designed to make sure you have a firm grasp on Java’s data structures.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''src/main/java''' directory. Go into the '''list.core''' and '''map.core''' packages and take a look at &amp;lt;code&amp;gt;SimpleList.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SimpleMap.java&amp;lt;/code&amp;gt;, repectively. These are the interfaces you must implement in &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ArrayOfBucketsHashMap.java&amp;lt;/code&amp;gt;. SinglyLinkedList, as the name suggests, will be your implementation of a singly linked list. LoneListMap will be your implementation of a very simple map, while ArrayOfBucketsHashMap will use an entry’s key to place an entry into one of several buckets. If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
&lt;br /&gt;
==SinglyLinkedList==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to either of the two maps as the maps will use your list. The only class you have to modify is &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class. Refer to the associated SimpleList interface in order to see descriptions of what each method should do and then get started! Alternatively, you can hover your mouse over the name of the method and the javadocs should pop up for you. All of this should look extremely familiar if you took CSE 131.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*Remember to update your next reference and size when inserting and deleting.&lt;br /&gt;
*The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
*While you do not have to use LinkedListIterator to correctly implement all of the methods, feel free to do so as it might make your life easier. If you are not familiar with iterators, we recommend at least attempting this in order to familiarize yourself with them.&lt;br /&gt;
**When using the iterator, remember that the &amp;quot;head&amp;quot; is a sentinel node. For the purpose of this assignment, you will want to put the call to iterator.next() at the start of the loop as opposed to the end.&lt;br /&gt;
*For the get method, remember to account for when the user attempts to feed an index value that is less than zero or greater than size. Refer to the javadocs for more detail, but it should return null and not throw an exception for such a scenario.&lt;br /&gt;
*You must implement the addFirst method before any of the others if you want your tests to work.&lt;br /&gt;
&lt;br /&gt;
==LoneListMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as both maps uses your implementation of a singly linked list. If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to ArrayOfBucketsHashMap. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the list is equivalent to the size of the map.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry if it is not null. The method should return this new value. Otherwise, the method should return null and the entry should be removed from the map.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
&lt;br /&gt;
==ArrayOfBucketsHashMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. In this class, you will use the entry’s key’s hashcode to determine which of 1024 buckets it should fall into. The reasoning for why we do this is explained under “Where to Start.” In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the map is equal to the size of the sum of the 1024 buckets, with each bucket containing one list.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to create the method.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
SinglyLinkedList subtotal: 40&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct addFirst (7.5)&lt;br /&gt;
* Correct remove (7.5)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct indexOf (10)&lt;br /&gt;
&lt;br /&gt;
ArrayOfBucketsHashMap subtotal: 50&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct put (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct compute (15)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=327</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=327"/>
		<updated>2017-09-18T20:07:13Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Rubric */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In the following assignment, you will use your knowledge of Java to create your own implementation of a '''SinglyLinkedList''' and an '''ArrayOfBucketsHashMap'''.  As a warm up exercise for the '''ArrayOfBucketsHashMap''' you are encouraged to build a '''LoneListMap'''. If you are not sure what a list or a map is, please refer to the relevant documentation to familiarize yourself with these data structures. As a good visualization, check out VisuAlgo's interactive demo for a [https://visualgo.net/en/list linked list] and [https://visualgo.net/en/hashtable hash table]. This assignment is designed to make sure you have a firm grasp on Java’s data structures.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''src/main/java''' directory. Go into the '''list.core''' and '''map.core''' packages and take a look at &amp;lt;code&amp;gt;SimpleList.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SimpleMap.java&amp;lt;/code&amp;gt;, repectively. These are the interfaces you must implement in &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ArrayOfBucketsHashMap.java&amp;lt;/code&amp;gt;. SinglyLinkedList, as the name suggests, will be your implementation of a singly linked list. LoneListMap will be your implementation of a very simple map, while ArrayOfBucketsHashMap will use an entry’s key to place an entry into one of several buckets. If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
&lt;br /&gt;
==SinglyLinkedList==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to either of the two maps as the maps will use your list. The only class you have to modify is &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class. Refer to the associated SimpleList interface in order to see descriptions of what each method should do and then get started! Alternatively, you can hover your mouse over the name of the method and the javadocs should pop up for you. All of this should look extremely familiar if you took CSE 131.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*Remember to update your next reference and size when inserting and deleting.&lt;br /&gt;
*The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
*While you do not have to use LinkedListIterator to correctly implement all of the methods, feel free to do so as it might make your life easier. If you are not familiar with iterators, we recommend at least attempting this in order to familiarize yourself with them.&lt;br /&gt;
**When using the iterator, remember that the &amp;quot;head&amp;quot; is a sentinel node. For the purpose of this assignment, you will want to put the call to iterator.next() at the start of the loop as opposed to the end.&lt;br /&gt;
*For the get method, remember to account for when the user attempts to feed an index value that is less than zero or greater than size. Refer to the javadocs for more detail, but it should return null and not throw an exception for such a scenario.&lt;br /&gt;
*You must implement the addFirst method before any of the others if you want your tests to work.&lt;br /&gt;
&lt;br /&gt;
==LoneListMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as both maps uses your implementation of a singly linked list. If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to ArrayOfBucketsHashMap. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the list is equivalent to the size of the map.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
&lt;br /&gt;
==ArrayOfBucketsHashMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. In this class, you will use the entry’s key’s hashcode to determine which of 1024 buckets it should fall into. The reasoning for why we do this is explained under “Where to Start.” In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Prefer [https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#equals-java.lang.Object-java.lang.Object- Objects.equals(a,b)] over ==&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the map is equal to the size of the sum of the 1024 buckets, with each bucket containing one list.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to create the method.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
SinglyLinkedList subtotal: 40&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct addFirst (7.5)&lt;br /&gt;
* Correct remove (7.5)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct indexOf (10)&lt;br /&gt;
&lt;br /&gt;
ArrayOfBucketsHashMap subtotal: 50&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct put (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct compute (15)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=312</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=312"/>
		<updated>2017-09-15T19:35:16Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* SinglyLinkedList */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In the following assignment, you will use your knowledge of Java to create your own implementation of a '''SinglyLinkedList''' and an '''ArrayOfBucketsHashMap'''.  As a warm up exercise for the '''ArrayOfBucketsHashMap''' you are encouraged to build a '''LoneListMap'''. If you are not sure what a list or a map is, please refer to the relevant documentation to familiarize yourself with these data structures. As a good visualization, check out VisuAlgo's interactive demo for a [https://visualgo.net/en/list linked list] and [https://visualgo.net/en/hashtable hash table]. This assignment is designed to make sure you have a firm grasp on Java’s data structures.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''src/main/java''' directory. Go into the '''list.core''' and '''map.core''' packages and take a look at &amp;lt;code&amp;gt;SimpleList.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SimpleMap.java&amp;lt;/code&amp;gt;, repectively. These are the interfaces you must implement in &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ArrayOfBucketsHashMap.java&amp;lt;/code&amp;gt;. SinglyLinkedList, as the name suggests, will be your implementation of a singly linked list. LoneListMap will be your implementation of a very simple map, while ArrayOfBucketsHashMap will use an entry’s key to place an entry into one of several buckets. If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
&lt;br /&gt;
==SinglyLinkedList==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to either of the two maps as the maps will use your list. The only class you have to modify is &amp;lt;code&amp;gt;SinglyLinkedList.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class. Refer to the associated SimpleList interface in order to see descriptions of what each method should do and then get started! Alternatively, you can hover your mouse over the name of the method and the javadocs should pop up for you. All of this should look extremely familiar if you took CSE 131.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Remember to update your next reference and size when inserting and deleting.&lt;br /&gt;
*The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
*While you do not have to use LinkedListIterator to correctly implement all of the methods, feel free to do so as it might make your life easier. If you are not familiar with iterators, we recommend at least attempting this in order to familiarize yourself with them.&lt;br /&gt;
**When using the iterator, remember that the &amp;quot;head&amp;quot; is a sentinel node. For the purpose of this assignment, you will want to put the call to iterator.next() at the start of the loop as opposed to the end.&lt;br /&gt;
*For the get method, remember to account for when the user attempts to feed an index value that is less than zero or greater than size. Refer to the javadocs for more detail, but it should return null and not throw an exception for such a scenario.&lt;br /&gt;
*You must implement the addFirst method before any of the others if you want your tests to work.&lt;br /&gt;
&lt;br /&gt;
==LoneListMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as both maps uses your implementation of a singly linked list. If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to ArrayOfBucketsHashMap. Otherwise, there is a warm up task of implementing &amp;lt;code&amp;gt;LoneListMap.java&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the list is equivalent to the size of the map.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
*The tests for this package test both LoneListMap and ArrayOfBucketsHashMap, so do not worry if you are failing the tests if you haven’t both maps, yet.&lt;br /&gt;
&lt;br /&gt;
==ArrayOfBucketsHashMap==&lt;br /&gt;
&lt;br /&gt;
You must finish SinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. In this class, you will use the entry’s key’s hashcode to determine which of 1024 buckets it should fall into. The reasoning for why we do this is explained under “Where to Start.” In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the map is equal to the size of the sum of the 1024 buckets, with each bucket containing one list.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to create the method.&lt;br /&gt;
*The tests for this package test both LoneListMap and ArrayOfBucketsHashMap, so do not worry if you are failing the tests if you haven’t implemented both maps, yet.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
SinglyLinkedList subtotal: 40&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct putAtFront (7.5)&lt;br /&gt;
* Correct remove (7.5)&lt;br /&gt;
* Correct getValueAt (10)&lt;br /&gt;
* Correct getIndexOf (10)&lt;br /&gt;
&lt;br /&gt;
ArrayOfBucketsHashMap subtotal: 50&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct put (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct compute (15)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=252</id>
		<title>Nucleobase Counting</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=252"/>
		<updated>2017-08-31T18:27:17Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* calculateMidpoint */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
For this assignment, you will be writing sequential and parallel code to count nucleobases in a human X chromosome.&lt;br /&gt;
 &lt;br /&gt;
DNA is made up of four nucleobases: cytosine, guanine, adenine, and thymine. A strand of DNA can thus be represented as a string of letters representing these nucleobases, for example: “ACCGCATAAAGTCC.” However, DNA sequencing is typically not 100% accurate, so some of the nucleobases are not read with high certainty. These bases can be represented as an “N.” A sequence then might look something like “NCCGCATNAAGTCC.” Your goal is to write code that counts the number of unknown nucleobases.&lt;br /&gt;
 &lt;br /&gt;
We will be using actual data pulled from the US National Library of Medicine, a database maintained by the National Institute of Health. We have already provided you the code that you need to access the chromosome from the database and check your work. You must implement a sequential solution and two parallel solutions to count the given bases in these sequences.&lt;br /&gt;
&lt;br /&gt;
For some more optional background on DNA and nucleotide bases, please refer to the links under Optional Reading.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You will find the starting point for this assignment is in the count folder.  In the count.assignment package you will find NucleobaseCounting.java.&lt;br /&gt;
&lt;br /&gt;
==calculateMidpoint==&lt;br /&gt;
&lt;br /&gt;
In this method, you will need to calculate the midpoint between two numbers. This is as simple as finding the average between the two numbers. There is no need to worry about rounding correctly, just drop everything after the decimal point if the midpoint is not automatically an int.&lt;br /&gt;
&lt;br /&gt;
==Sequential Solution==&lt;br /&gt;
&lt;br /&gt;
We recommend implementing a sequential solution before moving on to parallel solutions. In order to do this, please modify the &amp;lt;code&amp;gt;countSequential&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
&lt;br /&gt;
Hint: maybe some loops might be best for counting things?&lt;br /&gt;
&lt;br /&gt;
==Parallel Solution==&lt;br /&gt;
&lt;br /&gt;
You need to implement two different parallel solutions to this problem. The first will involve splitting the array into two equal halves, then going through each half of the array in parallel. The second will involve splitting the array into n different pieces, then going through each of those pieces of the array in parallel.&lt;br /&gt;
 &lt;br /&gt;
In order to start with then two equal halves solution, please modify the &amp;lt;code&amp;gt;countParallelUpperLowerSplit&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: don’t forget the finish block! The format will be very similar to the examples.&lt;br /&gt;
&lt;br /&gt;
After you’re finished with that, please modify the &amp;lt;code&amp;gt;countParallelNWaySplit&amp;lt;/code&amp;gt; method for the n different pieces solution. As before, when you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: make an array to store the results of each task. Split the array into n different chunks, each of which contains 1/n elements. Once each task has summed up the results from its chunk, add the results from each chunk to get your final answer.&lt;br /&gt;
&lt;br /&gt;
=Running Your Solution=&lt;br /&gt;
&lt;br /&gt;
Habanero requires a special VM argument.  Running your solution the first time will automatically place what you need into the copy buffer.  Follow [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f16//javaagent/index.html these steps] to give Habanero what it wants.&lt;br /&gt;
 &lt;br /&gt;
If you need any further help or clarification, please don’t hesitate to post to piazza and/or reach out to one of the instructors.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
* Correct calculateMidpoint (10)&lt;br /&gt;
* Correct countSequential (20)&lt;br /&gt;
* Correct countParallelUpperLowerSplit (20)&lt;br /&gt;
* Correct countParallelNWaySplit (40)&lt;br /&gt;
* Clarity and efficiency (10)&lt;br /&gt;
&lt;br /&gt;
=Optional Reading=&lt;br /&gt;
*https://en.wikipedia.org/wiki/DNA&lt;br /&gt;
*https://en.wikipedia.org/wiki/FASTA_format&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=251</id>
		<title>Nucleobase Counting</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=251"/>
		<updated>2017-08-31T18:26:49Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
For this assignment, you will be writing sequential and parallel code to count nucleobases in a human X chromosome.&lt;br /&gt;
 &lt;br /&gt;
DNA is made up of four nucleobases: cytosine, guanine, adenine, and thymine. A strand of DNA can thus be represented as a string of letters representing these nucleobases, for example: “ACCGCATAAAGTCC.” However, DNA sequencing is typically not 100% accurate, so some of the nucleobases are not read with high certainty. These bases can be represented as an “N.” A sequence then might look something like “NCCGCATNAAGTCC.” Your goal is to write code that counts the number of unknown nucleobases.&lt;br /&gt;
 &lt;br /&gt;
We will be using actual data pulled from the US National Library of Medicine, a database maintained by the National Institute of Health. We have already provided you the code that you need to access the chromosome from the database and check your work. You must implement a sequential solution and two parallel solutions to count the given bases in these sequences.&lt;br /&gt;
&lt;br /&gt;
For some more optional background on DNA and nucleotide bases, please refer to the links under Optional Reading.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You will find the starting point for this assignment is in the count folder.  In the count.assignment package you will find NucleobaseCounting.java.&lt;br /&gt;
&lt;br /&gt;
==calculateMidpoint==&lt;br /&gt;
&lt;br /&gt;
In this method, you will need to calculate the midpoint between two numbers. This is as simple as finding the average between the two numbers. There is no need to worry abuot rounding correctly, just drop everything after the decimal point if the midpoint is not automatically an int.&lt;br /&gt;
&lt;br /&gt;
==Sequential Solution==&lt;br /&gt;
&lt;br /&gt;
We recommend implementing a sequential solution before moving on to parallel solutions. In order to do this, please modify the &amp;lt;code&amp;gt;countSequential&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
&lt;br /&gt;
Hint: maybe some loops might be best for counting things?&lt;br /&gt;
&lt;br /&gt;
==Parallel Solution==&lt;br /&gt;
&lt;br /&gt;
You need to implement two different parallel solutions to this problem. The first will involve splitting the array into two equal halves, then going through each half of the array in parallel. The second will involve splitting the array into n different pieces, then going through each of those pieces of the array in parallel.&lt;br /&gt;
 &lt;br /&gt;
In order to start with then two equal halves solution, please modify the &amp;lt;code&amp;gt;countParallelUpperLowerSplit&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: don’t forget the finish block! The format will be very similar to the examples.&lt;br /&gt;
&lt;br /&gt;
After you’re finished with that, please modify the &amp;lt;code&amp;gt;countParallelNWaySplit&amp;lt;/code&amp;gt; method for the n different pieces solution. As before, when you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: make an array to store the results of each task. Split the array into n different chunks, each of which contains 1/n elements. Once each task has summed up the results from its chunk, add the results from each chunk to get your final answer.&lt;br /&gt;
&lt;br /&gt;
=Running Your Solution=&lt;br /&gt;
&lt;br /&gt;
Habanero requires a special VM argument.  Running your solution the first time will automatically place what you need into the copy buffer.  Follow [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f16//javaagent/index.html these steps] to give Habanero what it wants.&lt;br /&gt;
 &lt;br /&gt;
If you need any further help or clarification, please don’t hesitate to post to piazza and/or reach out to one of the instructors.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
* Correct calculateMidpoint (10)&lt;br /&gt;
* Correct countSequential (20)&lt;br /&gt;
* Correct countParallelUpperLowerSplit (20)&lt;br /&gt;
* Correct countParallelNWaySplit (40)&lt;br /&gt;
* Clarity and efficiency (10)&lt;br /&gt;
&lt;br /&gt;
=Optional Reading=&lt;br /&gt;
*https://en.wikipedia.org/wiki/DNA&lt;br /&gt;
*https://en.wikipedia.org/wiki/FASTA_format&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=202</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=202"/>
		<updated>2017-08-23T17:34:25Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Studios and Assignments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci | Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]]&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#*Studio: [[PageRank]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[ConnectFour]]&lt;br /&gt;
#*Studio: [[Locking | Lock Ordering]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking | All or Nothing]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Course Setup=&lt;br /&gt;
&lt;br /&gt;
We will use educational videos made by Rice University as prep work for the course. Sign up for an account [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/course/ here.]&lt;br /&gt;
&lt;br /&gt;
You will also need to set up some software for the course. Refer to the articles below for help.&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
Grading breakdown:&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=K_Mer_Counting_Assignment&amp;diff=212</id>
		<title>K Mer Counting Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=K_Mer_Counting_Assignment&amp;diff=212"/>
		<updated>2017-08-18T21:56:03Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
The term k-mer refers to a substring of length k and k-mer counting refers to the process of finding the number of occurrences of a k-mer in a given string. This computational problem has many real-world applications, the most notable being in the field of computational genomics. In this assignment, you will design a program that will ultimately take in a human X-chromosome and count the number of k-mers in the string of DNA. You will be making use of everything you have learned thus far, including atomic variables. It is useful to know that given a string of length n, the amount of possible k-mers is equal to '''n - k + 1'''.&lt;br /&gt;
&lt;br /&gt;
=Breakdown=&lt;br /&gt;
&lt;br /&gt;
This assignment is broken into in-class studios, demos, and a take-home assignment. For this assignment, you will create a k-mer counting program using several different data structures. Links to the documentation for all of the &amp;lt;code&amp;gt;java.util.concurrent&amp;lt;/code&amp;gt; data types can be found below.&lt;br /&gt;
&lt;br /&gt;
[https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html ConcurrentHashMap] and [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicIntegerArray.html AtomicIntegerArray].&lt;br /&gt;
&lt;br /&gt;
=Warmups=&lt;br /&gt;
&lt;br /&gt;
The warm-ups associated with this assignment can be found under the &amp;lt;code&amp;gt;kmer.warmup&amp;lt;/code&amp;gt; packages.&lt;br /&gt;
&lt;br /&gt;
==String HashMap Implementation==&lt;br /&gt;
&lt;br /&gt;
In this completely sequential implementation, you will have to write the parse method. The method takes in a list of arrays of bytes and a k-mer length. It should return a StringMapKmerCount (which takes in a map), a class provided to you which does exactly what its name suggests. In order to implement this method, we recommend taking a look at the KMerUtils class and more specifically the toString method, which converts a given byte array into a String in order to make it compatible with the String HashMap.&lt;br /&gt;
&lt;br /&gt;
parse should go through the amount of possible k-mers for every byte array in the list of sequences. As it goes through the bytes in the array, use the KMerUtils.toString() method to create a string to use for the HashMap. The map should take in a String as the key and an Integer as the value. We recommend using the map.compute() method and reviewing how to use lambdas.&lt;br /&gt;
&lt;br /&gt;
==String ConcurrentHashMap Implementation==&lt;br /&gt;
&lt;br /&gt;
This implementation will make your sequential String HashMap implementation into a parallel one. To do so, you will be making use of Java’s atomic version of a HashMap: a ConcurrentHashMap. Like before, you will be need to complete the parse method. You can choose to finish this method with a forall loop or a finish/async approach, which is completely up to you.&lt;br /&gt;
&lt;br /&gt;
==ByteArrayOffset Implementation==&lt;br /&gt;
&lt;br /&gt;
This parallel implementation will overlap greatly with your previous two implementations, but it will use ByteArrayOffsetKMer instead of Strings. Refer to the ByteArrayOffsetKMer class in order to get a better idea of how to implement this method and instantiate an instance of the class. The class closely resembles the Slice class you worked on earlier in the semester.&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
&lt;br /&gt;
The assignment itself can be found under the &amp;lt;code&amp;gt;kmer.assignment&amp;lt;/code&amp;gt; packages.&lt;br /&gt;
&lt;br /&gt;
==ThresholdSlices==&lt;br /&gt;
&lt;br /&gt;
This class is designed to take in a list of bytes and convert it into a list of slices. The slice class should be familiar to you from earlier in the semester, but feel free to refer back to the documentation on [[Slices]] for a quick recap. You should perform this task recursively and there are two methods you will need to implement. The createSlicesBelowThreshold method should call the addToCollectionKernel once, but the kernel should take over the recursion from there.&lt;br /&gt;
&lt;br /&gt;
In the createSlicesBelowThreshold method, you should call the recursive kernel for each sequence in the list of sequences. When defining the min and max values, keep the information mentioned in the &amp;quot;Background&amp;quot; section in mind. As for the kernel, it should add a new slice to the collection of slices once the length of the slice dips below the provided threshold, but it should otherwise split itself into two smaller slices using recursion.&lt;br /&gt;
&lt;br /&gt;
Hint: when defining the new slice, the sliceIndexId does not matter in this case.&lt;br /&gt;
&lt;br /&gt;
==Long ConcurrentHashMap Implementation==&lt;br /&gt;
&lt;br /&gt;
This parallel implementation will also overlap greatly with everything you have done previously, but instead of using Strings or SequenceSlice, we will be using Longs to represent DNA data. In order to do this, refer to the KMerUtils class, more specifically the toPackedLong method which will convert a sequence of bytes into a Long for our purposes. As the data that this implementation can take is much larger than the previous implementations, consider how to instantiate the ConcurrentHashMap in order to avoid dynamically resizing the map. KMerUtils has a method which will calculate this number for you, but think about which one to use, why you would use it, and how that would differ from simply calculating n - k + 1 yourself.&lt;br /&gt;
&lt;br /&gt;
Hint: calculatePossibleKmers and calculateSumOfAllKmers are distinct and take different input parameters. calculateSumOfAllKmers performs the n - k + 1 calculation on a list of arrays of sequences and sums the total. calculatePossibleKmers only takes the length of the k-mer (k) as the input parameter, meaning it will calculate possibilities independent of the size of the sequence. Thus, the n - k + 1 calculation would yield a value ranging from 0 (inclusive) to the result of calculatePossibleKmers (exclusive).&lt;br /&gt;
&lt;br /&gt;
==Int Array Implementation==&lt;br /&gt;
&lt;br /&gt;
Like the String HashMap implementation, this implementation should be completed sequentially. However, unlike the previous implementations, we will be using an array instead of a map. This means that you must keep in mind what size to make the array in order to instantiate it. KMerUtils has a method which will calculate this number for you, but think about which one to use, why you would use it, and how that would differ from simply calculating n - k + 1 yourself. Think of using the int array as similar to using the map, but with ints as the key/value pairs. Use KMerUtils.toPackedInt() in order to convert the sequence into an int for our purposes.&lt;br /&gt;
&lt;br /&gt;
Hint: calculatePossibleKmers and calculateSumOfAllKmers are distinct and take different input parameters. calculateSumOfAllKmers performs the n - k + 1 calculation on a list of arrays of sequences and sums the total. calculatePossibleKmers only takes the length of the k-mer (k) as the input parameter, meaning it will calculate possibilities independent of the size of the sequence. Thus, the n - k + 1 calculation would yield a value ranging from 0 (inclusive) to the result of calculatePossibleKmers (exclusive).&lt;br /&gt;
&lt;br /&gt;
==AtomicIntegerArray Implementation==&lt;br /&gt;
&lt;br /&gt;
This implementation is simply the parallel equivalent of the int array implementation. To do so, you will be making use of Java’s atomic version of an array: an AtomicIntegerArray. Like before, you will be need to complete the parse method. You can choose to finish this method with a forall loop or a finish/async approach, which is completely up to you.&lt;br /&gt;
&lt;br /&gt;
==IsolatedBucketDictionary Implementation==&lt;br /&gt;
&lt;br /&gt;
This parallel implementation will go a step beyond the previous implementations and divide entries into 1024 buckets. Although a different number of buckets can be used, we will simply stick to 1024. Every time an entry is added to the bucket dictionary, it will create a hash based on the entry's key and place the entry into one of the 1024 buckets. Because we would only need to search one bucket for an entry based on a key's hash, this mainly serves the purpose of cutting down on search time. The compute method of the IsolatedBucketDictionary should automatically compute the correct bucket for the entry, so this implementation should closely resemble the previous ConcurrentHashMap implementations. When instantiating the IsolatedBucketDictionary, we recommend making the key/value pairs a String and an Integer.&lt;br /&gt;
&lt;br /&gt;
==Open-ended K-mer Counter (AtomicReferenceArrayDictionary Implementation)==&lt;br /&gt;
&lt;br /&gt;
This implementation is extra credit and (as the name suggests) completely open-ended. Approach it however you wish!&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
* Correct ThresholdSlices (10)&lt;br /&gt;
* Correct Long ConcurrentHashMap (15)&lt;br /&gt;
* Correct Int Array (15)&lt;br /&gt;
* Correct AtomicIntegerArray (15)&lt;br /&gt;
* Correct BucketDictionaryCounter (15)&lt;br /&gt;
* Correct BucketDictionary implementation (20)&lt;br /&gt;
* Clarity and efficiency (10)&lt;br /&gt;
&lt;br /&gt;
=Research=&lt;br /&gt;
[https://en.wikipedia.org/wiki/K-mer wikipedia article on k-mers]&lt;br /&gt;
&lt;br /&gt;
paper: [https://academic.oup.com/bioinformatics/article-lookup/doi/10.1093/bioinformatics/btr011 A fast, lock-free approach for efficient parallel counting of occurrences of k-mers] (Jellyfish)&lt;br /&gt;
&lt;br /&gt;
paper: [https://peerj.com/articles/cs-94/ Multiple comparative metagenomics using multiset k-mer counting]&lt;br /&gt;
&lt;br /&gt;
[http://homolog.us/Tutorials/index.php?p=3.7&amp;amp;s=2 Collection of approaches to k-mer counting]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform Burrows–Wheeler transform]&lt;br /&gt;
&lt;br /&gt;
[http://biology.stackexchange.com/questions/45016/what-is-the-biological-significance-of-k-mer-counting Significance of k-mer Counting]&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=N-Queens/Sudoku_Assignment&amp;diff=224</id>
		<title>N-Queens/Sudoku Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=N-Queens/Sudoku_Assignment&amp;diff=224"/>
		<updated>2017-08-18T20:41:11Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
The n-queens problem is a fundamental coding puzzle which asks: how can N queens be placed on an NxN chessboard so that they cannot attack each other? In chess, a queen can move horizontally, vertically, and diagonally across the board. Thus, to solve the n-queens problem, we must effectively figure out how to place the queens in such a way that no two of them occupy the same row, column, or diagonal.&lt;br /&gt;
&lt;br /&gt;
In a similar vein, the sudoku problem has to do with solving a sudoku puzzle using a coded algorithm. A sudoku puzzle is composed of nine large squares that each contain nine smaller squares. Each of the nine smaller squares represents a number from 1 to 9 and there cannot be any duplicate numbers in a given big square. However, once a number is used in one small square, that number cannot appear again horizontally or vertically across the entire puzzle. Thus, for sudoku, we must figure out how to fill in all 81 squares while meeting these requirements.&lt;br /&gt;
&lt;br /&gt;
In this assignment, you will implement solutions to both the n-queens and sudoku problems.&lt;br /&gt;
&lt;br /&gt;
Refer to these articles regarding the [https://developers.google.com/optimization/puzzles/queens n-queens] puzzle and [http://norvig.com/sudoku.html sudoku] for more information.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for this assignment under the '''backtrack''' directory. From there, all of the classes you will need to implement can be found under &amp;lt;code&amp;gt;nqueens.assignment&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sudoku.assignment&amp;lt;/code&amp;gt;. The '''core''' directories are utility and building block classes we created for you and the '''viz''' directories are visualization apps that might help you understand your code from a visual standpoint. Take a look at these classes to get a better understanding of how to use them for your assignment.&lt;br /&gt;
&lt;br /&gt;
==N-Queens==&lt;br /&gt;
&lt;br /&gt;
There are three classes you will need to modify: &amp;lt;code&amp;gt;DefaultImmutableQueenLocations.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SequentialNQueens.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ParallelNQueens.java&amp;lt;/code&amp;gt;. Start with QueenLocations and then we recommend moving on to the sequential solution before the parallel one. Take a look at the javadocs to see what everything does and what you will need to implement.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*As QueenLocations is immutable, you will need to create a new instance of the object whenever you move on from one row to the next. This is where createNext comes in, along with the private constructor of this class.&lt;br /&gt;
*The isNextRowThreatFree method can easily be completed with a method in AbstractQueenLocations. Refer to that for help.&lt;br /&gt;
*The sequential solution uses MutableQueenLocations while the parallel solution uses your implementation of ImmutableQueenLocations. Be careful to use the correct QueenLocations class.&lt;br /&gt;
*As the name suggests, placeQueenInRow will go through the columns of the given row to check if a queen can fit in that location. If it can, it will set that value in QueenLocations. If the examined row is that last row of the board, you have found one valid solution to the n-queens problem! Update the correct parameter accordingly. Otherwise, recurse and keep going until you reach the last row.&lt;br /&gt;
*For the parallel implementation of placeQueenInRow, remember to place the async in an appropriate location. As the method is recursive, you do not want to wrap the async in a finish tightly. Rather, you want to wrap each call to the recursive method in a finish. In other words, the finish should go in the countSolutions method.&lt;br /&gt;
*The syntax for instantiating a FinishAccumulator of Integer is: &amp;lt;code&amp;gt;FinishAccumulator&amp;lt;Integer&amp;gt; acc = newIntegerFinishAccumulator(NumberReductionOperator.SUM);&amp;lt;/code&amp;gt;&lt;br /&gt;
*The syntax for using a FinishAccumulator is: &amp;lt;code&amp;gt;finish(register(acc), () -&amp;gt; { //body });&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sudoku==&lt;br /&gt;
&lt;br /&gt;
There are three classes you will need to modify: &amp;lt;code&amp;gt;DefaultImmutableSudokuPuzzle.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SquareSearchAlgorithms.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ParallelSudoku.java&amp;lt;/code&amp;gt; (we would recommend moving through these classes in this order). Take a look at the javadocs to see what everything does and what you will need to implement.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*As the SudokuPuzzle is immutable, you will need to create a new instance of the object whenever you move on from one square to the next. This is where createNext comes in, along with the private constructor of this class.&lt;br /&gt;
*The getOptions method in SudokuPuzzle should find what value the given square could represent by searching the value of its peers (same row, same column, and same larger square). Starting with ALL_OPTIONS, the number of options should be removed depending on the peer. If the square is already filled in, it should simply return the correct value.&lt;br /&gt;
*The getValue method is already done for you, but it might come in useful for a later portion of the assignment.&lt;br /&gt;
*Your solvers should be able to handle two different approaches to solving the puzzle: row major and fewest options first. Row major just means brute forcing your way through the puzzle row by row, while fewest options first means solving the puzzle in the order of which squares has the fewest options.&lt;br /&gt;
**The row major approach is already done for you&lt;br /&gt;
**For fewest options first, go through every square (you can do this by calling &amp;lt;code&amp;gt;Square.values()&amp;lt;/code&amp;gt;) and see how many options are available for each square. Return the square with the minimal number of options. However, check to make sure the puzzle is not already completed or that you are returning already filled squares.&lt;br /&gt;
*Just like n-queens, your solveKernel is the recursive method that will be called in the solve method. Again, watch where you put your asyncs and finishes.&lt;br /&gt;
*In your solveKernel method, you should use your desired search algorithm (row major or fewest options first) to select which square you will fill. After selecting a square, you should recursively call the kernel to check every viable option in the context of the puzzle. If there are no more unfilled squares, you should set the value of the solution to the finished puzzle and exit out of the recursion.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
N-Queens subtotal: 40&lt;br /&gt;
* Correct ImmutableQueenLocations (10)&lt;br /&gt;
* Correct sequential implementation (10)&lt;br /&gt;
* Correct parallel implementation (20)&lt;br /&gt;
&lt;br /&gt;
Sudoku subtotal: 50&lt;br /&gt;
* Correct ImmutableSudokuPuzzle (10)&lt;br /&gt;
* Correct SquareSearchAlgorithm (15)&lt;br /&gt;
* Correct ParallelSudoku (25)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=217</id>
		<title>Nucleobase Counting</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=217"/>
		<updated>2017-08-18T20:34:20Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Rubric */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
For this assignment, you will be writing sequential and parallel code to count nucleobases in a human X chromosome.&lt;br /&gt;
 &lt;br /&gt;
DNA is made up of four nucleobases: cytosine, guanine, adenine, and thymine. A strand of DNA can thus be represented as a string of letters representing these nucleobases, for example: “ACCGCATAAAGTCC.” However, DNA sequencing is typically not 100% accurate, so some of the nucleobases are not read with high certainty. These bases can be represented as an “N.” A sequence then might look something like “NCCGCATNAAGTCC.” Your goal is to write code that counts the number of unknown nucleobases.&lt;br /&gt;
 &lt;br /&gt;
We will be using actual data pulled from the US National Library of Medicine, a database maintained by the National Institute of Health. We have already provided you the code that you need to access the chromosome from the database and check your work. You must implement a sequential solution and two parallel solutions to count the given bases in these sequences.&lt;br /&gt;
&lt;br /&gt;
For some more optional background on DNA and nucleotide bases, please refer to the links under Optional Reading.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You will find the starting point for this assignment is in the count folder.  In the count.assignment package you will find NucleobaseCounting.java. &lt;br /&gt;
&lt;br /&gt;
==Sequential Solution==&lt;br /&gt;
&lt;br /&gt;
We recommend implementing a sequential solution before moving on to parallel solutions. In order to do this, please modify the &amp;lt;code&amp;gt;countSequential&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
&lt;br /&gt;
Hint: maybe some loops might be best for counting things?&lt;br /&gt;
&lt;br /&gt;
==Parallel Solution==&lt;br /&gt;
&lt;br /&gt;
You need to implement two different parallel solutions to this problem. The first will involve splitting the array into two equal halves, then going through each half of the array in parallel. The second will involve splitting the array into n different pieces, then going through each of those pieces of the array in parallel.&lt;br /&gt;
 &lt;br /&gt;
In order to start with then two equal halves solution, please modify the &amp;lt;code&amp;gt;countParallelUpperLowerSplit&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: don’t forget the finish block! The format will be very similar to the examples.&lt;br /&gt;
&lt;br /&gt;
After you’re finished with that, please modify the &amp;lt;code&amp;gt;countParallelNWaySplit&amp;lt;/code&amp;gt; method for the n different pieces solution. As before, when you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: make an array to store the results of each task. Split the array into n different chunks, each of which contains 1/n elements. Once each task has summed up the results from its chunk, add the results from each chunk to get your final answer.&lt;br /&gt;
&lt;br /&gt;
=Running Your Solution=&lt;br /&gt;
&lt;br /&gt;
Habanero requires a special VM argument.  Running your solution the first time will automatically place what you need into the copy buffer.  Follow [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f16//javaagent/index.html these steps] to give Habanero what it wants.&lt;br /&gt;
 &lt;br /&gt;
If you need any further help or clarification, please don’t hesitate to post to piazza and/or reach out to one of the instructors.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
* Correct calculateMidpoint (10)&lt;br /&gt;
* Correct countSequential (20)&lt;br /&gt;
* Correct countParallelUpperLowerSplit (20)&lt;br /&gt;
* Correct countParallelNWaySplit (40)&lt;br /&gt;
* Clarity and efficiency (10)&lt;br /&gt;
&lt;br /&gt;
=Optional Reading=&lt;br /&gt;
*https://en.wikipedia.org/wiki/DNA&lt;br /&gt;
*https://en.wikipedia.org/wiki/FASTA_format&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=228</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=228"/>
		<updated>2017-08-18T20:32:48Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Rubric */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In the following studios, you will use your knowledge of Java to create your own implementation of a '''SinglyLinkedList''', a '''Map''', and a '''HashMap'''. If you are not sure what a list or a map is, please refer to the relevant documentation to familiarize yourself with these data structures. This studio is designed to make sure you have a firm grasp on Java’s data structures.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''rundown''' directory. Go into the '''core''' packages and take a look at &amp;lt;code&amp;gt;SimpleList.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SimpleMap.java&amp;lt;/code&amp;gt;. These are the interfaces you must implement in &amp;lt;code&amp;gt;StudentSimpleSinglyLinkedList.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentSimpleMap.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;StudentSimpleHashMap.java&amp;lt;/code&amp;gt;. StudentSimpleSinglyLinkedList, as the name suggests, will be your implementation of a singly linked list. StudentSimpleMap will be your implementation of a very simple map, while StudentSimpleHashMap will use an entry’s key to place an entry into one of several buckets. If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleSinglyLinkedList==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to either of the two maps as the maps will use your list. The only class you have to modify is &amp;lt;code&amp;gt;StudentSimpleSinglyLinkedList.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class. Refer to the associated SimpleList interface in order to see descriptions of what each method should do and then get started! Alternatively, you can hover your mouse over the name of the method and the javadocs should pop up for you. All of this should look extremely familiar from CSE 131.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Remember to update your next reference and size when inserting and deleting.&lt;br /&gt;
*The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
*While you do not have to use StudentListIterator to correctly implement all of the methods, feel free to do so as it might make your life easier. If you are not familiar with iterators, we recommend at least attempting this in order to familiarize yourself with them.&lt;br /&gt;
*For the getValueAt method, remember to account for when the user attempts to feed an index value that is less than zero or greater than size. Refer to the javadocs for more detail, but it should return null and not throw an exception for such a scenario.&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleMap==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to StudentSimpleHashMap. Otherwise, the only class you have to modify for this section of the studio is &amp;lt;code&amp;gt;StudentSimpleMap.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the list is equivalent to the size of the map.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
*The tests for this package test both StudentSimpleMap and StudentSimpleHashMap, so do not worry if you are failing the tests if you haven’t implemented HashMap yet.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleHashMap==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. In this class, you will use the entry’s key’s hashcode to determine which of 1024 buckets it should fall into. The reasoning for why we do this is explained under “Where to Start.” In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*This class extends StudentSimpleMap, meaning it is a subclass of the simple map. However, you will have to override the previous method implementations to account for multiple buckets.&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the map is equal to the size of the sum of the 1024 buckets, with each bucket containing one list.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to create the method.&lt;br /&gt;
*The tests for this package test both StudentSimpleMap and StudentSimpleHashMap, so do not worry if you are failing the tests if you haven’t implemented HashMap yet.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
List subtotal: 40&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct putAtFront (7.5)&lt;br /&gt;
* Correct remove (7.5)&lt;br /&gt;
* Correct getValueAt (10)&lt;br /&gt;
* Correct getIndexOf (10)&lt;br /&gt;
&lt;br /&gt;
Map subtotal: 50&lt;br /&gt;
* Correct size (2.5)&lt;br /&gt;
* Correct isEmpty (2.5)&lt;br /&gt;
* Correct put (10)&lt;br /&gt;
* Correct remove (10)&lt;br /&gt;
* Correct get (10)&lt;br /&gt;
* Correct compute (15)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MapReduce_Frameworks_Lab&amp;diff=206</id>
		<title>MapReduce Frameworks Lab</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MapReduce_Frameworks_Lab&amp;diff=206"/>
		<updated>2017-08-18T20:31:18Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
As the name suggests, MapReduce refers to the process of mapping then reducing some stream of data. At its core, all a MapReduce algorithm entails is transforming a list of one kind of item before collecting those items and reducing them down to a single value using some computation. As you can probably tell, the concept of MapReduce is extremely general and can apply to a wide berth of problems. In this assignment, we will use MapReduce to simulate the Facebook mutual friends algorithm (finding the number of mutual friends between two people) and word count algorithm. As studios, you will use MapReduce to find which infected well(s) is causing an outbreak of cholera in historic London and to map a deck of cards.&lt;br /&gt;
&lt;br /&gt;
For more information on the general concept of MapReduce, refer to [https://stackoverflow.com/questions/28982/simple-explanation-of-mapreduce this] article.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for this assignment under the '''mapreduce''' directory. From there, all of the classes you will need to implement can be found under &amp;lt;code&amp;gt;mapreduce.assignment&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;mapreduce.studio&amp;lt;/code&amp;gt;. The '''core''' directories are utility and building block classes we created for you and the '''viz''' directories are visualization apps that might help you understand your code from a visual standpoint. Take a look at these classes to get a better understanding of how to use them for your assignment.&lt;br /&gt;
&lt;br /&gt;
==Cards MapReduce Studio==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;CardMapper.java&amp;lt;/code&amp;gt; class and look at the map method. In this part of the studio, you are going to create a mapper for a given deck of cards. The mapper should accept a card’s suit and numeric value through the use of a BiConsumer. Iterate through all of the cards in the given deck and ensure they are valid cards. If they are, then map them!&lt;br /&gt;
&lt;br /&gt;
Hint: the &amp;lt;code&amp;gt;Rank&amp;lt;/code&amp;gt; class has a useful method that checks whether a card is valid.&lt;br /&gt;
&lt;br /&gt;
==Cholera MapReduce Studio==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;CholeraMapper.java&amp;lt;/code&amp;gt; class and look at the map method. In this part of the studio, you will attempt to find which water pumps are infected with cholera based on a given location of a reported case. You will do this by checking which specific WaterPump is closest to a given location and map that value to a BiConsumer. The BiConsumer will accept two arguments: the closest WaterPump and the number of occurrences to add onto the map. To find the closest WaterPump, you should go through a database of all available water pumps and compare the distances between the pumps and the location.&lt;br /&gt;
&lt;br /&gt;
Hint: there are some useful methods in the WaterPump and Location classes that might help you with the studio.&lt;br /&gt;
&lt;br /&gt;
==Mutual Friends MapReduce Assignment==&lt;br /&gt;
&lt;br /&gt;
The goal of this implementation is to create Facebook’s mutual friends algorithm using MapReduce. To accomplish this, you will need to create the mapper yourself, but the reducer has been provided to you. Navigate to the &amp;lt;code&amp;gt;MutualFriendsMapper.java&amp;lt;/code&amp;gt; class. In this class, you will specifically define how the framework accomplishes the map method.&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the map method. In this method, you will need to map every combination of the account holder to his/her friends. In order to do this, create ordered pairs of the given account’s ID and the IDs of the account holder’s friends. You must then feed each individual ordered pair into the keyValuePairConsumer along with the full set of the account holder’s friends.&lt;br /&gt;
&lt;br /&gt;
Hint: check out the methods in the Account class for help.&lt;br /&gt;
&lt;br /&gt;
==Word Count MapReduce Assignment==&lt;br /&gt;
&lt;br /&gt;
The goal of this implementation is to count the number of times a word appears in a given text, using MapReduce. To accomplish this, you will need to create both the mapper and the reducer. Navigate to the &amp;lt;code&amp;gt;WordCountMapper.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;IntegerSumClassicReducer.java&amp;lt;/code&amp;gt; classes. You will specifically define how the framework accomplishes the map and reduce methods.&lt;br /&gt;
&lt;br /&gt;
===WordCountMapper===&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the map method. In this method, you need to record every instance of a given word and feed it into the keyValuePairConsumer. To do this, access all of the words in the TextSection and if the length of the word is greater than zero (meaning it is not just blank space), convert it into lower-case and accept it into the consumer.&lt;br /&gt;
&lt;br /&gt;
Hint: Look at the methods in TextSection and the toLowerCase() method for strings for assistance.&lt;br /&gt;
&lt;br /&gt;
===IntegerSumClassicReducer===&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the apply method. All you need to do is sum up the value of a list of integers and return that sum value.&lt;br /&gt;
&lt;br /&gt;
==Simple MapReduce Framework==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;SimpleMapReduceFramework.java&amp;lt;/code&amp;gt; class and there will be three methods for you to complete: mapAll, accumulateAll, and finishAll. These frameworks are meant to be extremely general and applied to more specific uses of MapReduce.&lt;br /&gt;
&lt;br /&gt;
===mapAll Method===&lt;br /&gt;
&lt;br /&gt;
With this method, you will map all of the elements of an array of data into a new array of equivalent size consisting of a list of key value pairs. In order to do this, you must define the map() method for the mapper by specifying that it should add a new key value pair to a previously empty list. This list should then be added to the array of lists you previously defined, therefore completing the mapping stage of MapReduce. This should all be done in parallel.&lt;br /&gt;
&lt;br /&gt;
Hint: if you are creating an array of lists equivalent in size to the original array, your lists should probably consist of just one item.&lt;br /&gt;
&lt;br /&gt;
===accumulateAll Method===&lt;br /&gt;
&lt;br /&gt;
This middle step is often excluded in more advanced MapReduce applications. When run in parallel, it is the only step of the framework that must be completed sequentially. In the matrix framework implementation, we will do away with this step altogether for the sake of performance.&lt;br /&gt;
&lt;br /&gt;
In this method, you will take in the array of lists you previously created and accumulate the key value pairs in the lists into a newly defined map. Unlike the mapping phase, the map must account for the possibility of duplicates. To help deal with this issue, you must make use of the Collector provided to you. More specifically, access the accumulator in the collector by calling the &amp;lt;code&amp;gt;accumulator()&amp;lt;/code&amp;gt; method and accept the key/value pair when you add it to the map. You probably noticed that the method must return a map of &amp;lt;K, A&amp;gt;, which differs from the &amp;lt;K, V&amp;gt; generics fed into the method. The framework is designed this way as the data originally fed into the mapping stage can be turned into a different form of data before reaching the reduce stage. Although we will not do this with any of our implementations, we designed the framework to allow this. In order to access the correct value for the map if the key has no associated value yet, use the supplier associated with the Collector with the &amp;lt;code&amp;gt;supplier()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
Hint: Look into the &amp;lt;code&amp;gt;compute()&amp;lt;/code&amp;gt; method for maps.&lt;br /&gt;
&lt;br /&gt;
===finishAll Method===&lt;br /&gt;
&lt;br /&gt;
This final step reduces the accumulated data and returns the final map in its reduced form. Again, you may notice that the method returns a map of &amp;lt;K, R&amp;gt; instead of the &amp;lt;K, A&amp;gt; which was returned in the accumulateAll method. This happens for the exact same reason as the accumulateAll method, as the framework is designed to handle cases in which the reduced data differs in type from the accumulated data.&lt;br /&gt;
&lt;br /&gt;
To reduce the data down, use the map returned from the accumulateAll stage and put the results of the reduction into a new map. The provided Collector will come in extremely handy for this stage, more specifically the finisher which can be called using the &amp;lt;code&amp;gt;finisher()&amp;lt;/code&amp;gt; method. This step should run in parallel and will probably be the easiest of the three methods.&lt;br /&gt;
&lt;br /&gt;
Hint: Use the &amp;lt;code&amp;gt;entrySet()&amp;lt;/code&amp;gt; method to get all of the entries in the given map and remember to use a ConcurrentHashMap instead of a regular HashMap to ensure the method can run in parallel.&lt;br /&gt;
&lt;br /&gt;
==Matrix MapReduce Framework==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;MatrixMapReduceFramework.java&amp;lt;/code&amp;gt; class and there will be two methods for you to complete: mapAndAccumulateAll and combineAndFinishAll. These frameworks are meant to be extremely general and applied to more specific uses of MapReduce.&lt;br /&gt;
&lt;br /&gt;
The matrix framework is much more complex than the simple framework, but it boosts performance by grouping the map and accumulate stages so that everything can run in parallel. It does so by slicing up the given data into the specified mapTaskCount number of slices and assigns a reduce task number to each entry using the provided getReduceIndex() method. This, in effect, creates a matrix of maps, hence the name of the framework. In the combineAndFinishAll stage, the matrix comes in handy by allowing us to go directly down the matrix (as each key is essentially grouped into a bucket), combining and reducing elements all-in-one. This concept was explained in more depth during class.&lt;br /&gt;
&lt;br /&gt;
===mapAndAccumulateAll===&lt;br /&gt;
&lt;br /&gt;
In this stage, you will map and accumulate a given array of data into a matrix of maps. This method should run in parallel while combining the map and accumulate portions of the simple framework (which we recommend you attempt first). As mentioned previously, the input should be sliced into a mapTaskCount number of slices and then mapped/accumulated into its rightful spot in the matrix. Although you can slice up the data into chunks yourself, we recommend using the &amp;lt;code&amp;gt;Slice&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Slices&amp;lt;/code&amp;gt; classes introduced earlier in the course.&lt;br /&gt;
&lt;br /&gt;
For each slice, the mapper should map the input into its rightful spot in the matrix and accumulate it into that specific map. Essentially, you will need to nestle the actions of the accumulate method into the mapper. In order to find where the input should go in the matrix, remember that each slice keeps track of its position relative to the other slices and the getReduceIndex method, mentioned above.&lt;br /&gt;
&lt;br /&gt;
Hint: The number of rows should match the number of slices.&lt;br /&gt;
&lt;br /&gt;
===combineAndFinishAll===&lt;br /&gt;
&lt;br /&gt;
In this stage, you will take the matrix you just completed and combine all of the separate rows down to one array. Afterward, you will convert this combined array of maps into one final map. This method should run in parallel.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, you should go directly down the matrix to access the same bucket across the different slices you created in the mapAndAccumulateAll step. For all of the maps in a column, you should go through each entry and combine it down into one row. You will need to make use of the Collector’s finisher again, but you will also need to make use of the combiner. You can access the Collector’s combiner using the &amp;lt;code&amp;gt;combiner()&amp;lt;/code&amp;gt; method. Although the combine step differs from the simple framework, the finish step should mirror what you did previously.&lt;br /&gt;
&lt;br /&gt;
Hint: You can use the provided MultiWrapMap class to return the final row as a valid output. You should also combine before you finish.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
Mutual friends subtotal: 10&lt;br /&gt;
* Correct mapper (10)&lt;br /&gt;
&lt;br /&gt;
Word count subtotal: 15&lt;br /&gt;
* Correct mapper (10)&lt;br /&gt;
* Correct reducer (5)&lt;br /&gt;
&lt;br /&gt;
Simple framework subtotal: 25&lt;br /&gt;
* Correct mapAll (5)&lt;br /&gt;
* Correct accumulateAll (10)&lt;br /&gt;
* Correct finishAll (10)&lt;br /&gt;
&lt;br /&gt;
Matrix framework subtotal: 40&lt;br /&gt;
* Correct mapAndAccumulateAll (20)&lt;br /&gt;
* Correct combineAndFinishAll (20)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* Clarity and efficiency (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=227</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=227"/>
		<updated>2017-08-18T20:22:27Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Rubric */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In the following studios, you will use your knowledge of Java to create your own implementation of a '''SinglyLinkedList''', a '''Map''', and a '''HashMap'''. If you are not sure what a list or a map is, please refer to the relevant documentation to familiarize yourself with these data structures. This studio is designed to make sure you have a firm grasp on Java’s data structures.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''rundown''' directory. Go into the '''core''' packages and take a look at &amp;lt;code&amp;gt;SimpleList.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SimpleMap.java&amp;lt;/code&amp;gt;. These are the interfaces you must implement in &amp;lt;code&amp;gt;StudentSimpleSinglyLinkedList.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentSimpleMap.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;StudentSimpleHashMap.java&amp;lt;/code&amp;gt;. StudentSimpleSinglyLinkedList, as the name suggests, will be your implementation of a singly linked list. StudentSimpleMap will be your implementation of a very simple map, while StudentSimpleHashMap will use an entry’s key to place an entry into one of several buckets. If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleSinglyLinkedList==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to either of the two maps as the maps will use your list. The only class you have to modify is &amp;lt;code&amp;gt;StudentSimpleSinglyLinkedList.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class. Refer to the associated SimpleList interface in order to see descriptions of what each method should do and then get started! Alternatively, you can hover your mouse over the name of the method and the javadocs should pop up for you. All of this should look extremely familiar from CSE 131.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Remember to update your next reference and size when inserting and deleting.&lt;br /&gt;
*The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
*While you do not have to use StudentListIterator to correctly implement all of the methods, feel free to do so as it might make your life easier. If you are not familiar with iterators, we recommend at least attempting this in order to familiarize yourself with them.&lt;br /&gt;
*For the getValueAt method, remember to account for when the user attempts to feed an index value that is less than zero or greater than size. Refer to the javadocs for more detail, but it should return null and not throw an exception for such a scenario.&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleMap==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to StudentSimpleHashMap. Otherwise, the only class you have to modify for this section of the studio is &amp;lt;code&amp;gt;StudentSimpleMap.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the list is equivalent to the size of the map.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
*The tests for this package test both StudentSimpleMap and StudentSimpleHashMap, so do not worry if you are failing the tests if you haven’t implemented HashMap yet.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleHashMap==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. In this class, you will use the entry’s key’s hashcode to determine which of 1024 buckets it should fall into. The reasoning for why we do this is explained under “Where to Start.” In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*This class extends StudentSimpleMap, meaning it is a subclass of the simple map. However, you will have to override the previous method implementations to account for multiple buckets.&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the map is equal to the size of the sum of the 1024 buckets, with each bucket containing one list.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to create the method.&lt;br /&gt;
*The tests for this package test both StudentSimpleMap and StudentSimpleHashMap, so do not worry if you are failing the tests if you haven’t implemented HashMap yet.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
List subtotal: 40&lt;br /&gt;
* Complete size (2.5)&lt;br /&gt;
* Complete isEmpty (2.5)&lt;br /&gt;
* Complete putAtFront (7.5)&lt;br /&gt;
* Complete remove (7.5)&lt;br /&gt;
* Complete getValueAt (10)&lt;br /&gt;
* Complete getIndexOf (10)&lt;br /&gt;
&lt;br /&gt;
Map subtotal: 50&lt;br /&gt;
* Complete size (2.5)&lt;br /&gt;
* Complete isEmpty (2.5)&lt;br /&gt;
* Complete put (10)&lt;br /&gt;
* Complete remove (10)&lt;br /&gt;
* Complete get (10)&lt;br /&gt;
* Complete compute (15)&lt;br /&gt;
&lt;br /&gt;
Whole project:&lt;br /&gt;
* General style (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=226</id>
		<title>Iterator, Collection, and Map</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Iterator,_Collection,_and_Map&amp;diff=226"/>
		<updated>2017-08-18T20:21:53Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In the following studios, you will use your knowledge of Java to create your own implementation of a '''SinglyLinkedList''', a '''Map''', and a '''HashMap'''. If you are not sure what a list or a map is, please refer to the relevant documentation to familiarize yourself with these data structures. This studio is designed to make sure you have a firm grasp on Java’s data structures.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''rundown''' directory. Go into the '''core''' packages and take a look at &amp;lt;code&amp;gt;SimpleList.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SimpleMap.java&amp;lt;/code&amp;gt;. These are the interfaces you must implement in &amp;lt;code&amp;gt;StudentSimpleSinglyLinkedList.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentSimpleMap.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;StudentSimpleHashMap.java&amp;lt;/code&amp;gt;. StudentSimpleSinglyLinkedList, as the name suggests, will be your implementation of a singly linked list. StudentSimpleMap will be your implementation of a very simple map, while StudentSimpleHashMap will use an entry’s key to place an entry into one of several buckets. If you have not taken CSE 247, this might not make as much sense. In short, these buckets exist to cut down the runtime of searching for entries within the map, as it is much quicker to search 1/total number of buckets than one large bucket which contains every entry.&lt;br /&gt;
&lt;br /&gt;
Throughout the process, refer to the associated tests to check your progress. Feel free to run tests individually depending on which method you are working on or run the test suite in order to run every test in the associated package.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleSinglyLinkedList==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to either of the two maps as the maps will use your list. The only class you have to modify is &amp;lt;code&amp;gt;StudentSimpleSinglyLinkedList.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class. Refer to the associated SimpleList interface in order to see descriptions of what each method should do and then get started! Alternatively, you can hover your mouse over the name of the method and the javadocs should pop up for you. All of this should look extremely familiar from CSE 131.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*Remember to update your next reference and size when inserting and deleting.&lt;br /&gt;
*The “head” is a sentinel node, meaning its sole purpose is to point its next reference to the true first node of the list. It should always maintain a value of null and you should never change its value.&lt;br /&gt;
*While you do not have to use StudentListIterator to correctly implement all of the methods, feel free to do so as it might make your life easier. If you are not familiar with iterators, we recommend at least attempting this in order to familiarize yourself with them.&lt;br /&gt;
*For the getValueAt method, remember to account for when the user attempts to feed an index value that is less than zero or greater than size. Refer to the javadocs for more detail, but it should return null and not throw an exception for such a scenario.&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleMap==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. If you are already familiar with buckets and maps and wish to skip this implementation, then feel free to go straight to StudentSimpleHashMap. Otherwise, the only class you have to modify for this section of the studio is &amp;lt;code&amp;gt;StudentSimpleMap.java&amp;lt;/code&amp;gt;, but we recommend looking at the other classes in the package as all of them will be incorporated in this class.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the list is equivalent to the size of the map.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to author the method.&lt;br /&gt;
*The tests for this package test both StudentSimpleMap and StudentSimpleHashMap, so do not worry if you are failing the tests if you haven’t implemented HashMap yet.&lt;br /&gt;
&lt;br /&gt;
==StudentSimpleHashMap==&lt;br /&gt;
&lt;br /&gt;
You must finish StudentSimpleSinglyLinkedList before moving on to this class as the map uses your implementation of a singly linked list. In this class, you will use the entry’s key’s hashcode to determine which of 1024 buckets it should fall into. The reasoning for why we do this is explained under “Where to Start.” In order to calculate the index of the bucket that the entry belongs in, we will make use of the hash function, which in turn uses Math.floorMod to calculate a modulo (remainder or % in Java) based on the number of buckets and the key’s hashcode. We will also make use of the getListFor method, which utilizes the hash method in order to return a '''pointer''' to the correct bucket.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*This class extends StudentSimpleMap, meaning it is a subclass of the simple map. However, you will have to override the previous method implementations to account for multiple buckets.&lt;br /&gt;
*You must implement the put method before any of the others if you want your tests to work.&lt;br /&gt;
*In this implementation, the size of the map is equal to the size of the sum of the 1024 buckets, with each bucket containing one list.&lt;br /&gt;
*Be careful to return the correct value, check the javadocs or the interface to ensure your return statements are correct.&lt;br /&gt;
*For the compute method, a BiFunction is simply Java’s '''functional interface''' for something that takes in two input parameters and spits out a result. &amp;lt;code&amp;gt;? super K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;? super V&amp;lt;/code&amp;gt; indicates a class K or V extends ('''superclass'''), while &amp;lt;code&amp;gt;? extends V&amp;lt;/code&amp;gt; indicates a class that extends V ('''subclass'''). The &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; is referred to as a '''wildcard generic'''. Follow the links below for Oracle’s documentation on the topic.&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html Wildcard Guidelines]&lt;br /&gt;
**[https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html Wildcards]&lt;br /&gt;
*When writing the compute method, check the entries to see if the given key exists. If it does, use remappingFunction’s apply method to generate a new value and set it as the new value for the entry. The method should return this new value. Otherwise, if the key was not found, it should return null.&lt;br /&gt;
*Lambda expressions come in handy when using the compute method, but you will not use lambda expressions to create the method.&lt;br /&gt;
*The tests for this package test both StudentSimpleMap and StudentSimpleHashMap, so do not worry if you are failing the tests if you haven’t implemented HashMap yet.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
&lt;br /&gt;
List subtotal: 40&lt;br /&gt;
* Complete size (2.5)&lt;br /&gt;
* Complete isEmpty (2.5)&lt;br /&gt;
* Complete putAtFront (7.5)&lt;br /&gt;
* Complete remove (7.5)&lt;br /&gt;
* Complete getValueAt (10)&lt;br /&gt;
* Complete getIndexOf (10)&lt;br /&gt;
&lt;br /&gt;
Map subtotal: 50&lt;br /&gt;
* Complete size (2.5)&lt;br /&gt;
* Complete isEmpty (2.5)&lt;br /&gt;
* Complete put (10)&lt;br /&gt;
* Complete remove (10)&lt;br /&gt;
* Complete get (10)&lt;br /&gt;
* Complete compute (15)&lt;br /&gt;
&lt;br /&gt;
* General style (10)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=216</id>
		<title>Nucleobase Counting</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=216"/>
		<updated>2017-08-18T19:59:37Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Rubric */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
For this assignment, you will be writing sequential and parallel code to count nucleobases in a human X chromosome.&lt;br /&gt;
 &lt;br /&gt;
DNA is made up of four nucleobases: cytosine, guanine, adenine, and thymine. A strand of DNA can thus be represented as a string of letters representing these nucleobases, for example: “ACCGCATAAAGTCC.” However, DNA sequencing is typically not 100% accurate, so some of the nucleobases are not read with high certainty. These bases can be represented as an “N.” A sequence then might look something like “NCCGCATNAAGTCC.” Your goal is to write code that counts the number of unknown nucleobases.&lt;br /&gt;
 &lt;br /&gt;
We will be using actual data pulled from the US National Library of Medicine, a database maintained by the National Institute of Health. We have already provided you the code that you need to access the chromosome from the database and check your work. You must implement a sequential solution and two parallel solutions to count the given bases in these sequences.&lt;br /&gt;
&lt;br /&gt;
For some more optional background on DNA and nucleotide bases, please refer to the links under Optional Reading.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You will find the starting point for this assignment is in the count folder.  In the count.assignment package you will find NucleobaseCounting.java. &lt;br /&gt;
&lt;br /&gt;
==Sequential Solution==&lt;br /&gt;
&lt;br /&gt;
We recommend implementing a sequential solution before moving on to parallel solutions. In order to do this, please modify the &amp;lt;code&amp;gt;countSequential&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
&lt;br /&gt;
Hint: maybe some loops might be best for counting things?&lt;br /&gt;
&lt;br /&gt;
==Parallel Solution==&lt;br /&gt;
&lt;br /&gt;
You need to implement two different parallel solutions to this problem. The first will involve splitting the array into two equal halves, then going through each half of the array in parallel. The second will involve splitting the array into n different pieces, then going through each of those pieces of the array in parallel.&lt;br /&gt;
 &lt;br /&gt;
In order to start with then two equal halves solution, please modify the &amp;lt;code&amp;gt;countParallelUpperLowerSplit&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: don’t forget the finish block! The format will be very similar to the examples.&lt;br /&gt;
&lt;br /&gt;
After you’re finished with that, please modify the &amp;lt;code&amp;gt;countParallelNWaySplit&amp;lt;/code&amp;gt; method for the n different pieces solution. As before, when you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: make an array to store the results of each task. Split the array into n different chunks, each of which contains 1/n elements. Once each task has summed up the results from its chunk, add the results from each chunk to get your final answer.&lt;br /&gt;
&lt;br /&gt;
=Running Your Solution=&lt;br /&gt;
&lt;br /&gt;
Habanero requires a special VM argument.  Running your solution the first time will automatically place what you need into the copy buffer.  Follow [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f16//javaagent/index.html these steps] to give Habanero what it wants.&lt;br /&gt;
 &lt;br /&gt;
If you need any further help or clarification, please don’t hesitate to post to piazza and/or reach out to one of the instructors.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
As always, please make sure to cite your work appropriately.&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
* Completed calculateMidpoint (10)&lt;br /&gt;
* Completed countSequential (20)&lt;br /&gt;
* Completed countParallelUpperLowerSplit (20)&lt;br /&gt;
* Completed countParallelNWaySplit (40)&lt;br /&gt;
* General style (10)&lt;br /&gt;
&lt;br /&gt;
=Optional Reading=&lt;br /&gt;
*https://en.wikipedia.org/wiki/DNA&lt;br /&gt;
*https://en.wikipedia.org/wiki/FASTA_format&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=215</id>
		<title>Nucleobase Counting</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Nucleobase_Counting&amp;diff=215"/>
		<updated>2017-08-18T19:58:42Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Rubric */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
For this assignment, you will be writing sequential and parallel code to count nucleobases in a human X chromosome.&lt;br /&gt;
 &lt;br /&gt;
DNA is made up of four nucleobases: cytosine, guanine, adenine, and thymine. A strand of DNA can thus be represented as a string of letters representing these nucleobases, for example: “ACCGCATAAAGTCC.” However, DNA sequencing is typically not 100% accurate, so some of the nucleobases are not read with high certainty. These bases can be represented as an “N.” A sequence then might look something like “NCCGCATNAAGTCC.” Your goal is to write code that counts the number of unknown nucleobases.&lt;br /&gt;
 &lt;br /&gt;
We will be using actual data pulled from the US National Library of Medicine, a database maintained by the National Institute of Health. We have already provided you the code that you need to access the chromosome from the database and check your work. You must implement a sequential solution and two parallel solutions to count the given bases in these sequences.&lt;br /&gt;
&lt;br /&gt;
For some more optional background on DNA and nucleotide bases, please refer to the links under Optional Reading.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You will find the starting point for this assignment is in the count folder.  In the count.assignment package you will find NucleobaseCounting.java. &lt;br /&gt;
&lt;br /&gt;
==Sequential Solution==&lt;br /&gt;
&lt;br /&gt;
We recommend implementing a sequential solution before moving on to parallel solutions. In order to do this, please modify the &amp;lt;code&amp;gt;countSequential&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
&lt;br /&gt;
Hint: maybe some loops might be best for counting things?&lt;br /&gt;
&lt;br /&gt;
==Parallel Solution==&lt;br /&gt;
&lt;br /&gt;
You need to implement two different parallel solutions to this problem. The first will involve splitting the array into two equal halves, then going through each half of the array in parallel. The second will involve splitting the array into n different pieces, then going through each of those pieces of the array in parallel.&lt;br /&gt;
 &lt;br /&gt;
In order to start with then two equal halves solution, please modify the &amp;lt;code&amp;gt;countParallelUpperLowerSplit&amp;lt;/code&amp;gt; method. When you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: don’t forget the finish block! The format will be very similar to the examples.&lt;br /&gt;
&lt;br /&gt;
After you’re finished with that, please modify the &amp;lt;code&amp;gt;countParallelNWaySplit&amp;lt;/code&amp;gt; method for the n different pieces solution. As before, when you’re ready to begin, delete the return statement and begin implementing your solution! Again, please refer to your notes from lecture for help, as we tackled a very similar problem in class.&lt;br /&gt;
 &lt;br /&gt;
Hint: make an array to store the results of each task. Split the array into n different chunks, each of which contains 1/n elements. Once each task has summed up the results from its chunk, add the results from each chunk to get your final answer.&lt;br /&gt;
&lt;br /&gt;
=Running Your Solution=&lt;br /&gt;
&lt;br /&gt;
Habanero requires a special VM argument.  Running your solution the first time will automatically place what you need into the copy buffer.  Follow [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f16//javaagent/index.html these steps] to give Habanero what it wants.&lt;br /&gt;
 &lt;br /&gt;
If you need any further help or clarification, please don’t hesitate to post to piazza and/or reach out to one of the instructors.&lt;br /&gt;
&lt;br /&gt;
=Rubric=&lt;br /&gt;
&lt;br /&gt;
Total points: 100&lt;br /&gt;
* Completed calculateMidpoint (10)&lt;br /&gt;
* Completed countSequential (20)&lt;br /&gt;
* Completed countParallelUpperLowerSplit (20)&lt;br /&gt;
* Completed countParallelNWaySplit (40)&lt;br /&gt;
* Code is properly styled and cited, if applicable (10)&lt;br /&gt;
&lt;br /&gt;
=Optional Reading=&lt;br /&gt;
*https://en.wikipedia.org/wiki/DNA&lt;br /&gt;
*https://en.wikipedia.org/wiki/FASTA_format&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=245</id>
		<title>MatrixMultiply</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=245"/>
		<updated>2017-08-17T15:40:45Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* OPTIONAL_SEQ_RECURSIVE &amp;amp; OPTIONAL_PAR_RECURSIVE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
Matrix multiplication is a simple mathematical operation which we will replicate in this studio. For our purposes, we will only deal with square matrices (same number of rows and columns). However, we will approach this problem with several different parallel constructs and approaches. For those unfamiliar on how to multiply two matrices, take a look at [https://www.mathsisfun.com/algebra/matrix-multiplying.html this link] for a quick overview.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for the assignment under the '''matrix-multiply''' directory. From there, you will need to implement the &amp;lt;code&amp;gt;MatrixMultiplySolutions&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
==MatrixMultiplySolutions==&lt;br /&gt;
&lt;br /&gt;
There are three methods you will need to implement, all of which are different ways to use parallel for loops to solve the problem. To assist you, the sequential implementation has already been completed for you. We recommend starting from the top and working your way down. There is also an optional recursive implementation and a manual grouping implementation which has been done for you (this is just to demonstrate how chunking works behind the scenes).&lt;br /&gt;
&lt;br /&gt;
===FORALL_FORALL===&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will simply convert the sequential solution into a parallel one using two forall loops.&lt;br /&gt;
&lt;br /&gt;
===FORALL2D===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will cut down the syntax of the two forall implementation with the use of HJ’s &amp;lt;code&amp;gt;forall2d&amp;lt;/code&amp;gt; method. Functionally, this method serves the purpose of using two forall loops. The input parameters should equal the input parameters of the two separate forall loops. For example,&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;forall(min, max, (i) -&amp;gt; {&lt;br /&gt;
	forall(min, max, (j) -&amp;gt; doSomething());&lt;br /&gt;
});&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Would appear as &amp;lt;code&amp;gt;forall2d(min, max, min, max, (i, j) -&amp;gt; doSomething());&amp;lt;/code&amp;gt; in the forall2d syntax.&lt;br /&gt;
&lt;br /&gt;
===FORALL2D_CHUNKED===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will add a minor performance boost to the process by using the forall-chunked construct. Although similar to the traditional forall loop, it increases speedup using iteration grouping/chunking. This topic is discussed in detail in this [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/courseware/a900dd0655384de3b5ef01e508ea09d7/6349730bb2a149a0b33fa23db7afddee/?activate_block_id=i4x%3A%2F%2FRiceX%2FCOMP322%2Fsequential%2F6349730bb2a149a0b33fa23db7afddee Rice video] and explained in the [http://pasiphae.cs.rice.edu/#hjlib-for-parallelchunkediterationwithimplicitfinish HJ documentation]. There is no need to specify anything, allow the runtime to determine the chunking.&lt;br /&gt;
&lt;br /&gt;
===FORALL_GROUPED &amp;amp; FORALL2D_GROUPED===&lt;br /&gt;
&lt;br /&gt;
In this approach, we will show you how you can specify the grouping yourself and what forAllChunked is doing behind the scenes. There is no need to implement this method, this is just here to serve as a reference for you. However, you should understand the concept of iteration grouping before moving forward.&lt;br /&gt;
&lt;br /&gt;
===OPTIONAL_SEQ_RECURSIVE &amp;amp; OPTIONAL_PAR_RECURSIVE===&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will solve the matrix multiply problem sequentially and in parallel using recursion. Although this class should be able to take in a matrix of any size, try to imagine this as a 2x2 matrix in order to make it easier to solve. Once you solve the sequential method, the parallel method should look very similar with exception of an async/finish block.&lt;br /&gt;
&lt;br /&gt;
In order to obtain the desired result matrix, you will need to recursively call the correct submatrices for each of the four result submatrices. Imagining this as a 2x2 matrix, remember that the dot products of the rows of the first matrix and the columns of the second matrix create the result matrix.&lt;br /&gt;
&lt;br /&gt;
Hint: Each result submatrix should have two recursive calls, for a total of eight recursive calls.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=244</id>
		<title>MatrixMultiply</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=244"/>
		<updated>2017-08-17T15:38:35Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
Matrix multiplication is a simple mathematical operation which we will replicate in this studio. For our purposes, we will only deal with square matrices (same number of rows and columns). However, we will approach this problem with several different parallel constructs and approaches. For those unfamiliar on how to multiply two matrices, take a look at [https://www.mathsisfun.com/algebra/matrix-multiplying.html this link] for a quick overview.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for the assignment under the '''matrix-multiply''' directory. From there, you will need to implement the &amp;lt;code&amp;gt;MatrixMultiplySolutions&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
==MatrixMultiplySolutions==&lt;br /&gt;
&lt;br /&gt;
There are three methods you will need to implement, all of which are different ways to use parallel for loops to solve the problem. To assist you, the sequential implementation has already been completed for you. We recommend starting from the top and working your way down. There is also an optional recursive implementation and a manual grouping implementation which has been done for you (this is just to demonstrate how chunking works behind the scenes).&lt;br /&gt;
&lt;br /&gt;
===FORALL_FORALL===&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will simply convert the sequential solution into a parallel one using two forall loops.&lt;br /&gt;
&lt;br /&gt;
===FORALL2D===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will cut down the syntax of the two forall implementation with the use of HJ’s &amp;lt;code&amp;gt;forall2d&amp;lt;/code&amp;gt; method. Functionally, this method serves the purpose of using two forall loops. The input parameters should equal the input parameters of the two separate forall loops. For example,&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;forall(min, max, (i) -&amp;gt; {&lt;br /&gt;
	forall(min, max, (j) -&amp;gt; doSomething());&lt;br /&gt;
});&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Would appear as &amp;lt;code&amp;gt;forall2d(min, max, min, max, (i, j) -&amp;gt; doSomething());&amp;lt;/code&amp;gt; in the forall2d syntax.&lt;br /&gt;
&lt;br /&gt;
===FORALL2D_CHUNKED===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will add a minor performance boost to the process by using the forall-chunked construct. Although similar to the traditional forall loop, it increases speedup using iteration grouping/chunking. This topic is discussed in detail in this [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/courseware/a900dd0655384de3b5ef01e508ea09d7/6349730bb2a149a0b33fa23db7afddee/?activate_block_id=i4x%3A%2F%2FRiceX%2FCOMP322%2Fsequential%2F6349730bb2a149a0b33fa23db7afddee Rice video] and explained in the [http://pasiphae.cs.rice.edu/#hjlib-for-parallelchunkediterationwithimplicitfinish HJ documentation]. There is no need to specify anything, allow the runtime to determine the chunking.&lt;br /&gt;
&lt;br /&gt;
===FORALL_GROUPED &amp;amp; FORALL2D_GROUPED===&lt;br /&gt;
&lt;br /&gt;
In this approach, we will show you how you can specify the grouping yourself and what forAllChunked is doing behind the scenes. There is no need to implement this method, this is just here to serve as a reference for you. However, you should understand the concept of iteration grouping before moving forward.&lt;br /&gt;
&lt;br /&gt;
==OPTIONAL_SEQ_RECURSIVE &amp;amp; OPTIONAL_PAR_RECURSIVE==&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will solve the matrix multiply problem sequentially and in parallel using recursion. Although this class should be able to take in a matrix of any size, try to imagine this as a 2x2 matrix in order to make it easier to solve. Once you solve the sequential method, the parallel method should look very similar with exception of an async/finish block.&lt;br /&gt;
&lt;br /&gt;
In order to obtain the desired result matrix, you will need to recursively call the correct submatrices for each of the four result submatrices. Imagining this as a 2x2 matrix, remember that the dot products of the rows of the first matrix and the columns of the second matrix create the result matrix.&lt;br /&gt;
&lt;br /&gt;
Hint: Each result submatrix should have two recursive calls, for a total of eight recursive calls.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=201</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=201"/>
		<updated>2017-08-16T19:48:55Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Studios and Assignments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci | Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]] (needs update)&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#*Studio: [[PageRank]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[ConnectFour]]&lt;br /&gt;
#*Studio: [[Locking | Lock Ordering]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking | All or Nothing]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Course Setup=&lt;br /&gt;
&lt;br /&gt;
We will use educational videos made by Rice University as prep work for the course. Sign up for an account [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/course/ here.]&lt;br /&gt;
&lt;br /&gt;
You will also need to set up some software for the course. Refer to the articles below for help.&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
Grading breakdown:&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=N-Queens/Sudoku_Assignment&amp;diff=223</id>
		<title>N-Queens/Sudoku Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=N-Queens/Sudoku_Assignment&amp;diff=223"/>
		<updated>2017-08-16T19:47:31Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Sudoku */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
The n-queens problem is a fundamental coding puzzle which asks: how can N queens be placed on an NxN chessboard so that they cannot attack each other? In chess, a queen can move horizontally, vertically, and diagonally across the board. Thus, to solve the n-queens problem, we must effectively figure out how to place the queens in such a way that no two of them occupy the same row, column, or diagonal.&lt;br /&gt;
&lt;br /&gt;
In a similar vein, the sudoku problem has to do with solving a sudoku puzzle using a coded algorithm. A sudoku puzzle is composed of nine large squares that each contain nine smaller squares. Each of the nine smaller squares represents a number from 1 to 9 and there cannot be any duplicate numbers in a given big square. However, once a number is used in one small square, that number cannot appear again horizontally or vertically across the entire puzzle. Thus, for sudoku, we must figure out how to fill in all 81 squares while meeting these requirements.&lt;br /&gt;
&lt;br /&gt;
In this assignment, you will implement solutions to both the n-queens and sudoku problems.&lt;br /&gt;
&lt;br /&gt;
Refer to these articles regarding the [https://developers.google.com/optimization/puzzles/queens n-queens] puzzle and [http://norvig.com/sudoku.html sudoku] for more information.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for this assignment under the '''backtrack''' directory. From there, all of the classes you will need to implement can be found under &amp;lt;code&amp;gt;nqueens.assignment&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sudoku.assignment&amp;lt;/code&amp;gt;. The '''core''' directories are utility and building block classes we created for you and the '''viz''' directories are visualization apps that might help you understand your code from a visual standpoint. Take a look at these classes to get a better understanding of how to use them for your assignment.&lt;br /&gt;
&lt;br /&gt;
==N-Queens==&lt;br /&gt;
&lt;br /&gt;
There are three classes you will need to modify: &amp;lt;code&amp;gt;DefaultImmutableQueenLocations.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SequentialNQueens.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ParallelNQueens.java&amp;lt;/code&amp;gt;. Start with QueenLocations and then we recommend moving on to the sequential solution before the parallel one. Take a look at the javadocs to see what everything does and what you will need to implement.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*As QueenLocations is immutable, you will need to create a new instance of the object whenever you move on from one row to the next. This is where createNext comes in, along with the private constructor of this class.&lt;br /&gt;
*The isNextRowThreatFree method can easily be completed with a method in AbstractQueenLocations. Refer to that for help.&lt;br /&gt;
*The sequential solution uses MutableQueenLocations while the parallel solution uses your implementation of ImmutableQueenLocations. Be careful to use the correct QueenLocations class.&lt;br /&gt;
*As the name suggests, placeQueenInRow will go through the columns of the given row to check if a queen can fit in that location. If it can, it will set that value in QueenLocations. If the examined row is that last row of the board, you have found one valid solution to the n-queens problem! Update the correct parameter accordingly. Otherwise, recurse and keep going until you reach the last row.&lt;br /&gt;
*For the parallel implementation of placeQueenInRow, remember to place the async in an appropriate location. As the method is recursive, you do not want to wrap the async in a finish tightly. Rather, you want to wrap each call to the recursive method in a finish. In other words, the finish should go in the countSolutions method.&lt;br /&gt;
*The syntax for instantiating a FinishAccumulator of Integer is: &amp;lt;code&amp;gt;FinishAccumulator&amp;lt;Integer&amp;gt; acc = newIntegerFinishAccumulator(NumberReductionOperator.SUM);&amp;lt;/code&amp;gt;&lt;br /&gt;
*The syntax for using a FinishAccumulator is: &amp;lt;code&amp;gt;finish(register(acc), () -&amp;gt; { //body });&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sudoku==&lt;br /&gt;
&lt;br /&gt;
There are three classes you will need to modify: &amp;lt;code&amp;gt;DefaultImmutableSudokuPuzzle.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SquareSearchAlgorithms.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ParallelSudoku.java&amp;lt;/code&amp;gt; (we would recommend moving through these classes in this order). Take a look at the javadocs to see what everything does and what you will need to implement.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*As the SudokuPuzzle is immutable, you will need to create a new instance of the object whenever you move on from one square to the next. This is where createNext comes in, along with the private constructor of this class.&lt;br /&gt;
*The getOptions method in SudokuPuzzle should find what value the given square could represent by searching the value of its peers (same row, same column, and same larger square). Starting with ALL_OPTIONS, the number of options should be removed depending on the peer. If the square is already filled in, it should simply return the correct value.&lt;br /&gt;
*The getValue method is already done for you, but it might come in useful for a later portion of the assignment.&lt;br /&gt;
*Your solvers should be able to handle two different approaches to solving the puzzle: row major and fewest options first. Row major just means brute forcing your way through the puzzle row by row, while fewest options first means solving the puzzle in the order of which squares has the fewest options.&lt;br /&gt;
**The row major approach is already done for you&lt;br /&gt;
**For fewest options first, go through every square (you can do this by calling &amp;lt;code&amp;gt;Square.values()&amp;lt;/code&amp;gt;) and see how many options are available for each square. Return the square with the minimal number of options. However, check to make sure the puzzle is not already completed or that you are returning already filled squares.&lt;br /&gt;
*Just like n-queens, your solveKernel is the recursive method that will be called in the solve method. Again, watch where you put your asyncs and finishes.&lt;br /&gt;
*In your solveKernel method, you should use your desired search algorithm (row major or fewest options first) to select which square you will fill. After selecting a square, you should recursively call the kernel to check every viable option in the context of the puzzle. If there are no more unfilled squares, you should set the value of the solution to the finished puzzle and exit out of the recursion.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=N-Queens/Sudoku_Assignment&amp;diff=222</id>
		<title>N-Queens/Sudoku Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=N-Queens/Sudoku_Assignment&amp;diff=222"/>
		<updated>2017-08-16T19:42:41Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* N-Queens */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
The n-queens problem is a fundamental coding puzzle which asks: how can N queens be placed on an NxN chessboard so that they cannot attack each other? In chess, a queen can move horizontally, vertically, and diagonally across the board. Thus, to solve the n-queens problem, we must effectively figure out how to place the queens in such a way that no two of them occupy the same row, column, or diagonal.&lt;br /&gt;
&lt;br /&gt;
In a similar vein, the sudoku problem has to do with solving a sudoku puzzle using a coded algorithm. A sudoku puzzle is composed of nine large squares that each contain nine smaller squares. Each of the nine smaller squares represents a number from 1 to 9 and there cannot be any duplicate numbers in a given big square. However, once a number is used in one small square, that number cannot appear again horizontally or vertically across the entire puzzle. Thus, for sudoku, we must figure out how to fill in all 81 squares while meeting these requirements.&lt;br /&gt;
&lt;br /&gt;
In this assignment, you will implement solutions to both the n-queens and sudoku problems.&lt;br /&gt;
&lt;br /&gt;
Refer to these articles regarding the [https://developers.google.com/optimization/puzzles/queens n-queens] puzzle and [http://norvig.com/sudoku.html sudoku] for more information.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for this assignment under the '''backtrack''' directory. From there, all of the classes you will need to implement can be found under &amp;lt;code&amp;gt;nqueens.assignment&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sudoku.assignment&amp;lt;/code&amp;gt;. The '''core''' directories are utility and building block classes we created for you and the '''viz''' directories are visualization apps that might help you understand your code from a visual standpoint. Take a look at these classes to get a better understanding of how to use them for your assignment.&lt;br /&gt;
&lt;br /&gt;
==N-Queens==&lt;br /&gt;
&lt;br /&gt;
There are three classes you will need to modify: &amp;lt;code&amp;gt;DefaultImmutableQueenLocations.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SequentialNQueens.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ParallelNQueens.java&amp;lt;/code&amp;gt;. Start with QueenLocations and then we recommend moving on to the sequential solution before the parallel one. Take a look at the javadocs to see what everything does and what you will need to implement.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*As QueenLocations is immutable, you will need to create a new instance of the object whenever you move on from one row to the next. This is where createNext comes in, along with the private constructor of this class.&lt;br /&gt;
*The isNextRowThreatFree method can easily be completed with a method in AbstractQueenLocations. Refer to that for help.&lt;br /&gt;
*The sequential solution uses MutableQueenLocations while the parallel solution uses your implementation of ImmutableQueenLocations. Be careful to use the correct QueenLocations class.&lt;br /&gt;
*As the name suggests, placeQueenInRow will go through the columns of the given row to check if a queen can fit in that location. If it can, it will set that value in QueenLocations. If the examined row is that last row of the board, you have found one valid solution to the n-queens problem! Update the correct parameter accordingly. Otherwise, recurse and keep going until you reach the last row.&lt;br /&gt;
*For the parallel implementation of placeQueenInRow, remember to place the async in an appropriate location. As the method is recursive, you do not want to wrap the async in a finish tightly. Rather, you want to wrap each call to the recursive method in a finish. In other words, the finish should go in the countSolutions method.&lt;br /&gt;
*The syntax for instantiating a FinishAccumulator of Integer is: &amp;lt;code&amp;gt;FinishAccumulator&amp;lt;Integer&amp;gt; acc = newIntegerFinishAccumulator(NumberReductionOperator.SUM);&amp;lt;/code&amp;gt;&lt;br /&gt;
*The syntax for using a FinishAccumulator is: &amp;lt;code&amp;gt;finish(register(acc), () -&amp;gt; { //body });&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sudoku==&lt;br /&gt;
&lt;br /&gt;
There are three classes you will need to modify: &amp;lt;code&amp;gt;StudentImmutableSudokuPuzzle.java&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SquareSearchAlgorithms.java&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;StudentSudokuSolver.java&amp;lt;/code&amp;gt; (we would recommend moving through these classes in this order). Take a look at the javadocs to see what everything does and what you will need to implement.&lt;br /&gt;
&lt;br /&gt;
A couple of notes and common issues:&lt;br /&gt;
&lt;br /&gt;
*As the SudokuPuzzle is immutable, you will need to create a new instance of the object whenever you move on from one square to the next. This is where createNext comes in, along with the private constructor of this class.&lt;br /&gt;
*The getOptions method in SudokuPuzzle should find what value the given square could represent by searching the value of its peers (same row, same column, and same larger square). Starting with ALL_OPTIONS, the number of options should be removed depending on the peer. If the square is already filled in, it should simply return the correct value.&lt;br /&gt;
*The getValue method is already done for you, but it might come in useful for a later portion of the assignment.&lt;br /&gt;
*Your solvers should be able to handle two different approaches to solving the puzzle: row major and fewest options first. Row major just means brute forcing your way through the puzzle row by row, while fewest options first means solving the puzzle in the order of which squares has the fewest options.&lt;br /&gt;
**The row major approach is already done for you&lt;br /&gt;
**For fewest options first, go through every square (you can do this by calling &amp;lt;code&amp;gt;Square.values()&amp;lt;/code&amp;gt;) and see how many options are available for each square. Return the square with the minimal number of options. However, check to make sure the puzzle is not already completed or that you are returning already filled squares.&lt;br /&gt;
*Just like n-queens, your solveKernel is the recursive method that will be called in the solve method. Again, watch where you put your asyncs and finishes.&lt;br /&gt;
*In your solveKernel method, you should use your desired search algorithm (row major or fewest options first) to select which square you will fill. After selecting a square, you should recursively call the kernel to check every viable option in the context of the puzzle. If there are no more unfilled squares, you should set the value of the solution to the finished puzzle and exit out of the recursion.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Race_Conditions_Studio&amp;diff=248</id>
		<title>Race Conditions Studio</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Race_Conditions_Studio&amp;diff=248"/>
		<updated>2017-08-16T19:23:08Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* toCleanedWords */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In this studio, you will take in a collection of strings, clean up each string, and add it into another collection of strings concurrently. You will also take in a collection of words, assign a point value to each word, and then put it into a map. Although not terribly exciting, the point of this studio is to teach you how to avoid data races when performing concurrent tasks. In order to accomplish these tasks, you will use the ConcurrentLinkedQueue, array, and ConcurrentHashMap classes.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''data races''' directory. The &amp;lt;code&amp;gt;WordScoreDataRace.java&amp;lt;/code&amp;gt; class is the only one you will need to alter, but the &amp;lt;code&amp;gt;WordScoreUtils.java&amp;lt;/code&amp;gt; class contains useful methods that will help with the studio.&lt;br /&gt;
&lt;br /&gt;
==toCleanedWords==&lt;br /&gt;
&lt;br /&gt;
This method should take in a collection of strings, clean it, then add the strings into another collection of strings. The &amp;lt;code&amp;gt;WordScoreUtils.toCleandWords()&amp;lt;/code&amp;gt; method should come in handy for cleaning up the string. All of this should be done in parallel and you should use a ConcurrentLinkedQueue to accomplish this task.&lt;br /&gt;
&lt;br /&gt;
Hint: try using the non-concurrent equivalent and see what happens.&lt;br /&gt;
&lt;br /&gt;
==toCleanedWordsViaArray==&lt;br /&gt;
&lt;br /&gt;
This method should do the same thing as the toCleandWords method, but it should use arrays to avoid a data race.&lt;br /&gt;
Hint: use the Arrays.asList() method to turn your array result into a list so that you can return the data structure the method desires.&lt;br /&gt;
&lt;br /&gt;
==createLetterToScoreMap==&lt;br /&gt;
&lt;br /&gt;
This method should take in a collection of strings, assign a point value to the string, then put it into a map. The map should be composed of the words and their associated point values. The &amp;lt;code&amp;gt;WordScoreUtils.calculateScore()&amp;lt;/code&amp;gt; method should come in handy for assigning the correct point value for each word. If the map already contains a given word (there is a duplicate word), nothing should be done to the map.&lt;br /&gt;
&lt;br /&gt;
==createLetterToScoreMapViaArray==&lt;br /&gt;
&lt;br /&gt;
This method should do the same thing as the createLetterToScoreMap method, but it should use an array of entries to avoid a data race. To do this, the &amp;lt;code&amp;gt;EntryUtils.createEntryArray()&amp;lt;/code&amp;gt; method should come in handy. For each string within the collection, get the point value as you did before and create a new entry for the array using the &amp;lt;code&amp;gt;EntryUtils.createEntry()&amp;lt;/code&amp;gt; method. You can convert the array of entries into a map using the &amp;lt;code&amp;gt;EntryUtils.createTreeMapFromArrayOfEntries()&amp;lt;/code&amp;gt; method.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Race_Conditions_Studio&amp;diff=247</id>
		<title>Race Conditions Studio</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Race_Conditions_Studio&amp;diff=247"/>
		<updated>2017-08-16T19:22:33Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: Created page with &amp;quot;=Background=  In this studio, you will take in a collection of strings, clean up each string, and add it into another collection of strings concurrently. You will also take in...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In this studio, you will take in a collection of strings, clean up each string, and add it into another collection of strings concurrently. You will also take in a collection of words, assign a point value to each word, and then put it into a map. Although not terribly exciting, the point of this studio is to teach you how to avoid data races when performing concurrent tasks. In order to accomplish these tasks, you will use the ConcurrentLinkedQueue, array, and ConcurrentHashMap classes.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''data races''' directory. The &amp;lt;code&amp;gt;WordScoreDataRace.java&amp;lt;/code&amp;gt; class is the only one you will need to alter, but the &amp;lt;code&amp;gt;WordScoreUtils.java&amp;lt;/code&amp;gt; class contains useful methods that will help with the studio.&lt;br /&gt;
&lt;br /&gt;
==toCleanedWords==&lt;br /&gt;
&lt;br /&gt;
This method should take in a collection of strings, clean it, then add the strings into another collection of strings. The &amp;lt;code&amp;gt;WordScoreUtils.toCleandWords()&amp;lt;/code&amp;gt; method should come in handy for cleaning up the string. All of this should be done in parallel and you should use a ConcurrentLinkedQueue to accomplish this task.&lt;br /&gt;
Hint: try using the non-concurrent equivalent and see what happens.&lt;br /&gt;
&lt;br /&gt;
==toCleanedWordsViaArray==&lt;br /&gt;
&lt;br /&gt;
This method should do the same thing as the toCleandWords method, but it should use arrays to avoid a data race.&lt;br /&gt;
Hint: use the Arrays.asList() method to turn your array result into a list so that you can return the data structure the method desires.&lt;br /&gt;
&lt;br /&gt;
==createLetterToScoreMap==&lt;br /&gt;
&lt;br /&gt;
This method should take in a collection of strings, assign a point value to the string, then put it into a map. The map should be composed of the words and their associated point values. The &amp;lt;code&amp;gt;WordScoreUtils.calculateScore()&amp;lt;/code&amp;gt; method should come in handy for assigning the correct point value for each word. If the map already contains a given word (there is a duplicate word), nothing should be done to the map.&lt;br /&gt;
&lt;br /&gt;
==createLetterToScoreMapViaArray==&lt;br /&gt;
&lt;br /&gt;
This method should do the same thing as the createLetterToScoreMap method, but it should use an array of entries to avoid a data race. To do this, the &amp;lt;code&amp;gt;EntryUtils.createEntryArray()&amp;lt;/code&amp;gt; method should come in handy. For each string within the collection, get the point value as you did before and create a new entry for the array using the &amp;lt;code&amp;gt;EntryUtils.createEntry()&amp;lt;/code&amp;gt; method. You can convert the array of entries into a map using the &amp;lt;code&amp;gt;EntryUtils.createTreeMapFromArrayOfEntries()&amp;lt;/code&amp;gt; method.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=243</id>
		<title>MatrixMultiply</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=243"/>
		<updated>2017-08-16T16:27:20Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* parallelGroupedForAllTasksForSeq2dIJMultiply (need help explaining this) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
Matrix multiplication is a simple mathematical operation which we will replicate in this studio. For our purposes, we will only deal with square matrices (same number of rows and columns). However, we will approach this problem with several different parallel constructs and approaches. For those unfamiliar on how to multiply two matrices, take a look at [https://www.mathsisfun.com/algebra/matrix-multiplying.html this link] for a quick overview.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for the assignment under the '''matrix-multiply''' directory. From there, you will need to implement the &amp;lt;code&amp;gt;Matrix&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SubMatrix&amp;lt;/code&amp;gt; classes.&lt;br /&gt;
&lt;br /&gt;
==Matrix==&lt;br /&gt;
&lt;br /&gt;
There are seven methods you will need to implement, all of which are different ways to use parallel for loops to solve the problem. To assist you, the sequential implementation has already been completed for you. We recommend starting from the top and working your way down.&lt;br /&gt;
&lt;br /&gt;
===parallelForAllIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will simply convert the sequential solution into a parallel one using a forall loop. This should be the easiest parallel implementation and should only require minor changes to work properly.&lt;br /&gt;
&lt;br /&gt;
===parallelChunkedForAllIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will add a minor performance boost to the process by using the forall-chunked construct. Although similar to the traditional forall loop, it increases speedup using iteration grouping/chunking. This topic is discussed in detail in this [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/courseware/a900dd0655384de3b5ef01e508ea09d7/6349730bb2a149a0b33fa23db7afddee/?activate_block_id=i4x%3A%2F%2FRiceX%2FCOMP322%2Fsequential%2F6349730bb2a149a0b33fa23db7afddee Rice video] and explained in the [http://pasiphae.cs.rice.edu/#hjlib-for-parallelchunkediterationwithimplicitfinish HJ documentation]. There is no need to specify anything, allow the runtime to determine the chunking.&lt;br /&gt;
&lt;br /&gt;
===parallelGroupedForAllTasksForSeqIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this approach, we will show you how you can specify the grouping yourself and what forAllChunked is doing behind the scenes. There is no need to implement this method, this is just here to serve as a reference for you. However, you should understand the concept of iteration grouping before moving forward.&lt;br /&gt;
&lt;br /&gt;
===parallelForAllIForAllJMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will increase the parallelism of the previous implementations using two forall loops instead of one. There is no need to chunk or group the iterations. This should look very similar to the original forall implementation.&lt;br /&gt;
&lt;br /&gt;
===parallelForAll2dIJMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will cut down the syntax of the two forall implementation with the use of HJ’s &amp;lt;code&amp;gt;forall2d&amp;lt;/code&amp;gt; method. Functionally, this method serves the purpose of using two forall loops. The input parameters should equal the input parameters of the two separate forall loops. For example,&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;forall(min, max, (i) -&amp;gt; {&lt;br /&gt;
	forall(min, max, (j) -&amp;gt; doSomething());&lt;br /&gt;
});&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Would appear as &amp;lt;code&amp;gt;forall2d(min, max, min, max, (i, j) -&amp;gt; doSomething());&amp;lt;/code&amp;gt; in the forall2d syntax.&lt;br /&gt;
&lt;br /&gt;
===parallelChunkedForAll2dIJMultiply===&lt;br /&gt;
&lt;br /&gt;
This method should build on the previous 2d method and optimize its performance using chunked(). This should look very familiar from the previous implementations. Again, there is no need to specify how to chunk, leave it all to the runtime.&lt;br /&gt;
&lt;br /&gt;
===parallelGroupedForAllTasksForSeq2dIJMultiply===&lt;br /&gt;
&lt;br /&gt;
In this approach, we will show you how you can specify the grouping yourself and what forAllChunked2d is doing behind the scenes. There is no need to implement this method, this is just here to serve as a reference for you. However, you should understand the concept of iteration grouping before moving forward.&lt;br /&gt;
&lt;br /&gt;
==SubMatrix==&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will solve the matrix multiply problem in parallel using recursion. Although this class should be able to take in a matrix of any size, try to imagine this as a 2x2 matrix in order to make it easier to solve. Once you solve the sequential method, the parallel method should look very similar with exception of an async/finish block.&lt;br /&gt;
&lt;br /&gt;
In order to obtain the desired result matrix, you will need to recursively call the correct submatrices for each of the four result submatrices. Imagining this as a 2x2 matrix, remember that the dot products of the rows of the first matrix and the columns of the second matrix create the result matrix.&lt;br /&gt;
&lt;br /&gt;
Hint: Each result submatrix should have two recursive calls, for a total of eight recursive calls.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=242</id>
		<title>MatrixMultiply</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=242"/>
		<updated>2017-08-16T16:27:04Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
Matrix multiplication is a simple mathematical operation which we will replicate in this studio. For our purposes, we will only deal with square matrices (same number of rows and columns). However, we will approach this problem with several different parallel constructs and approaches. For those unfamiliar on how to multiply two matrices, take a look at [https://www.mathsisfun.com/algebra/matrix-multiplying.html this link] for a quick overview.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for the assignment under the '''matrix-multiply''' directory. From there, you will need to implement the &amp;lt;code&amp;gt;Matrix&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SubMatrix&amp;lt;/code&amp;gt; classes.&lt;br /&gt;
&lt;br /&gt;
==Matrix==&lt;br /&gt;
&lt;br /&gt;
There are seven methods you will need to implement, all of which are different ways to use parallel for loops to solve the problem. To assist you, the sequential implementation has already been completed for you. We recommend starting from the top and working your way down.&lt;br /&gt;
&lt;br /&gt;
===parallelForAllIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will simply convert the sequential solution into a parallel one using a forall loop. This should be the easiest parallel implementation and should only require minor changes to work properly.&lt;br /&gt;
&lt;br /&gt;
===parallelChunkedForAllIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will add a minor performance boost to the process by using the forall-chunked construct. Although similar to the traditional forall loop, it increases speedup using iteration grouping/chunking. This topic is discussed in detail in this [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/courseware/a900dd0655384de3b5ef01e508ea09d7/6349730bb2a149a0b33fa23db7afddee/?activate_block_id=i4x%3A%2F%2FRiceX%2FCOMP322%2Fsequential%2F6349730bb2a149a0b33fa23db7afddee Rice video] and explained in the [http://pasiphae.cs.rice.edu/#hjlib-for-parallelchunkediterationwithimplicitfinish HJ documentation]. There is no need to specify anything, allow the runtime to determine the chunking.&lt;br /&gt;
&lt;br /&gt;
===parallelGroupedForAllTasksForSeqIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this approach, we will show you how you can specify the grouping yourself and what forAllChunked is doing behind the scenes. There is no need to implement this method, this is just here to serve as a reference for you. However, you should understand the concept of iteration grouping before moving forward.&lt;br /&gt;
&lt;br /&gt;
===parallelForAllIForAllJMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will increase the parallelism of the previous implementations using two forall loops instead of one. There is no need to chunk or group the iterations. This should look very similar to the original forall implementation.&lt;br /&gt;
&lt;br /&gt;
===parallelForAll2dIJMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will cut down the syntax of the two forall implementation with the use of HJ’s &amp;lt;code&amp;gt;forall2d&amp;lt;/code&amp;gt; method. Functionally, this method serves the purpose of using two forall loops. The input parameters should equal the input parameters of the two separate forall loops. For example,&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;forall(min, max, (i) -&amp;gt; {&lt;br /&gt;
	forall(min, max, (j) -&amp;gt; doSomething());&lt;br /&gt;
});&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Would appear as &amp;lt;code&amp;gt;forall2d(min, max, min, max, (i, j) -&amp;gt; doSomething());&amp;lt;/code&amp;gt; in the forall2d syntax.&lt;br /&gt;
&lt;br /&gt;
===parallelChunkedForAll2dIJMultiply===&lt;br /&gt;
&lt;br /&gt;
This method should build on the previous 2d method and optimize its performance using chunked(). This should look very familiar from the previous implementations. Again, there is no need to specify how to chunk, leave it all to the runtime.&lt;br /&gt;
&lt;br /&gt;
===parallelGroupedForAllTasksForSeq2dIJMultiply (need help explaining this)===&lt;br /&gt;
&lt;br /&gt;
In this approach, we will show you how you can specify the grouping yourself and what forAllChunked2d is doing behind the scenes. There is no need to implement this method, this is just here to serve as a reference for you. However, you should understand the concept of iteration grouping before moving forward.&lt;br /&gt;
&lt;br /&gt;
==SubMatrix==&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will solve the matrix multiply problem in parallel using recursion. Although this class should be able to take in a matrix of any size, try to imagine this as a 2x2 matrix in order to make it easier to solve. Once you solve the sequential method, the parallel method should look very similar with exception of an async/finish block.&lt;br /&gt;
&lt;br /&gt;
In order to obtain the desired result matrix, you will need to recursively call the correct submatrices for each of the four result submatrices. Imagining this as a 2x2 matrix, remember that the dot products of the rows of the first matrix and the columns of the second matrix create the result matrix.&lt;br /&gt;
&lt;br /&gt;
Hint: Each result submatrix should have two recursive calls, for a total of eight recursive calls.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=200</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=200"/>
		<updated>2017-08-16T16:20:20Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Studios and Assignments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci | Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]]&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#*Studio: [[PageRank]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[ConnectFour]]&lt;br /&gt;
#*Studio: [[Locking | Lock Ordering]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking | All or Nothing]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Course Setup=&lt;br /&gt;
&lt;br /&gt;
We will use educational videos made by Rice University as prep work for the course. Sign up for an account [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/course/ here.]&lt;br /&gt;
&lt;br /&gt;
You will also need to set up some software for the course. Refer to the articles below for help.&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
Grading breakdown:&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Fibonacci&amp;diff=246</id>
		<title>Fibonacci</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Fibonacci&amp;diff=246"/>
		<updated>2017-08-16T16:14:03Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: Created page with &amp;quot;=Background=  The fibonacci sequence is a mathematical concept often used in computer science as a means to demonstrate iteration and recursion. Although you should be familia...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
The fibonacci sequence is a mathematical concept often used in computer science as a means to demonstrate iteration and recursion. Although you should be familiar with it from CSE 131, we will use the fibonacci sequence to demonstrate memoization and dynamic programming. Follow these links for a quick recap on [http://classes.engineering.wustl.edu/cse231/core/index.php/FAQ#Unit_2:_Futures.2FAccumulators.2FData_Races.2FMemoization memoization, dynamic programming], and the [https://en.wikipedia.org/wiki/Fibonacci_number fibonacci sequence].&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
'''UNDER CONSTRUCTION'''&lt;br /&gt;
&lt;br /&gt;
==FibonacciStudio==&lt;br /&gt;
&lt;br /&gt;
You will need to return the number associated with a given position in the fibonacci sequence. For example, if 0 was fed in, the method should return 0. 1 should return 1, 2 should return 1, 3 should return 2, and so on. You should use iteration to arrive at this value and you must use memoization to accomplish this. In other words, store and overwrite values.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MapReduce_Frameworks_Lab&amp;diff=205</id>
		<title>MapReduce Frameworks Lab</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MapReduce_Frameworks_Lab&amp;diff=205"/>
		<updated>2017-08-16T15:32:45Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* combineAndFinishAll */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
As the name suggests, MapReduce refers to the process of mapping then reducing some stream of data. At its core, all a MapReduce algorithm entails is transforming a list of one kind of item before collecting those items and reducing them down to a single value using some computation. As you can probably tell, the concept of MapReduce is extremely general and can apply to a wide berth of problems. In this assignment, we will use MapReduce to simulate the Facebook mutual friends algorithm (finding the number of mutual friends between two people) and word count algorithm. As studios, you will use MapReduce to find which infected well(s) is causing an outbreak of cholera in historic London and to map a deck of cards.&lt;br /&gt;
&lt;br /&gt;
For more information on the general concept of MapReduce, refer to [https://stackoverflow.com/questions/28982/simple-explanation-of-mapreduce this] article.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for this assignment under the '''mapreduce''' directory. From there, all of the classes you will need to implement can be found under &amp;lt;code&amp;gt;mapreduce.assignment&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;mapreduce.studio&amp;lt;/code&amp;gt;. The '''core''' directories are utility and building block classes we created for you and the '''viz''' directories are visualization apps that might help you understand your code from a visual standpoint. Take a look at these classes to get a better understanding of how to use them for your assignment.&lt;br /&gt;
&lt;br /&gt;
==Cards MapReduce Studio==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;CardMapper.java&amp;lt;/code&amp;gt; class and look at the map method. In this part of the studio, you are going to create a mapper for a given deck of cards. The mapper should accept a card’s suit and numeric value through the use of a BiConsumer. Iterate through all of the cards in the given deck and ensure they are valid cards. If they are, then map them!&lt;br /&gt;
&lt;br /&gt;
Hint: the &amp;lt;code&amp;gt;Rank&amp;lt;/code&amp;gt; class has a useful method that checks whether a card is valid.&lt;br /&gt;
&lt;br /&gt;
==Cholera MapReduce Studio==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;CholeraMapper.java&amp;lt;/code&amp;gt; class and look at the map method. In this part of the studio, you will attempt to find which water pumps are infected with cholera based on a given location of a reported case. You will do this by checking which specific WaterPump is closest to a given location and map that value to a BiConsumer. The BiConsumer will accept two arguments: the closest WaterPump and the number of occurrences to add onto the map. To find the closest WaterPump, you should go through a database of all available water pumps and compare the distances between the pumps and the location.&lt;br /&gt;
&lt;br /&gt;
Hint: there are some useful methods in the WaterPump and Location classes that might help you with the studio.&lt;br /&gt;
&lt;br /&gt;
==Mutual Friends MapReduce Assignment==&lt;br /&gt;
&lt;br /&gt;
The goal of this implementation is to create Facebook’s mutual friends algorithm using MapReduce. To accomplish this, you will need to create the mapper yourself, but the reducer has been provided to you. Navigate to the &amp;lt;code&amp;gt;MutualFriendsMapper.java&amp;lt;/code&amp;gt; class. In this class, you will specifically define how the framework accomplishes the map method.&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the map method. In this method, you will need to map every combination of the account holder to his/her friends. In order to do this, create ordered pairs of the given account’s ID and the IDs of the account holder’s friends. You must then feed each individual ordered pair into the keyValuePairConsumer along with the full set of the account holder’s friends.&lt;br /&gt;
&lt;br /&gt;
Hint: check out the methods in the Account class for help.&lt;br /&gt;
&lt;br /&gt;
==Word Count MapReduce Assignment==&lt;br /&gt;
&lt;br /&gt;
The goal of this implementation is to count the number of times a word appears in a given text, using MapReduce. To accomplish this, you will need to create both the mapper and the reducer. Navigate to the &amp;lt;code&amp;gt;WordCountMapper.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;IntegerSumClassicReducer.java&amp;lt;/code&amp;gt; classes. You will specifically define how the framework accomplishes the map and reduce methods.&lt;br /&gt;
&lt;br /&gt;
===WordCountMapper===&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the map method. In this method, you need to record every instance of a given word and feed it into the keyValuePairConsumer. To do this, access all of the words in the TextSection and if the length of the word is greater than zero (meaning it is not just blank space), convert it into lower-case and accept it into the consumer.&lt;br /&gt;
&lt;br /&gt;
Hint: Look at the methods in TextSection and the toLowerCase() method for strings for assistance.&lt;br /&gt;
&lt;br /&gt;
===IntegerSumClassicReducer===&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the apply method. All you need to do is sum up the value of a list of integers and return that sum value.&lt;br /&gt;
&lt;br /&gt;
==Simple MapReduce Framework==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;SimpleMapReduceFramework.java&amp;lt;/code&amp;gt; class and there will be three methods for you to complete: mapAll, accumulateAll, and finishAll. These frameworks are meant to be extremely general and applied to more specific uses of MapReduce.&lt;br /&gt;
&lt;br /&gt;
===mapAll Method===&lt;br /&gt;
&lt;br /&gt;
With this method, you will map all of the elements of an array of data into a new array of equivalent size consisting of a list of key value pairs. In order to do this, you must define the map() method for the mapper by specifying that it should add a new key value pair to a previously empty list. This list should then be added to the array of lists you previously defined, therefore completing the mapping stage of MapReduce. This should all be done in parallel.&lt;br /&gt;
&lt;br /&gt;
Hint: if you are creating an array of lists equivalent in size to the original array, your lists should probably consist of just one item.&lt;br /&gt;
&lt;br /&gt;
===accumulateAll Method===&lt;br /&gt;
&lt;br /&gt;
This middle step is often excluded in more advanced MapReduce applications. When run in parallel, it is the only step of the framework that must be completed sequentially. In the matrix framework implementation, we will do away with this step altogether for the sake of performance.&lt;br /&gt;
&lt;br /&gt;
In this method, you will take in the array of lists you previously created and accumulate the key value pairs in the lists into a newly defined map. Unlike the mapping phase, the map must account for the possibility of duplicates. To help deal with this issue, you must make use of the Collector provided to you. More specifically, access the accumulator in the collector by calling the &amp;lt;code&amp;gt;accumulator()&amp;lt;/code&amp;gt; method and accept the key/value pair when you add it to the map. You probably noticed that the method must return a map of &amp;lt;K, A&amp;gt;, which differs from the &amp;lt;K, V&amp;gt; generics fed into the method. The framework is designed this way as the data originally fed into the mapping stage can be turned into a different form of data before reaching the reduce stage. Although we will not do this with any of our implementations, we designed the framework to allow this. In order to access the correct value for the map if the key has no associated value yet, use the supplier associated with the Collector with the &amp;lt;code&amp;gt;supplier()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
Hint: Look into the &amp;lt;code&amp;gt;compute()&amp;lt;/code&amp;gt; method for maps.&lt;br /&gt;
&lt;br /&gt;
===finishAll Method===&lt;br /&gt;
&lt;br /&gt;
This final step reduces the accumulated data and returns the final map in its reduced form. Again, you may notice that the method returns a map of &amp;lt;K, R&amp;gt; instead of the &amp;lt;K, A&amp;gt; which was returned in the accumulateAll method. This happens for the exact same reason as the accumulateAll method, as the framework is designed to handle cases in which the reduced data differs in type from the accumulated data.&lt;br /&gt;
&lt;br /&gt;
To reduce the data down, use the map returned from the accumulateAll stage and put the results of the reduction into a new map. The provided Collector will come in extremely handy for this stage, more specifically the finisher which can be called using the &amp;lt;code&amp;gt;finisher()&amp;lt;/code&amp;gt; method. This step should run in parallel and will probably be the easiest of the three methods.&lt;br /&gt;
&lt;br /&gt;
Hint: Use the &amp;lt;code&amp;gt;entrySet()&amp;lt;/code&amp;gt; method to get all of the entries in the given map and remember to use a ConcurrentHashMap instead of a regular HashMap to ensure the method can run in parallel.&lt;br /&gt;
&lt;br /&gt;
==Matrix MapReduce Framework==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;MatrixMapReduceFramework.java&amp;lt;/code&amp;gt; class and there will be two methods for you to complete: mapAndAccumulateAll and combineAndFinishAll. These frameworks are meant to be extremely general and applied to more specific uses of MapReduce.&lt;br /&gt;
&lt;br /&gt;
The matrix framework is much more complex than the simple framework, but it boosts performance by grouping the map and accumulate stages so that everything can run in parallel. It does so by slicing up the given data into the specified mapTaskCount number of slices and assigns a reduce task number to each entry using the provided getReduceIndex() method. This, in effect, creates a matrix of maps, hence the name of the framework. In the combineAndFinishAll stage, the matrix comes in handy by allowing us to go directly down the matrix (as each key is essentially grouped into a bucket), combining and reducing elements all-in-one. This concept was explained in more depth during class.&lt;br /&gt;
&lt;br /&gt;
===mapAndAccumulateAll===&lt;br /&gt;
&lt;br /&gt;
In this stage, you will map and accumulate a given array of data into a matrix of maps. This method should run in parallel while combining the map and accumulate portions of the simple framework (which we recommend you attempt first). As mentioned previously, the input should be sliced into a mapTaskCount number of slices and then mapped/accumulated into its rightful spot in the matrix. Although you can slice up the data into chunks yourself, we recommend using the &amp;lt;code&amp;gt;Slice&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Slices&amp;lt;/code&amp;gt; classes introduced earlier in the course.&lt;br /&gt;
&lt;br /&gt;
For each slice, the mapper should map the input into its rightful spot in the matrix and accumulate it into that specific map. Essentially, you will need to nestle the actions of the accumulate method into the mapper. In order to find where the input should go in the matrix, remember that each slice keeps track of its position relative to the other slices and the getReduceIndex method, mentioned above.&lt;br /&gt;
&lt;br /&gt;
Hint: The number of rows should match the number of slices.&lt;br /&gt;
&lt;br /&gt;
===combineAndFinishAll===&lt;br /&gt;
&lt;br /&gt;
In this stage, you will take the matrix you just completed and combine all of the separate rows down to one array. Afterward, you will convert this combined array of maps into one final map. This method should run in parallel.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, you should go directly down the matrix to access the same bucket across the different slices you created in the mapAndAccumulateAll step. For all of the maps in a column, you should go through each entry and combine it down into one row. You will need to make use of the Collector’s finisher again, but you will also need to make use of the combiner. You can access the Collector’s combiner using the &amp;lt;code&amp;gt;combiner()&amp;lt;/code&amp;gt; method. Although the combine step differs from the simple framework, the finish step should mirror what you did previously.&lt;br /&gt;
&lt;br /&gt;
Hint: You can use the provided MultiWrapMap class to return the final row as a valid output. You should also combine before you finish.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MapReduce_Frameworks_Lab&amp;diff=204</id>
		<title>MapReduce Frameworks Lab</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MapReduce_Frameworks_Lab&amp;diff=204"/>
		<updated>2017-08-16T15:27:54Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* mapAndAccumulateAll */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
As the name suggests, MapReduce refers to the process of mapping then reducing some stream of data. At its core, all a MapReduce algorithm entails is transforming a list of one kind of item before collecting those items and reducing them down to a single value using some computation. As you can probably tell, the concept of MapReduce is extremely general and can apply to a wide berth of problems. In this assignment, we will use MapReduce to simulate the Facebook mutual friends algorithm (finding the number of mutual friends between two people) and word count algorithm. As studios, you will use MapReduce to find which infected well(s) is causing an outbreak of cholera in historic London and to map a deck of cards.&lt;br /&gt;
&lt;br /&gt;
For more information on the general concept of MapReduce, refer to [https://stackoverflow.com/questions/28982/simple-explanation-of-mapreduce this] article.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for this assignment under the '''mapreduce''' directory. From there, all of the classes you will need to implement can be found under &amp;lt;code&amp;gt;mapreduce.assignment&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;mapreduce.studio&amp;lt;/code&amp;gt;. The '''core''' directories are utility and building block classes we created for you and the '''viz''' directories are visualization apps that might help you understand your code from a visual standpoint. Take a look at these classes to get a better understanding of how to use them for your assignment.&lt;br /&gt;
&lt;br /&gt;
==Cards MapReduce Studio==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;CardMapper.java&amp;lt;/code&amp;gt; class and look at the map method. In this part of the studio, you are going to create a mapper for a given deck of cards. The mapper should accept a card’s suit and numeric value through the use of a BiConsumer. Iterate through all of the cards in the given deck and ensure they are valid cards. If they are, then map them!&lt;br /&gt;
&lt;br /&gt;
Hint: the &amp;lt;code&amp;gt;Rank&amp;lt;/code&amp;gt; class has a useful method that checks whether a card is valid.&lt;br /&gt;
&lt;br /&gt;
==Cholera MapReduce Studio==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;CholeraMapper.java&amp;lt;/code&amp;gt; class and look at the map method. In this part of the studio, you will attempt to find which water pumps are infected with cholera based on a given location of a reported case. You will do this by checking which specific WaterPump is closest to a given location and map that value to a BiConsumer. The BiConsumer will accept two arguments: the closest WaterPump and the number of occurrences to add onto the map. To find the closest WaterPump, you should go through a database of all available water pumps and compare the distances between the pumps and the location.&lt;br /&gt;
&lt;br /&gt;
Hint: there are some useful methods in the WaterPump and Location classes that might help you with the studio.&lt;br /&gt;
&lt;br /&gt;
==Mutual Friends MapReduce Assignment==&lt;br /&gt;
&lt;br /&gt;
The goal of this implementation is to create Facebook’s mutual friends algorithm using MapReduce. To accomplish this, you will need to create the mapper yourself, but the reducer has been provided to you. Navigate to the &amp;lt;code&amp;gt;MutualFriendsMapper.java&amp;lt;/code&amp;gt; class. In this class, you will specifically define how the framework accomplishes the map method.&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the map method. In this method, you will need to map every combination of the account holder to his/her friends. In order to do this, create ordered pairs of the given account’s ID and the IDs of the account holder’s friends. You must then feed each individual ordered pair into the keyValuePairConsumer along with the full set of the account holder’s friends.&lt;br /&gt;
&lt;br /&gt;
Hint: check out the methods in the Account class for help.&lt;br /&gt;
&lt;br /&gt;
==Word Count MapReduce Assignment==&lt;br /&gt;
&lt;br /&gt;
The goal of this implementation is to count the number of times a word appears in a given text, using MapReduce. To accomplish this, you will need to create both the mapper and the reducer. Navigate to the &amp;lt;code&amp;gt;WordCountMapper.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;IntegerSumClassicReducer.java&amp;lt;/code&amp;gt; classes. You will specifically define how the framework accomplishes the map and reduce methods.&lt;br /&gt;
&lt;br /&gt;
===WordCountMapper===&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the map method. In this method, you need to record every instance of a given word and feed it into the keyValuePairConsumer. To do this, access all of the words in the TextSection and if the length of the word is greater than zero (meaning it is not just blank space), convert it into lower-case and accept it into the consumer.&lt;br /&gt;
&lt;br /&gt;
Hint: Look at the methods in TextSection and the toLowerCase() method for strings for assistance.&lt;br /&gt;
&lt;br /&gt;
===IntegerSumClassicReducer===&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the apply method. All you need to do is sum up the value of a list of integers and return that sum value.&lt;br /&gt;
&lt;br /&gt;
==Simple MapReduce Framework==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;SimpleMapReduceFramework.java&amp;lt;/code&amp;gt; class and there will be three methods for you to complete: mapAll, accumulateAll, and finishAll. These frameworks are meant to be extremely general and applied to more specific uses of MapReduce.&lt;br /&gt;
&lt;br /&gt;
===mapAll Method===&lt;br /&gt;
&lt;br /&gt;
With this method, you will map all of the elements of an array of data into a new array of equivalent size consisting of a list of key value pairs. In order to do this, you must define the map() method for the mapper by specifying that it should add a new key value pair to a previously empty list. This list should then be added to the array of lists you previously defined, therefore completing the mapping stage of MapReduce. This should all be done in parallel.&lt;br /&gt;
&lt;br /&gt;
Hint: if you are creating an array of lists equivalent in size to the original array, your lists should probably consist of just one item.&lt;br /&gt;
&lt;br /&gt;
===accumulateAll Method===&lt;br /&gt;
&lt;br /&gt;
This middle step is often excluded in more advanced MapReduce applications. When run in parallel, it is the only step of the framework that must be completed sequentially. In the matrix framework implementation, we will do away with this step altogether for the sake of performance.&lt;br /&gt;
&lt;br /&gt;
In this method, you will take in the array of lists you previously created and accumulate the key value pairs in the lists into a newly defined map. Unlike the mapping phase, the map must account for the possibility of duplicates. To help deal with this issue, you must make use of the Collector provided to you. More specifically, access the accumulator in the collector by calling the &amp;lt;code&amp;gt;accumulator()&amp;lt;/code&amp;gt; method and accept the key/value pair when you add it to the map. You probably noticed that the method must return a map of &amp;lt;K, A&amp;gt;, which differs from the &amp;lt;K, V&amp;gt; generics fed into the method. The framework is designed this way as the data originally fed into the mapping stage can be turned into a different form of data before reaching the reduce stage. Although we will not do this with any of our implementations, we designed the framework to allow this. In order to access the correct value for the map if the key has no associated value yet, use the supplier associated with the Collector with the &amp;lt;code&amp;gt;supplier()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
Hint: Look into the &amp;lt;code&amp;gt;compute()&amp;lt;/code&amp;gt; method for maps.&lt;br /&gt;
&lt;br /&gt;
===finishAll Method===&lt;br /&gt;
&lt;br /&gt;
This final step reduces the accumulated data and returns the final map in its reduced form. Again, you may notice that the method returns a map of &amp;lt;K, R&amp;gt; instead of the &amp;lt;K, A&amp;gt; which was returned in the accumulateAll method. This happens for the exact same reason as the accumulateAll method, as the framework is designed to handle cases in which the reduced data differs in type from the accumulated data.&lt;br /&gt;
&lt;br /&gt;
To reduce the data down, use the map returned from the accumulateAll stage and put the results of the reduction into a new map. The provided Collector will come in extremely handy for this stage, more specifically the finisher which can be called using the &amp;lt;code&amp;gt;finisher()&amp;lt;/code&amp;gt; method. This step should run in parallel and will probably be the easiest of the three methods.&lt;br /&gt;
&lt;br /&gt;
Hint: Use the &amp;lt;code&amp;gt;entrySet()&amp;lt;/code&amp;gt; method to get all of the entries in the given map and remember to use a ConcurrentHashMap instead of a regular HashMap to ensure the method can run in parallel.&lt;br /&gt;
&lt;br /&gt;
==Matrix MapReduce Framework==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;MatrixMapReduceFramework.java&amp;lt;/code&amp;gt; class and there will be two methods for you to complete: mapAndAccumulateAll and combineAndFinishAll. These frameworks are meant to be extremely general and applied to more specific uses of MapReduce.&lt;br /&gt;
&lt;br /&gt;
The matrix framework is much more complex than the simple framework, but it boosts performance by grouping the map and accumulate stages so that everything can run in parallel. It does so by slicing up the given data into the specified mapTaskCount number of slices and assigns a reduce task number to each entry using the provided getReduceIndex() method. This, in effect, creates a matrix of maps, hence the name of the framework. In the combineAndFinishAll stage, the matrix comes in handy by allowing us to go directly down the matrix (as each key is essentially grouped into a bucket), combining and reducing elements all-in-one. This concept was explained in more depth during class.&lt;br /&gt;
&lt;br /&gt;
===mapAndAccumulateAll===&lt;br /&gt;
&lt;br /&gt;
In this stage, you will map and accumulate a given array of data into a matrix of maps. This method should run in parallel while combining the map and accumulate portions of the simple framework (which we recommend you attempt first). As mentioned previously, the input should be sliced into a mapTaskCount number of slices and then mapped/accumulated into its rightful spot in the matrix. Although you can slice up the data into chunks yourself, we recommend using the &amp;lt;code&amp;gt;Slice&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Slices&amp;lt;/code&amp;gt; classes introduced earlier in the course.&lt;br /&gt;
&lt;br /&gt;
For each slice, the mapper should map the input into its rightful spot in the matrix and accumulate it into that specific map. Essentially, you will need to nestle the actions of the accumulate method into the mapper. In order to find where the input should go in the matrix, remember that each slice keeps track of its position relative to the other slices and the getReduceIndex method, mentioned above.&lt;br /&gt;
&lt;br /&gt;
Hint: The number of rows should match the number of slices.&lt;br /&gt;
&lt;br /&gt;
===combineAndFinishAll===&lt;br /&gt;
&lt;br /&gt;
In this stage, you will take the matrix you just completed and combine all of the separate rows down to one array. Afterwards, you will convert this combined array of maps into one final map. This method should run in parallel.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, you should go directly down the matrix to access the same bucket across the different slices you created in the mapAndAccumulateAll step. For all of the maps in a column, you should go through each entry and combine it down into one row. You will need to make use of the Collector’s finisher again, but you will also need to make use of the combiner. You can access the Collector’s combiner using the &amp;lt;code&amp;gt;combiner()&amp;lt;/code&amp;gt; method. Although the combine step differs from the simple framework, the finish step should mirror what you did previously.&lt;br /&gt;
&lt;br /&gt;
Hint: You can use the provided MultiWrapMap class to return the final row as a valid output.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=241</id>
		<title>MatrixMultiply</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MatrixMultiply&amp;diff=241"/>
		<updated>2017-08-07T21:35:21Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: Created page with &amp;quot;=Background=  Matrix multiplication is a simple mathematical operation which we will replicate in this studio. For our purposes, we will only deal with square matrices (same n...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
Matrix multiplication is a simple mathematical operation which we will replicate in this studio. For our purposes, we will only deal with square matrices (same number of rows and columns). However, we will approach this problem with several different parallel constructs and approaches. For those unfamiliar on how to multiply two matrices, take a look at [https://www.mathsisfun.com/algebra/matrix-multiplying.html this link] for a quick overview.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for the assignment under the '''matrix-multiply''' directory. From there, you will need to implement the &amp;lt;code&amp;gt;Matrix&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SubMatrix&amp;lt;/code&amp;gt; classes.&lt;br /&gt;
&lt;br /&gt;
==Matrix==&lt;br /&gt;
&lt;br /&gt;
There are seven methods you will need to implement, all of which are different ways to use parallel for loops to solve the problem. To assist you, the sequential implementation has already been completed for you. We recommend starting from the top and working your way down.&lt;br /&gt;
&lt;br /&gt;
===parallelForAllIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will simply convert the sequential solution into a parallel one using a forall loop. This should be the easiest parallel implementation and should only require minor changes to work properly.&lt;br /&gt;
&lt;br /&gt;
===parallelChunkedForAllIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will add a minor performance boost to the process by using the forall-chunked construct. Although similar to the traditional forall loop, it increases speedup using iteration grouping/chunking. This topic is discussed in detail in this [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/courseware/a900dd0655384de3b5ef01e508ea09d7/6349730bb2a149a0b33fa23db7afddee/?activate_block_id=i4x%3A%2F%2FRiceX%2FCOMP322%2Fsequential%2F6349730bb2a149a0b33fa23db7afddee Rice video] and explained in the [http://pasiphae.cs.rice.edu/#hjlib-for-parallelchunkediterationwithimplicitfinish HJ documentation]. There is no need to specify anything, allow the runtime to determine the chunking.&lt;br /&gt;
&lt;br /&gt;
===parallelGroupedForAllTasksForSeqIMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will make use of HJ’s iteration regions in order to manually group them for the sake of performance. You only need to use a 1D region for this method, but you will need to make notable changes from your previous work. For optimal performance, we will break down the parallel tasks so that they equal the exact number of working threads. You can access this information using HJ’s &amp;lt;code&amp;gt;numWorkerThreads()&amp;lt;/code&amp;gt; method. After launching a number of tasks equal to the number of worker threads, use HJ’s &amp;lt;code&amp;gt;myGroup()&amp;lt;/code&amp;gt; method to create a new 1D region from the index of the thread, a 1D region specified to the size of the matrix, and the number of threads. After that, launch the code as you did previously and multiply the two matrices.&lt;br /&gt;
&lt;br /&gt;
Hint: use forseq to create a sequential for loop that can access the indices of a HJ iteration region.&lt;br /&gt;
&lt;br /&gt;
===parallelForAllIForAllJMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will increase the parallelism of the previous implementations using two forall loops instead of one. There is no need to chunk or group the iterations. This should look very similar to the original forall implementation.&lt;br /&gt;
&lt;br /&gt;
===parallelForAll2dIJMultiply===&lt;br /&gt;
&lt;br /&gt;
In this implementation, we will cut down the syntax of the two forall implementation with the use of HJ’s &amp;lt;code&amp;gt;forall2d&amp;lt;/code&amp;gt; method. Functionally, this method serves the purpose of using two forall loops. The input parameters should equal the input parameters of the two separate forall loops. For example,&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;forall(min, max, (i) -&amp;gt; {&lt;br /&gt;
	forall(min, max, (j) -&amp;gt; doSomething());&lt;br /&gt;
});&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Would appear as &amp;lt;code&amp;gt;forall2d(min, max, min, max, (i, j) -&amp;gt; doSomething());&amp;lt;/code&amp;gt; in the forall2d syntax.&lt;br /&gt;
&lt;br /&gt;
===parallelChunkedForAll2dIJMultiply===&lt;br /&gt;
&lt;br /&gt;
This method should build on the previous 2d method and optimize its performance using chunked(). This should look very familiar from the previous implementations. Again, there is no need to specify how to chunk, leave it all to the runtime.&lt;br /&gt;
&lt;br /&gt;
===parallelGroupedForAllTasksForSeq2dIJMultiply (need help explaining this)===&lt;br /&gt;
&lt;br /&gt;
This is the most difficult implementation out of all of the previous methods. However, if you did everything beforehand, a lot of the steps are a synthesis of the forall2d implementations and the 1D grouping implementation.&lt;br /&gt;
&lt;br /&gt;
'''UNDER CONSTRUCTION'''&lt;br /&gt;
&lt;br /&gt;
==SubMatrix==&lt;br /&gt;
&lt;br /&gt;
In this implementation, you will solve the matrix multiply problem in parallel using recursion. Although this class should be able to take in a matrix of any size, try to imagine this as a 2x2 matrix in order to make it easier to solve. Once you solve the sequential method, the parallel method should look very similar with exception of an async/finish block.&lt;br /&gt;
&lt;br /&gt;
In order to obtain the desired result matrix, you will need to recursively call the correct submatrices for each of the four result submatrices. Imagining this as a 2x2 matrix, remember that the dot products of the rows of the first matrix and the columns of the second matrix create the result matrix.&lt;br /&gt;
&lt;br /&gt;
Hint: Each result submatrix should have two recursive calls, for a total of eight recursive calls.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MapReduce_Frameworks_Lab&amp;diff=203</id>
		<title>MapReduce Frameworks Lab</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MapReduce_Frameworks_Lab&amp;diff=203"/>
		<updated>2017-08-07T21:27:31Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
As the name suggests, MapReduce refers to the process of mapping then reducing some stream of data. At its core, all a MapReduce algorithm entails is transforming a list of one kind of item before collecting those items and reducing them down to a single value using some computation. As you can probably tell, the concept of MapReduce is extremely general and can apply to a wide berth of problems. In this assignment, we will use MapReduce to simulate the Facebook mutual friends algorithm (finding the number of mutual friends between two people) and word count algorithm. As studios, you will use MapReduce to find which infected well(s) is causing an outbreak of cholera in historic London and to map a deck of cards.&lt;br /&gt;
&lt;br /&gt;
For more information on the general concept of MapReduce, refer to [https://stackoverflow.com/questions/28982/simple-explanation-of-mapreduce this] article.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
You can find all of the relevant files for this assignment under the '''mapreduce''' directory. From there, all of the classes you will need to implement can be found under &amp;lt;code&amp;gt;mapreduce.assignment&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;mapreduce.studio&amp;lt;/code&amp;gt;. The '''core''' directories are utility and building block classes we created for you and the '''viz''' directories are visualization apps that might help you understand your code from a visual standpoint. Take a look at these classes to get a better understanding of how to use them for your assignment.&lt;br /&gt;
&lt;br /&gt;
==Cards MapReduce Studio==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;CardMapper.java&amp;lt;/code&amp;gt; class and look at the map method. In this part of the studio, you are going to create a mapper for a given deck of cards. The mapper should accept a card’s suit and numeric value through the use of a BiConsumer. Iterate through all of the cards in the given deck and ensure they are valid cards. If they are, then map them!&lt;br /&gt;
&lt;br /&gt;
Hint: the &amp;lt;code&amp;gt;Rank&amp;lt;/code&amp;gt; class has a useful method that checks whether a card is valid.&lt;br /&gt;
&lt;br /&gt;
==Cholera MapReduce Studio==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;CholeraMapper.java&amp;lt;/code&amp;gt; class and look at the map method. In this part of the studio, you will attempt to find which water pumps are infected with cholera based on a given location of a reported case. You will do this by checking which specific WaterPump is closest to a given location and map that value to a BiConsumer. The BiConsumer will accept two arguments: the closest WaterPump and the number of occurrences to add onto the map. To find the closest WaterPump, you should go through a database of all available water pumps and compare the distances between the pumps and the location.&lt;br /&gt;
&lt;br /&gt;
Hint: there are some useful methods in the WaterPump and Location classes that might help you with the studio.&lt;br /&gt;
&lt;br /&gt;
==Mutual Friends MapReduce Assignment==&lt;br /&gt;
&lt;br /&gt;
The goal of this implementation is to create Facebook’s mutual friends algorithm using MapReduce. To accomplish this, you will need to create the mapper yourself, but the reducer has been provided to you. Navigate to the &amp;lt;code&amp;gt;MutualFriendsMapper.java&amp;lt;/code&amp;gt; class. In this class, you will specifically define how the framework accomplishes the map method.&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the map method. In this method, you will need to map every combination of the account holder to his/her friends. In order to do this, create ordered pairs of the given account’s ID and the IDs of the account holder’s friends. You must then feed each individual ordered pair into the keyValuePairConsumer along with the full set of the account holder’s friends.&lt;br /&gt;
&lt;br /&gt;
Hint: check out the methods in the Account class for help.&lt;br /&gt;
&lt;br /&gt;
==Word Count MapReduce Assignment==&lt;br /&gt;
&lt;br /&gt;
The goal of this implementation is to count the number of times a word appears in a given text, using MapReduce. To accomplish this, you will need to create both the mapper and the reducer. Navigate to the &amp;lt;code&amp;gt;WordCountMapper.java&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;IntegerSumClassicReducer.java&amp;lt;/code&amp;gt; classes. You will specifically define how the framework accomplishes the map and reduce methods.&lt;br /&gt;
&lt;br /&gt;
===WordCountMapper===&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the map method. In this method, you need to record every instance of a given word and feed it into the keyValuePairConsumer. To do this, access all of the words in the TextSection and if the length of the word is greater than zero (meaning it is not just blank space), convert it into lower-case and accept it into the consumer.&lt;br /&gt;
&lt;br /&gt;
Hint: Look at the methods in TextSection and the toLowerCase() method for strings for assistance.&lt;br /&gt;
&lt;br /&gt;
===IntegerSumClassicReducer===&lt;br /&gt;
&lt;br /&gt;
The only method you will need to alter is the apply method. All you need to do is sum up the value of a list of integers and return that sum value.&lt;br /&gt;
&lt;br /&gt;
==Simple MapReduce Framework==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;SimpleMapReduceFramework.java&amp;lt;/code&amp;gt; class and there will be three methods for you to complete: mapAll, accumulateAll, and finishAll. These frameworks are meant to be extremely general and applied to more specific uses of MapReduce.&lt;br /&gt;
&lt;br /&gt;
===mapAll Method===&lt;br /&gt;
&lt;br /&gt;
With this method, you will map all of the elements of an array of data into a new array of equivalent size consisting of a list of key value pairs. In order to do this, you must define the map() method for the mapper by specifying that it should add a new key value pair to a previously empty list. This list should then be added to the array of lists you previously defined, therefore completing the mapping stage of MapReduce. This should all be done in parallel.&lt;br /&gt;
&lt;br /&gt;
Hint: if you are creating an array of lists equivalent in size to the original array, your lists should probably consist of just one item.&lt;br /&gt;
&lt;br /&gt;
===accumulateAll Method===&lt;br /&gt;
&lt;br /&gt;
This middle step is often excluded in more advanced MapReduce applications. When run in parallel, it is the only step of the framework that must be completed sequentially. In the matrix framework implementation, we will do away with this step altogether for the sake of performance.&lt;br /&gt;
&lt;br /&gt;
In this method, you will take in the array of lists you previously created and accumulate the key value pairs in the lists into a newly defined map. Unlike the mapping phase, the map must account for the possibility of duplicates. To help deal with this issue, you must make use of the Collector provided to you. More specifically, access the accumulator in the collector by calling the &amp;lt;code&amp;gt;accumulator()&amp;lt;/code&amp;gt; method and accept the key/value pair when you add it to the map. You probably noticed that the method must return a map of &amp;lt;K, A&amp;gt;, which differs from the &amp;lt;K, V&amp;gt; generics fed into the method. The framework is designed this way as the data originally fed into the mapping stage can be turned into a different form of data before reaching the reduce stage. Although we will not do this with any of our implementations, we designed the framework to allow this. In order to access the correct value for the map if the key has no associated value yet, use the supplier associated with the Collector with the &amp;lt;code&amp;gt;supplier()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
Hint: Look into the &amp;lt;code&amp;gt;compute()&amp;lt;/code&amp;gt; method for maps.&lt;br /&gt;
&lt;br /&gt;
===finishAll Method===&lt;br /&gt;
&lt;br /&gt;
This final step reduces the accumulated data and returns the final map in its reduced form. Again, you may notice that the method returns a map of &amp;lt;K, R&amp;gt; instead of the &amp;lt;K, A&amp;gt; which was returned in the accumulateAll method. This happens for the exact same reason as the accumulateAll method, as the framework is designed to handle cases in which the reduced data differs in type from the accumulated data.&lt;br /&gt;
&lt;br /&gt;
To reduce the data down, use the map returned from the accumulateAll stage and put the results of the reduction into a new map. The provided Collector will come in extremely handy for this stage, more specifically the finisher which can be called using the &amp;lt;code&amp;gt;finisher()&amp;lt;/code&amp;gt; method. This step should run in parallel and will probably be the easiest of the three methods.&lt;br /&gt;
&lt;br /&gt;
Hint: Use the &amp;lt;code&amp;gt;entrySet()&amp;lt;/code&amp;gt; method to get all of the entries in the given map and remember to use a ConcurrentHashMap instead of a regular HashMap to ensure the method can run in parallel.&lt;br /&gt;
&lt;br /&gt;
==Matrix MapReduce Framework==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;code&amp;gt;MatrixMapReduceFramework.java&amp;lt;/code&amp;gt; class and there will be two methods for you to complete: mapAndAccumulateAll and combineAndFinishAll. These frameworks are meant to be extremely general and applied to more specific uses of MapReduce.&lt;br /&gt;
&lt;br /&gt;
The matrix framework is much more complex than the simple framework, but it boosts performance by grouping the map and accumulate stages so that everything can run in parallel. It does so by slicing up the given data into the specified mapTaskCount number of slices and assigns a reduce task number to each entry using the provided getReduceIndex() method. This, in effect, creates a matrix of maps, hence the name of the framework. In the combineAndFinishAll stage, the matrix comes in handy by allowing us to go directly down the matrix (as each key is essentially grouped into a bucket), combining and reducing elements all-in-one. This concept was explained in more depth during class.&lt;br /&gt;
&lt;br /&gt;
===mapAndAccumulateAll===&lt;br /&gt;
&lt;br /&gt;
In this stage, you will map and accumulate a given array of data into a matrix of maps. This method should run in parallel while combining the map and accumulate portions of the simple framework (which we recommend you attempt first). As mentioned previously, the input should be sliced into a mapTaskCount number of slices and then mapped/accumulated into its rightful spot in the matrix. Although you can slice up the data into chunks yourself, we recommend using the &amp;lt;code&amp;gt;Slice&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Slices&amp;lt;/code&amp;gt; classes introduced earlier in the course.&lt;br /&gt;
&lt;br /&gt;
For each slice, define that the mapper should map the input into its rightful spot in the matrix and accumulate it into that specific map. Essentially, you will need to nestle the actions of the accumulate method into the mapper. In order to find where the input should go in the matrix, remember that each slice keeps track of its position relative to the other slices and the getReduceIndex method, mentioned above.&lt;br /&gt;
&lt;br /&gt;
Hint: The number of rows should match the number of slices.&lt;br /&gt;
&lt;br /&gt;
===combineAndFinishAll===&lt;br /&gt;
&lt;br /&gt;
In this stage, you will take the matrix you just completed and combine all of the separate rows down to one array. Afterwards, you will convert this combined array of maps into one final map. This method should run in parallel.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, you should go directly down the matrix to access the same bucket across the different slices you created in the mapAndAccumulateAll step. For all of the maps in a column, you should go through each entry and combine it down into one row. You will need to make use of the Collector’s finisher again, but you will also need to make use of the combiner. You can access the Collector’s combiner using the &amp;lt;code&amp;gt;combiner()&amp;lt;/code&amp;gt; method. Although the combine step differs from the simple framework, the finish step should mirror what you did previously.&lt;br /&gt;
&lt;br /&gt;
Hint: You can use the provided MultiWrapMap class to return the final row as a valid output.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=MergeSort&amp;diff=238</id>
		<title>MergeSort</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=MergeSort&amp;diff=238"/>
		<updated>2017-08-07T21:17:18Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: Created page with &amp;quot;=Background=  In computer science, merge sort refers to a sorting algorithm which splits an array of data into continuously smaller halves until the arrays reach a size of 1,...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Background=&lt;br /&gt;
&lt;br /&gt;
In computer science, merge sort refers to a sorting algorithm which splits an array of data into continuously smaller halves until the arrays reach a size of 1, after which the elements are continuously compared and merged into a sorted array. For more information on how this process works, visit [https://en.wikipedia.org/wiki/Merge_sort this] page. If you took CSE 247, this algorithm should look extremely familiar to you.&lt;br /&gt;
&lt;br /&gt;
=Where to Start=&lt;br /&gt;
&lt;br /&gt;
Navigate to the '''mergesort''' directory and look at the &amp;lt;code&amp;gt;MergesortStudio.java&amp;lt;/code&amp;gt; class. The '''core''' directory contains some useful building block classes we created for you. Take a look at &amp;lt;code&amp;gt;MergesortUtils&amp;lt;/code&amp;gt; as you will need to use one of its methods to assist you in this studio.&lt;br /&gt;
&lt;br /&gt;
=MergeSort Studio=&lt;br /&gt;
&lt;br /&gt;
You will need to implement merge sort sequentially and in parallel, but you will need to do both implementations recursively. The kernel method should call itself using recursion, but the mergesort method should only call the kernel once. We do this in order to manipulate where we can place our async/finish blocks. When running recursively, we do not want to place a finish block around the recursive call as that would defeat the purpose of calling an async in the first place. When completing this studio, think carefully about where to put your async/finish calls.&lt;br /&gt;
&lt;br /&gt;
==Sequential Implementation==&lt;br /&gt;
&lt;br /&gt;
The only thing you will need to edit is the kernel method. As this is a sequential implementation, there is no need to call an async or finish. Using the description of merge sort provided to you in the background, try to consider what the base case would be. Then, further consider how to call the method recursively. When the array reaches the base case, you will need to complete the “merging” aspect of merge sort. As mentioned above, there is a method in the utils class that should help with this.&lt;br /&gt;
&lt;br /&gt;
Hint: Follow the Wikipedia links and look at the pseudocode for help.&lt;br /&gt;
&lt;br /&gt;
==Parallel Implementation==&lt;br /&gt;
&lt;br /&gt;
This should look exactly like the sequential implementation, but it should also include async/finish calls. Think carefully about where to place them to maximize concurrency.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=199</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=199"/>
		<updated>2017-08-07T18:13:22Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Studios and Assignments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]]&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#*Studio: [[PageRank]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[ConnectFour]]&lt;br /&gt;
#*Studio: [[Locking | Lock Ordering]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking | All or Nothing]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Course Setup=&lt;br /&gt;
&lt;br /&gt;
We will use educational videos made by Rice University as prep work for the course. Sign up for an account [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/course/ here.]&lt;br /&gt;
&lt;br /&gt;
You will also need to set up some software for the course. Refer to the articles below for help.&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
Grading breakdown:&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=198</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=198"/>
		<updated>2017-07-31T17:49:40Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]]&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Course Setup=&lt;br /&gt;
&lt;br /&gt;
We will use educational videos made by Rice University as prep work for the course. Sign up for an account [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/course/ here.]&lt;br /&gt;
&lt;br /&gt;
You will also need to set up some software for the course. Refer to the articles below for help.&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
Grading breakdown:&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=197</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=197"/>
		<updated>2017-07-31T17:42:30Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Course Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
=Course Setup=&lt;br /&gt;
&lt;br /&gt;
We will use educational videos made by Rice University as prep work for the course. Sign up for an account [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/course/ here.]&lt;br /&gt;
&lt;br /&gt;
You will also need to set up some software for the course. Refer to the articles below for help.&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]]&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
Grading breakdown:&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=196</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=196"/>
		<updated>2017-07-31T17:33:41Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
=Course Setup=&lt;br /&gt;
&lt;br /&gt;
We will use educational videos made by Rice University as prep work for the course. Sign up for an account [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/course/ here.]&lt;br /&gt;
&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]]&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
Grading breakdown:&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=195</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=195"/>
		<updated>2017-07-31T17:03:13Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Class Policies and Grading Breakdown */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]]&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
Grading breakdown:&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=194</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=Main_Page&amp;diff=194"/>
		<updated>2017-07-31T16:59:54Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Studios and Assignments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki for CSE 231 Introduction to Parallel and Concurrent Programming at Washington University in St. Louis.&lt;br /&gt;
&lt;br /&gt;
=Calendar=&lt;br /&gt;
&lt;br /&gt;
Click [http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/calendar.html here] to visit our calendar.&lt;br /&gt;
&lt;br /&gt;
==Studios and Assignments==&lt;br /&gt;
&lt;br /&gt;
These studios and assignments are organized in chronological order.&lt;br /&gt;
&lt;br /&gt;
#Assignment: [[Nucleobase Counting]]&lt;br /&gt;
#*Studio: [[MergeSort]]&lt;br /&gt;
#Assignment: [[SimpleList and SimpleMap Assignment]]&lt;br /&gt;
#*Studio: [[Slices]]&lt;br /&gt;
#*Studio: [[Floodfill]]&lt;br /&gt;
#Assignment: [[Futures and Executors]]&lt;br /&gt;
#*Studio: [[Fibonacci Memoization and Dynamic Programming]]&lt;br /&gt;
#*Studio: [[Data Races Studio]]&lt;br /&gt;
#*Studio: [[Matrix Multiply]]&lt;br /&gt;
#Assignment: '''[[MapReduce]]'''&lt;br /&gt;
#*Studio: [[MapReduce | Card MapReduce]]&lt;br /&gt;
#*Studio: [[MapReduce | Cholera MapReduce]]&lt;br /&gt;
#Assignment: [[N-Queens/Sudoku Assignment]]&lt;br /&gt;
#*Studio: [[Legged Races]]&lt;br /&gt;
#Assignment: [[K-MerCounting Assignment]]&lt;br /&gt;
#*Studio: [[Locking]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
&lt;br /&gt;
Every week, we gather the most commonly asked questions from your Q&amp;amp;S forms and add them to our [[FAQ]] section. Please use it as a resource!&lt;br /&gt;
&lt;br /&gt;
=Help with Java=&lt;br /&gt;
&lt;br /&gt;
*[[Rundown on Everything Java]]&lt;br /&gt;
**[[Generics]]&lt;br /&gt;
**[[Interfaces]]&lt;br /&gt;
**[[Lambdas]]&lt;br /&gt;
&lt;br /&gt;
==Help with Habanero==&lt;br /&gt;
&lt;br /&gt;
*[[Habanero]]&lt;br /&gt;
&lt;br /&gt;
==Help with Eclipse==&lt;br /&gt;
&lt;br /&gt;
*[[Software setup]]&lt;br /&gt;
*[[Eclipse Tips]]&lt;br /&gt;
*[[OpenCV3]]&lt;br /&gt;
**[[Homebrew]]&lt;br /&gt;
**[[Chocolatey]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Class Policies and Grading Breakdown=&lt;br /&gt;
&lt;br /&gt;
*[[Class Policies]]&lt;br /&gt;
*[[Office hours]]&lt;br /&gt;
&lt;br /&gt;
*Midterm (15%)&lt;br /&gt;
*Final (10%)&lt;br /&gt;
*Prep Q&amp;amp;S Forms (15%)&lt;br /&gt;
*Participation/Attendance (10%)&lt;br /&gt;
*Assignments and Studios (50%)&lt;br /&gt;
**[[Nucleobase Counting]] (weight=1;3.85%)&lt;br /&gt;
**[[SimpleList and SimpleMap Assignment]] (weight=1;3.85%)&lt;br /&gt;
**[[Futures and Executors]] (weight=2;7.69%)&lt;br /&gt;
**[[MapReduce]] (weight=4;15.38%)&lt;br /&gt;
**[[N-Queens/Sudoku Assignment]] (weight=3;11.54%)&lt;br /&gt;
**[[K-MerCounting_Assignment]] (weight=2;7.69%)&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=FAQ&amp;diff=237</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=FAQ&amp;diff=237"/>
		<updated>2017-07-31T16:43:18Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Unit 2: Futures/Accumulators/Data Races/Memoization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We have gathered the most frequently asked questions on Piazza and the Q&amp;amp;S forms on this wiki for your convenience.&lt;br /&gt;
&lt;br /&gt;
=Unit 1: Async/Finish=&lt;br /&gt;
&lt;br /&gt;
*For the demo, he uses a threshold to determine whether or not to use the parallel version. How does he decide that threshold? Is it machine dependent? Or algorithm dependent?&lt;br /&gt;
**The threshold is often specified as an input parameter in a parallel method. The user often sets the value depending on the algorithm based on the overhead of starting a parallel process.&lt;br /&gt;
*Is async and finish features of the Java language or specific to this class?&lt;br /&gt;
**Async and finish are features of Habanero Java, a tool built by Rice University. It is not native to Java but we will use it in this class for its simplicity.&lt;br /&gt;
*When doing Quicksort, why is it more efficient to place the finish inside the main method?&lt;br /&gt;
**When performing recursive methods in parallel, it is most efficient to place the finish around the initial call as you want the subsequent inner calls to run asynchronously. Thus, you should wrap the async around the inner recursive call and the finish around the initial outer call.&lt;br /&gt;
*Are we assuming that the core of the CPU is infinite?&lt;br /&gt;
**When dealing with theory, we will assume it is infinite unless otherwise specified. When coding, we will take hybrid approaches where we will sometimes assume it is infinite and sometimes code realistically to adjust for the finite number of cores.&lt;br /&gt;
*In the videos and quizzes, we assumed finish and asyncs added no work to the computation graph. In reality, is there some amount of work needed for them?&lt;br /&gt;
**Yes, that work is what we are referring to when we talk about overhead. In order to account for this, you should only run a program in parallel if the amount of work overshadows the overhead costs.&lt;br /&gt;
*How does concurrency affect timing with a single core?&lt;br /&gt;
**With a single core, it becomes impossible to launch programs in parallel, but concurrent programming is still possible. Under such a scenario, whatever you async'd will still execute as separate threads, but it will simply run on the single core. Thus, the order in which the threads execute is still not guaranteed, meaning it will not run like sequential code. For a more detailed explanation, refer to [https://stackoverflow.com/questions/1897993/what-is-the-difference-between-concurrent-programming-and-parallel-programming this] article.&lt;br /&gt;
&lt;br /&gt;
=Unit 2: Futures/Accumulators/Data Races/Memoization=&lt;br /&gt;
&lt;br /&gt;
*Why is it recommended to use immutable objects as far as possible in order to avoid data races?&lt;br /&gt;
**By the very definition of a data race, immutable objects avoid data races as they prevent threads from writing to them. Refer to the [http://classes.engineering.wustl.edu/cse231/core/index.php/Rundown_on_Everything_Java#Data_Races wiki post] on data races to get a better understanding of the definition of a data race.&lt;br /&gt;
*How are you able to tell when there is a data race in your code?&lt;br /&gt;
**A good rule of thumb is to look for shared mutable data in your code. Whenever you write to data in an async block, make sure that data you write to is adequately protected.&lt;br /&gt;
*Can we use the presence of functional and structural determinism to prove that a program is data race free? I understand that being DRF implies functional and structural determinism, but is the reverse also true?&lt;br /&gt;
**The reverse is not true and DRF actually does not guarantee determinism. This is a complicated topic, but the constructs introduced in Unit 5 will break the &amp;quot;DRF implies determinism&amp;quot; guarantee.&lt;br /&gt;
*Can a program have functional determinism but not structural determinism and vice versa?&lt;br /&gt;
**Yes and a program can also have neither.&lt;br /&gt;
*If a program lacks structural determinism but has functional determinism, is that &amp;quot;bad&amp;quot;? Should you always try to give it structural determinism?&lt;br /&gt;
**Not necessarily, sometimes it does not matter. [[Floodfill]] is a good example of this.&lt;br /&gt;
*When is async and finish better than futures?&lt;br /&gt;
**There are several cases when async/finish would be more appropriate than futures, but generally, anything that would not involve returning a value.&lt;br /&gt;
*What's the difference between memoization and dynamic programming?&lt;br /&gt;
**Memoization is the process of storing the value of an expensive calculation in order to avoid doing the calculation again. Dynamic programming, on the other hand, is the process of breaking up a large problem into smaller, more manageable subproblems (this can, but does not have to, include memoization).&lt;br /&gt;
*Are there ever situations where it would be better to run a function twice rather than utilizing memoization?&lt;br /&gt;
**The purpose of memoization is to balance performance and storage. If the calculation is not taxing but produces a variable that will eat up a lot of storage, it might be better not to store the value if it is only an intermediary variable.&lt;br /&gt;
&lt;br /&gt;
=Unit 3: Forall/Barriers=&lt;br /&gt;
&lt;br /&gt;
*How can you determine if forall is better or finish-async, or are they functionally the same?&lt;br /&gt;
**A forall loop is functionally the same as putting a regular for loop in between a finish and an async. It is up to you which you want to use, but the forall loop serves the purpose of making your code more readable.&lt;br /&gt;
*Can barriers be used in regular asyncs, or do they have to be parallel loops (like forall)?&lt;br /&gt;
**Barriers can be used wherever you put them, but are especially useful for parallel loops.&lt;br /&gt;
*Is a barrier simply analogous to a finish-block within a forall loop?&lt;br /&gt;
**No, it would be more accurate to think of a barrier as a type of phaser with an implicit wait command.&lt;br /&gt;
&lt;br /&gt;
=Unit 4: Phasers/Deadlock=&lt;br /&gt;
&lt;br /&gt;
*How would you recreate fuzzy barriers with asyncs and finishes?&lt;br /&gt;
**You cannot, fuzzy barriers create previously impossible computation graphs.&lt;br /&gt;
*Is it possible for two phasers to be dependent on each other, thereby breaking the program?&lt;br /&gt;
**Yes, this is called a deadlock.&lt;br /&gt;
*What kind of error will be thrown if we enter deadlock? Or would the program never terminate?&lt;br /&gt;
**Unless you explicitly define an error that would appear after a set amount of time, the program would just never terminate.&lt;br /&gt;
*Why use await instead of normal futures?&lt;br /&gt;
**Either one works, but you would need to use await if you wanted to execute task B after A without using the value generated from A or if A does not return a value (futures return values).&lt;br /&gt;
&lt;br /&gt;
=Unit 5: Isolated/Synchronized/Locks/Atomics=&lt;br /&gt;
&lt;br /&gt;
*What are locks and semaphores?&lt;br /&gt;
**Locks prevent a protected piece of code from running in parallel, forcing threads to access data one after the other. Each class has its own intrinsic lock and locks can also be set explicitly. Semaphores restrict threads from accessing a protected piece of data, but unlike locks, [https://stackoverflow.com/questions/34519/what-is-a-semaphore semaphores can allow more than one consumer access to a specific piece of data.]&lt;br /&gt;
*What is the difference between isolated and synchronized?&lt;br /&gt;
**They serve the same functional purpose, but isolated has the added perk of being able to specify read/write access with object-based isolation. You can use whichever you prefer.&lt;br /&gt;
*Does isolation naturally take up more resources? That is to say, in cases where data race is not a problem, would there be no reason to use isolation?&lt;br /&gt;
**Isolated is only used to protect shared mutable data, so it would be useless to call it when a program is already DRF.&lt;br /&gt;
*Are there such things as atomic strings or even data structures?&lt;br /&gt;
**Yes, there are several protected data structures built into Java. Check out [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/package-summary.html java.util.concurrent] for some more examples!&lt;br /&gt;
*Are atomic variables just a shorthand for object-based isolated constructs?&lt;br /&gt;
**You can think of them that way, but many of them are specifically optimized so that they often surpass simple object-based isolation in performance.&lt;br /&gt;
*Can we go over the difference between Atomic Integers and finish accumulators?&lt;br /&gt;
**You can choose to use them the exact same way if you would like, but atomic integers are slightly more versatile as they have more options for operations.&lt;br /&gt;
*How do we quantitatively define low, medium, and high contention?&lt;br /&gt;
**This is something you will just have to feel out. If you are only accessing one piece of shared mutable data, that might be low contention. If, however, you are reading and writing to multiple variables in parallel to the point that the parallel implementation performs worse than a sequential approach, this would be high contention. You will become better at judging this as the semester goes on.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse231/core/index.php?title=FAQ&amp;diff=236</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse231/core/index.php?title=FAQ&amp;diff=236"/>
		<updated>2017-07-31T16:35:37Z</updated>

		<summary type="html">&lt;p&gt;Benjaminchoi: /* Unit 2: Futures/Accumulators/Data Races/Memoization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We have gathered the most frequently asked questions on Piazza and the Q&amp;amp;S forms on this wiki for your convenience.&lt;br /&gt;
&lt;br /&gt;
=Unit 1: Async/Finish=&lt;br /&gt;
&lt;br /&gt;
*For the demo, he uses a threshold to determine whether or not to use the parallel version. How does he decide that threshold? Is it machine dependent? Or algorithm dependent?&lt;br /&gt;
**The threshold is often specified as an input parameter in a parallel method. The user often sets the value depending on the algorithm based on the overhead of starting a parallel process.&lt;br /&gt;
*Is async and finish features of the Java language or specific to this class?&lt;br /&gt;
**Async and finish are features of Habanero Java, a tool built by Rice University. It is not native to Java but we will use it in this class for its simplicity.&lt;br /&gt;
*When doing Quicksort, why is it more efficient to place the finish inside the main method?&lt;br /&gt;
**When performing recursive methods in parallel, it is most efficient to place the finish around the initial call as you want the subsequent inner calls to run asynchronously. Thus, you should wrap the async around the inner recursive call and the finish around the initial outer call.&lt;br /&gt;
*Are we assuming that the core of the CPU is infinite?&lt;br /&gt;
**When dealing with theory, we will assume it is infinite unless otherwise specified. When coding, we will take hybrid approaches where we will sometimes assume it is infinite and sometimes code realistically to adjust for the finite number of cores.&lt;br /&gt;
*In the videos and quizzes, we assumed finish and asyncs added no work to the computation graph. In reality, is there some amount of work needed for them?&lt;br /&gt;
**Yes, that work is what we are referring to when we talk about overhead. In order to account for this, you should only run a program in parallel if the amount of work overshadows the overhead costs.&lt;br /&gt;
*How does concurrency affect timing with a single core?&lt;br /&gt;
**With a single core, it becomes impossible to launch programs in parallel, but concurrent programming is still possible. Under such a scenario, whatever you async'd will still execute as separate threads, but it will simply run on the single core. Thus, the order in which the threads execute is still not guaranteed, meaning it will not run like sequential code. For a more detailed explanation, refer to [https://stackoverflow.com/questions/1897993/what-is-the-difference-between-concurrent-programming-and-parallel-programming this] article.&lt;br /&gt;
&lt;br /&gt;
=Unit 2: Futures/Accumulators/Data Races/Memoization=&lt;br /&gt;
&lt;br /&gt;
*Why is it recommended to use immutable objects as far as possible in order to avoid data races?&lt;br /&gt;
**By the very definition of a data race, immutable objects avoid data races as they prevent threads from writing to them. Refer to the [http://classes.engineering.wustl.edu/cse231/core/index.php/Rundown_on_Everything_Java#Data_Races wiki post] on data races to get a better understanding of the definition of a data race.&lt;br /&gt;
*How are you able to tell when there is a data race in your code?&lt;br /&gt;
**A good rule of thumb is to look for shared mutable data in your code. Whenever you write to data in an async block, make sure that data you write to is adequately protected.&lt;br /&gt;
*Can we use the presence of functional and structural determinism to prove that a program is data race free? I understand that being DRF implies functional and structural determinism, but is the reverse also true?&lt;br /&gt;
**The reverse is not true and DRF actually does not guarantee determinism. This is a complicated topic, but the constructs introduced in Unit 5 will break the &amp;quot;DRF implies determinism&amp;quot; guarantee.&lt;br /&gt;
*Can a program have functional determinism but not structural determinism and vice versa?&lt;br /&gt;
**Yes and a program can also not have either.&lt;br /&gt;
*If a program lacks structural determinism but has functional determinism, is that &amp;quot;bad&amp;quot;? Should you always try to give it structural determinism?&lt;br /&gt;
**Not necessarily, sometimes it does not matter. [[Floodfill]] is a good example of this.&lt;br /&gt;
*When is async and finish better than futures?&lt;br /&gt;
**There are several cases when async/finish would be more appropriate than futures, but generally, anything that would not involve returning a value.&lt;br /&gt;
*What's the difference between memoization and dynamic programming?&lt;br /&gt;
**Memoization is the process of storing the value of an expensive calculation in order to avoid doing the calculation again. Dynamic programming, on the other hand, is the process of breaking up a large problem into smaller, more manageable subproblems (this can, but does not have to, include memoization).&lt;br /&gt;
*Are there ever situations where it would be better to run a function twice rather than utilizing memoization?&lt;br /&gt;
**The purpose of memoization is to balance performance and storage. If the calculation is not taxing but produces a variable that will eat up a lot of storage, it might be better not to store the value if it is only an intermediary variable.&lt;br /&gt;
&lt;br /&gt;
=Unit 3: Forall/Barriers=&lt;br /&gt;
&lt;br /&gt;
*How can you determine if forall is better or finish-async, or are they functionally the same?&lt;br /&gt;
**A forall loop is functionally the same as putting a regular for loop in between a finish and an async. It is up to you which you want to use, but the forall loop serves the purpose of making your code more readable.&lt;br /&gt;
*Can barriers be used in regular asyncs, or do they have to be parallel loops (like forall)?&lt;br /&gt;
**Barriers can be used wherever you put them, but are especially useful for parallel loops.&lt;br /&gt;
*Is a barrier simply analogous to a finish-block within a forall loop?&lt;br /&gt;
**No, it would be more accurate to think of a barrier as a type of phaser with an implicit wait command.&lt;br /&gt;
&lt;br /&gt;
=Unit 4: Phasers/Deadlock=&lt;br /&gt;
&lt;br /&gt;
*How would you recreate fuzzy barriers with asyncs and finishes?&lt;br /&gt;
**You cannot, fuzzy barriers create previously impossible computation graphs.&lt;br /&gt;
*Is it possible for two phasers to be dependent on each other, thereby breaking the program?&lt;br /&gt;
**Yes, this is called a deadlock.&lt;br /&gt;
*What kind of error will be thrown if we enter deadlock? Or would the program never terminate?&lt;br /&gt;
**Unless you explicitly define an error that would appear after a set amount of time, the program would just never terminate.&lt;br /&gt;
*Why use await instead of normal futures?&lt;br /&gt;
**Either one works, but you would need to use await if you wanted to execute task B after A without using the value generated from A or if A does not return a value (futures return values).&lt;br /&gt;
&lt;br /&gt;
=Unit 5: Isolated/Synchronized/Locks/Atomics=&lt;br /&gt;
&lt;br /&gt;
*What are locks and semaphores?&lt;br /&gt;
**Locks prevent a protected piece of code from running in parallel, forcing threads to access data one after the other. Each class has its own intrinsic lock and locks can also be set explicitly. Semaphores restrict threads from accessing a protected piece of data, but unlike locks, [https://stackoverflow.com/questions/34519/what-is-a-semaphore semaphores can allow more than one consumer access to a specific piece of data.]&lt;br /&gt;
*What is the difference between isolated and synchronized?&lt;br /&gt;
**They serve the same functional purpose, but isolated has the added perk of being able to specify read/write access with object-based isolation. You can use whichever you prefer.&lt;br /&gt;
*Does isolation naturally take up more resources? That is to say, in cases where data race is not a problem, would there be no reason to use isolation?&lt;br /&gt;
**Isolated is only used to protect shared mutable data, so it would be useless to call it when a program is already DRF.&lt;br /&gt;
*Are there such things as atomic strings or even data structures?&lt;br /&gt;
**Yes, there are several protected data structures built into Java. Check out [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/package-summary.html java.util.concurrent] for some more examples!&lt;br /&gt;
*Are atomic variables just a shorthand for object-based isolated constructs?&lt;br /&gt;
**You can think of them that way, but many of them are specifically optimized so that they often surpass simple object-based isolation in performance.&lt;br /&gt;
*Can we go over the difference between Atomic Integers and finish accumulators?&lt;br /&gt;
**You can choose to use them the exact same way if you would like, but atomic integers are slightly more versatile as they have more options for operations.&lt;br /&gt;
*How do we quantitatively define low, medium, and high contention?&lt;br /&gt;
**This is something you will just have to feel out. If you are only accessing one piece of shared mutable data, that might be low contention. If, however, you are reading and writing to multiple variables in parallel to the point that the parallel implementation performs worse than a sequential approach, this would be high contention. You will become better at judging this as the semester goes on.&lt;/div&gt;</summary>
		<author><name>Benjaminchoi</name></author>
		
	</entry>
</feed>