<?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%2Fhw5</id>
	<title>Computer Science/61b/Homework/hw5 - 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%2Fhw5"/>
	<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw5&amp;action=history"/>
	<updated>2026-05-01T15:31:55Z</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/hw5&amp;diff=24327&amp;oldid=prev</id>
		<title>Lensovet: Lensovet moved page CS/61b/Homework/hw5 to Computer Science/61b/Homework/hw5</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw5&amp;diff=24327&amp;oldid=prev"/>
		<updated>2023-02-20T03:51:35Z</updated>

		<summary type="html">&lt;p&gt;Lensovet moved page &lt;a href=&quot;/~sysadmin/w/CS/61b/Homework/hw5&quot; class=&quot;mw-redirect&quot; title=&quot;CS/61b/Homework/hw5&quot;&gt;CS/61b/Homework/hw5&lt;/a&gt; to &lt;a href=&quot;/~sysadmin/w/Computer_Science/61b/Homework/hw5&quot; title=&quot;Computer Science/61b/Homework/hw5&quot;&gt;Computer Science/61b/Homework/hw5&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/hw5&amp;diff=4015&amp;oldid=prev</id>
		<title>Lensovet: moved CS 61b/Homework/hw5 to CS/61b/Homework/hw5:&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/hw5&amp;diff=4015&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/hw5&quot; class=&quot;mw-redirect&quot; title=&quot;CS 61b/Homework/hw5&quot;&gt;CS 61b/Homework/hw5&lt;/a&gt; to &lt;a href=&quot;/~sysadmin/w/CS/61b/Homework/hw5&quot; class=&quot;mw-redirect&quot; title=&quot;CS/61b/Homework/hw5&quot;&gt;CS/61b/Homework/hw5&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/hw5&amp;diff=3254&amp;oldid=prev</id>
		<title>Lensovet: /* Files */ +set.java</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw5&amp;diff=3254&amp;oldid=prev"/>
		<updated>2007-09-22T07:05:48Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Files: &lt;/span&gt; +set.java&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 07:05, 22 September 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Files==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Files==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[[/list]] package&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[[/list]] package&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*[[/Set.java]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Description==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Description==&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/hw5&amp;diff=2973&amp;oldid=prev</id>
		<title>Lensovet: /* Part II  (8 points) */ stray char</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw5&amp;diff=2973&amp;oldid=prev"/>
		<updated>2007-05-22T20:07:29Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Part II  (8 points): &lt;/span&gt; stray char&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 20:07, 22 May 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l66&quot; &gt;Line 66:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 66:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The main() method of list.DList contains code to help test your work.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The main() method of list.DList contains code to help test your work.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;�Part &lt;/del&gt;II&amp;#160; (8 points)===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Part &lt;/ins&gt;II&amp;#160; (8 points)===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Your main assignment is to implement a Set ADT in Set.java.&amp;#160; Your Set class&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Your main assignment is to implement a Set ADT in Set.java.&amp;#160; Your Set class&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;must use a List to store the elements of the set.&amp;#160; Your Sets should behave like&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;must use a List to store the elements of the set.&amp;#160; Your Sets should behave like&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/hw5&amp;diff=2972&amp;oldid=prev</id>
		<title>Lensovet at 20:06, 22 May 2007</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw5&amp;diff=2972&amp;oldid=prev"/>
		<updated>2007-05-22T20:06:50Z</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;
*[[/list]] package&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
                              CS 61B  Homework 5&lt;br /&gt;
                       Due 4pm Friday, October 13, 2006&lt;br /&gt;
&lt;br /&gt;
This homework will teach you a more secure way to encapsulate lists than the&lt;br /&gt;
method used in Homework 4, and give you practice using it to accomplish tasks&lt;br /&gt;
quickly.  This is an individual assignment; you may not share code with other&lt;br /&gt;
students.&lt;br /&gt;
&lt;br /&gt;
Copy the Homework 5 directory by doing the following, starting from your home&lt;br /&gt;
directory.  Don't forget the &amp;quot;-r&amp;quot; switch in the cp command.&lt;br /&gt;
&lt;br /&gt;
    mkdir hw5&lt;br /&gt;
    cd hw5&lt;br /&gt;
    cp -r $master/hw/hw5/* .&lt;br /&gt;
&lt;br /&gt;
The list package contains encapsulated DList and SList classes (both of which&lt;br /&gt;
inherit from an abstract List class).  These classes differ from those we have&lt;br /&gt;
seen before in a critical way:  each ListNode knows which List it is in.  A new&lt;br /&gt;
invariant in our Lists is that for any ListNode x in a List l, x.myList = l,&lt;br /&gt;
UNLESS x is the sentinel.  For any sentinel node x, x.myList = null.  Because&lt;br /&gt;
every ListNode knows its List, we can move some of the methods from the List&lt;br /&gt;
class to the ListNode class.&lt;br /&gt;
&lt;br /&gt;
  Methods of List                       | Methods of ListNode&lt;br /&gt;
                                        |&lt;br /&gt;
  public boolean isEmpty()              | public Object item()&lt;br /&gt;
  public int length()                   | public void setItem(Object item)&lt;br /&gt;
  public void insertFront(Object item)  | public ListNode next()               &lt;br /&gt;
  public void insertBack(Object item)   | public ListNode prev()               &lt;br /&gt;
  public ListNode front()               | public void insertAfter(Object item) &lt;br /&gt;
  public ListNode back()                | public void insertBefore(Object item)&lt;br /&gt;
                                        | public void remove()&lt;br /&gt;
                                        | public bolean isValidNode()&lt;br /&gt;
&lt;br /&gt;
One innovation of these classes is the existence of &amp;quot;invalid nodes,&amp;quot; which can&lt;br /&gt;
be identified by the isValidNode() method.  In Homework 4, the methods next()&lt;br /&gt;
and prev() return null when there is no node to return, whereas here they&lt;br /&gt;
return an invalid node.  A node that has been removed from a List is also&lt;br /&gt;
invalid.  With the exception of isValidNode(), any method called on an invalid&lt;br /&gt;
node will throw an InvalidNodeException.  The item field of ListNode is no&lt;br /&gt;
longer public, to prevent manipulation of invalid nodes.&lt;br /&gt;
&lt;br /&gt;
Recall that every ListNode knows what List it is in.  An invalid node is&lt;br /&gt;
represented by any ListNode whose &amp;quot;myList&amp;quot; field is null.  In the DList&lt;br /&gt;
implementation, the sentinel is an invalid node, which simplifies the&lt;br /&gt;
implementations of front(), back(), next(), and prev().  (Take a look at&lt;br /&gt;
DListNode.isValidNode.)&lt;br /&gt;
&lt;br /&gt;
===Part I  (2 points)===&lt;br /&gt;
Complete the implementation of the DList and DListNode classes.&lt;br /&gt;
&lt;br /&gt;
In DList.java, you will need to implement insertFront(), insertBack(), and the&lt;br /&gt;
DList() constructor.  You should be able to cut and paste your solutions from&lt;br /&gt;
Homework 4 unchanged.  The implementations of front() and back() are already&lt;br /&gt;
provided; observe that they are simpler than in Homework 4 because we use&lt;br /&gt;
sentinels as invalid nodes.&lt;br /&gt;
&lt;br /&gt;
In DListNode.java, you will need to implement insertAfter(), insertBefore(),&lt;br /&gt;
and remove().  Your Homework 4 solutions will be a good start, but you'll need&lt;br /&gt;
to make changes to accommodate these methods' move from DList to DListNode.&lt;br /&gt;
&lt;br /&gt;
The main() method of list.DList contains code to help test your work.&lt;br /&gt;
&lt;br /&gt;
===�Part II  (8 points)===&lt;br /&gt;
Your main assignment is to implement a Set ADT in Set.java.  Your Set class&lt;br /&gt;
must use a List to store the elements of the set.  Your Sets should behave like&lt;br /&gt;
mathematical sets, which means they should not contain duplicate items.  To&lt;br /&gt;
make set union and intersection operations run quickly, your Sets will contain&lt;br /&gt;
only Comparable elements, and you will keep them sorted in order from least to&lt;br /&gt;
greatest element.  (You will want to review the Comparable interface on the&lt;br /&gt;
Java API Web page.)&lt;br /&gt;
&lt;br /&gt;
You will need to decide on fields and implement the following methods.&lt;br /&gt;
  public Set()                          // Constructs an empty Set.&lt;br /&gt;
  public int cardinality()              // Number of elements in this Set.&lt;br /&gt;
  public void insert(Comparable c)      // Insert c into this Set.&lt;br /&gt;
  public void union(Set s)              // Assign this = (this union s).&lt;br /&gt;
  public void intersect(Set s)          // Assign this = (this intersect s).&lt;br /&gt;
  public String toString()              // Express this Set as a String.&lt;br /&gt;
&lt;br /&gt;
Unlike in previous assignment, each method comes with prescribed time bounds&lt;br /&gt;
that you must meet when your Set uses DLists (but not when it uses SLists).&lt;br /&gt;
For example, union() and intersect() must run in time proportional to&lt;br /&gt;
this.cardinality() + s.cardinality().  This means you don't have time to make a&lt;br /&gt;
pass through &amp;quot;this&amp;quot; list for each element of s; that would take time&lt;br /&gt;
proportional to this.cardinality() * s.cardinality().  You must take advantage&lt;br /&gt;
of the fact that Sets are sorted to achieve this time bound.  This time bound&lt;br /&gt;
is one reason why Sets may not store duplicate items in their Lists.&lt;br /&gt;
&lt;br /&gt;
On the other hand, insert() need not run in constant time; since each Set uses&lt;br /&gt;
a sorted representation, insert() may need time proportional to the cardinality&lt;br /&gt;
of the Set to find the right place to insert a new element, and to ensure the&lt;br /&gt;
new element doesn't duplicate an old one.&lt;br /&gt;
&lt;br /&gt;
Another constraint is that union() and intersect() may NOT change the Set s.&lt;br /&gt;
Furthermore, intersect() may not create any new ListNodes (it only needs to&lt;br /&gt;
remove ListNodes from &amp;quot;this&amp;quot; List), and union() should reuse all the ListNodes&lt;br /&gt;
in the Set &amp;quot;this&amp;quot;, creating new nodes only for elements of s that &amp;quot;this&amp;quot; List&lt;br /&gt;
lacks.  We will deduct points for failing to meet the time bounds or failing to&lt;br /&gt;
obey these constraints.&lt;br /&gt;
&lt;br /&gt;
Be sure to declare variables of static type List and ListNode in Set.java, not&lt;br /&gt;
variables of type DList, DListNode, SList, or SListNode.  Set.java should be&lt;br /&gt;
able to switch between using DLists and using SLists by changing one&lt;br /&gt;
constructor call in the Set() constructor.  (In fact, you can use SList to help&lt;br /&gt;
you debug Set if you have trouble getting DList working.  But be sure to use a&lt;br /&gt;
DList in your final submission unless you can't get it working.)&lt;br /&gt;
&lt;br /&gt;
Do not modify List.java, ListNode.java, SList.java, or SListNode.java.  Do not&lt;br /&gt;
modify the prototypes in Set.Java, DList.java, or DListNode.java.&lt;br /&gt;
&lt;br /&gt;
===Afterthought (for your own introspection only)===&lt;br /&gt;
If you use SLists instead of DLists, do your union() and intersect() methods&lt;br /&gt;
still run within the time bounds?  If not, how easy would it be to fix them so&lt;br /&gt;
that they do?&lt;/div&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
</feed>