<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.lensovet.net/~sysadmin/w/index.php?action=history&amp;feed=atom&amp;title=Computer_Science%2F61b%2FHomework%2Fhw3</id>
	<title>Computer Science/61b/Homework/hw3 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.lensovet.net/~sysadmin/w/index.php?action=history&amp;feed=atom&amp;title=Computer_Science%2F61b%2FHomework%2Fhw3"/>
	<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw3&amp;action=history"/>
	<updated>2026-05-03T04:35:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw3&amp;diff=24303&amp;oldid=prev</id>
		<title>Lensovet: Lensovet moved page CS/61b/Homework/hw3 to Computer Science/61b/Homework/hw3</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw3&amp;diff=24303&amp;oldid=prev"/>
		<updated>2023-02-20T03:51:34Z</updated>

		<summary type="html">&lt;p&gt;Lensovet moved page &lt;a href=&quot;/~sysadmin/w/CS/61b/Homework/hw3&quot; class=&quot;mw-redirect&quot; title=&quot;CS/61b/Homework/hw3&quot;&gt;CS/61b/Homework/hw3&lt;/a&gt; to &lt;a href=&quot;/~sysadmin/w/Computer_Science/61b/Homework/hw3&quot; title=&quot;Computer Science/61b/Homework/hw3&quot;&gt;Computer Science/61b/Homework/hw3&lt;/a&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 03:51, 20 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw3&amp;diff=3991&amp;oldid=prev</id>
		<title>Lensovet: moved CS 61b/Homework/hw3 to CS/61b/Homework/hw3:&amp;#32;fix cs 61b hierarchy</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw3&amp;diff=3991&amp;oldid=prev"/>
		<updated>2010-11-14T06:00:19Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/~sysadmin/w/CS_61b/Homework/hw3&quot; class=&quot;mw-redirect&quot; title=&quot;CS 61b/Homework/hw3&quot;&gt;CS 61b/Homework/hw3&lt;/a&gt; to &lt;a href=&quot;/~sysadmin/w/CS/61b/Homework/hw3&quot; class=&quot;mw-redirect&quot; title=&quot;CS/61b/Homework/hw3&quot;&gt;CS/61b/Homework/hw3&lt;/a&gt;: fix cs 61b hierarchy&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 06:00, 14 November 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw3&amp;diff=2967&amp;oldid=prev</id>
		<title>Lensovet at 19:59, 22 May 2007</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw3&amp;diff=2967&amp;oldid=prev"/>
		<updated>2007-05-22T19:59:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Files==&lt;br /&gt;
*[[/Homework3.java]]&lt;br /&gt;
*[[/SList.java]]&lt;br /&gt;
*[[/SListNode.java]]&lt;br /&gt;
*[[/TestHelper.java]]&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
                              CS 61B Homework 3 &lt;br /&gt;
                     Due 4pm Friday, September 22, 2006 &lt;br /&gt;
This homework assignment is designed to give you practice working with arrays, &lt;br /&gt;
linked lists, and nested loops.  It will also give you practice for the similar &lt;br /&gt;
but harder run-length encoding computations in Project 1.  This is an &lt;br /&gt;
individual assignment; you may not share code with other students. &lt;br /&gt;
Copy the Homework 3 directory by doing the following, starting from your home &lt;br /&gt;
directory: &lt;br /&gt;
    mkdir hw3 &lt;br /&gt;
    cd hw3 &lt;br /&gt;
    cp $master/hw/hw3/* . &lt;br /&gt;
Your task is to write two methods for removing successive duplicate items from &lt;br /&gt;
lists, and one method for adding them.  The smoosh() method operates on lists &lt;br /&gt;
represented as arrays, and the squish() method and twin() method operate on &lt;br /&gt;
singly-linked lists. &lt;br /&gt;
The Homework3 class includes test code for all three methods, as well as a &lt;br /&gt;
skeleton for the smoosh() method.  The SList class from Lab 3 is also present, &lt;br /&gt;
and here includes skeletons for the squish() method and the twin() method. &lt;br /&gt;
You can test all three methods by compiling and running Homework3.java.  As &lt;br /&gt;
usual, you are welcome to add test cases to the main() method or change main() &lt;br /&gt;
as you please; we will not test main().  However, you cannot change the &lt;br /&gt;
interface of the public methods and classes, because our autograder will use &lt;br /&gt;
them.  So you might want to keep the main() test code around--if you &lt;br /&gt;
accidentally change a prototype, the test code will catch it. &lt;br /&gt;
You may NOT use Java’s built-in data structure libraries, like java.util.Vector &lt;br /&gt;
or java.util.LinkedList, in this homework (or any future homework, except where &lt;br /&gt;
otherwise specified).  All data structure implementations should be your own or &lt;br /&gt;
those taken from lectures/labs/homeworks. &lt;br /&gt;
&lt;br /&gt;
===Part I  (5 points)=== &lt;br /&gt;
Fill in the smoosh() method in the Homework3 class so that it performs as &lt;br /&gt;
indicated in the comment.  Your solution should not use linked lists, nor &lt;br /&gt;
should it use your squish() method. &lt;br /&gt;
  /** &lt;br /&gt;
   *  smoosh() takes an array of ints.  On completion the array contains &lt;br /&gt;
   *  the same numbers, but wherever the array had two or more consecutive &lt;br /&gt;
   *  duplicate numbers, they are replaced by one copy of the number.  Hence, &lt;br /&gt;
   *  after smoosh() is done, no two consecutive numbers in the array are the &lt;br /&gt;
   *  same. &lt;br /&gt;
   * &lt;br /&gt;
   *  Any unused elements at the end of the array are set to -1. &lt;br /&gt;
   * &lt;br /&gt;
   *  For example, if the input array is [ 0 0 0 0 1 1 0 0 0 3 3 3 1 1 0 ], &lt;br /&gt;
   *  it reads [ 0 1 0 3 1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 ] after smoosh() &lt;br /&gt;
   *  completes. &lt;br /&gt;
   * &lt;br /&gt;
   *  @param ints the input array. &lt;br /&gt;
   **/ &lt;br /&gt;
  private static void smoosh(int[] ints) { &lt;br /&gt;
    // Fill in your solution here.  (Ours is fourteen lines long, not counting &lt;br /&gt;
    // blank lines or lines already present in this file.) &lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
===Part II  (3 points)=== &lt;br /&gt;
Fill in the squish() method in the SList class so that it performs as indicated &lt;br /&gt;
in the comment.  Your solution should not use arrays, nor should it use your &lt;br /&gt;
smoosh() method.  Do not change the prototype of the SList constructor or the &lt;br /&gt;
insertEnd method; our test software will call them. &lt;br /&gt;
  /** &lt;br /&gt;
   *  squish() takes this list and, wherever two or more consecutive items are &lt;br /&gt;
   *  equal(), it removes duplicate nodes so that only one consecutive copy &lt;br /&gt;
   *  remains.  Hence, no two consecutive items in this list are equal() upon &lt;br /&gt;
   *  completion of the procedure. &lt;br /&gt;
   * &lt;br /&gt;
   *  After squish() executes, the list may well be shorter than when squish() &lt;br /&gt;
   *  began.  No extra items are added to make up for those removed. &lt;br /&gt;
   * &lt;br /&gt;
   *  For example, if the input list is [ 0 0 0 0 1 1 0 0 0 3 3 3 1 1 0 ], the &lt;br /&gt;
   *  output list is [ 0 1 0 3 1 0 ]. &lt;br /&gt;
   * &lt;br /&gt;
   *  IMPORTANT:  Be sure you use the equals() method, and not the &amp;quot;==&amp;quot; &lt;br /&gt;
   *  operator, to compare items. &lt;br /&gt;
   **/ &lt;br /&gt;
  public void squish() { &lt;br /&gt;
    // Fill in your solution here.  (Ours is eleven lines long.) &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
===Part III  (2 points)===&lt;br /&gt;
Fill in the twin() method in the SList class so that it performs as indicated &lt;br /&gt;
in the comment.  Your solution should not use arrays. &lt;br /&gt;
  /** &lt;br /&gt;
   *  twin() takes this list and doubles its length by replacing each node &lt;br /&gt;
   *  with two consecutive nodes referencing the same item. &lt;br /&gt;
   * &lt;br /&gt;
   *  For example, if the input list is [ 3 7 4 2 2 ], the &lt;br /&gt;
   *  output list is [ 3 3 7 7 4 4 2 2 2 2 ]. &lt;br /&gt;
   * &lt;br /&gt;
   *  IMPORTANT:  Do not try to make new copies of the items themselves. &lt;br /&gt;
   *  Just copy the references to the items. &lt;br /&gt;
   **/ &lt;br /&gt;
  public void twin() { &lt;br /&gt;
    // Fill in your solution here.  (Ours is seven lines long.) &lt;br /&gt;
  }&lt;/div&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
</feed>