Singly Linked List ( Due 25 Mar 2014 )

In this assignment you will be writing helper methods for the LinkedList class that we developed and test them. The following is the outline of the code that you will be submitting. For the time being assume that the data that you are handling are integers. Later on when you use objects of other classes you will write compare functions for those classes and you can use your LinkedList class as is.

class Link (object):
  ...

class LinkedList (object):
  # get number of links 
  def getNumLinks (self):
  
  # Add data at the beginning of the list
  def addFirst (self, data): 

  # Add data at the end of a list
  def addLast (self, data): 

  # Add data in an ordered list in ascending order
  def addInOrder (self, data): 

  # Search in an unordered list, return None if not found
  def findUnordered (self, data): 

  # Search in an ordered list, return None if not found
  def findOrdered (self, data): 

  # Delete and return Link from an unordered list or None if not found
  def delete (self, data):

  # String representation of data 10 items to a line, 2 spaces between data
  def __str__ (self):

  # Copy the contents of a list and return new list
  def copyList (self):

  # Reverse the contents of a list and return new list
  def reverseList (self): 

  # Sort the contents of a list in ascending order and return new list
  def sortList (self): 

  # Return True if a list is sorted in ascending order or False otherwise
  def isSorted (self):

  # Return True if a list is empty or False otherwise
  def isEmpty (self): 

  # Merge two sorted lists and return new list in ascending order
  def mergeList (self, b): 

  # Test if two lists are equal, item by item and return True
  def isEqual (self, b):

  # Return a new list, keeping only the first occurence of an element
  # and removing all duplicates. Do not change the order of the elements.
  def removeDuplicates (self):

def main():
  # Test methods addFirst() and __str__() by adding more than
  # 10 items to a list and printing it.

  # Test method addLast()

  # Test method addInOrder()

  # Test method getNumLinks()

  # Test method findUnordered() 
  # Consider two cases - item is there, item is not there 

  # Test method findOrdered() 
  # Consider two cases - item is there, item is not there 

  # Test method delete()
  # Consider two cases - item is there, item is not there 

  # Test method copyList()

  # Test method reverseList()

  # Test method sortList()

  # Test method isSorted()
  # Consider two cases - list is sorted, list is not sorted

  # Test method isEmpty()

  # Test method mergeList()

  # Test method isEqual()
  # Consider two cases - lists are equal, lists are not equal

  # Test removeDuplicates()

The file that you will be turning in will be called TestLinkedList.py. The file will have a header of the following form:


#  File: TestLinkedList.py

#  Description:

#  Student Name:

#  Student UT EID:

#  Course Name: CS 313E

#  Unique Number: 53580

#  Date Created:

#  Date Last Modified:

Use the turnin program to submit your TestLinkedList.py file. We should receive your work by 11 PM on Tuesday, 25 Mar 2014. There will be substantial penalties if you do not adhere to the guidelines. The student assistant in charge of this assignment is Bon Koo (bonkoo@utexas.edu).