More Practice with Loops

To start this activity, snarf the project loops.

Compress

Complete the method, compress, that compresses a given list of data by removing duplicate values when they appear together in the list. For example, given the top list below, your method should return the bottom list.

Your method should work by creating a new list that has the same elements in the same order as the original list, but without any duplicate elements immediately following each element.

Remove

Complete the method, remove, that removes all occurrences of a given element from a given list of data. For example, if the value 0 was passed to your method along with the top list below, your method should return the bottom list.

Your method should work by creating a new list that has the same elements in the same order as the original list, but without any elements that equal the one to remove.

Partition

Complete the method, partition, that divides a given list of data so that all elements less than a given element are in the beginning of the list and all elements greater than the element are moved to the end. It does not matter how the elements are ordered on their respective sides, just so that they are properly divided.  For example, if the value 4 was passed to your method along with the top list below, your method should return the bottom list.

Your method should work by creating a new list that has all the same elements as the original list, but ordered as described above.


Comments?