Homework #3 (Due Date: Saturday July 30 by midnight)

Submit your homework via E-learning

Select your 2 code files (main.cpp and doublyCircularLL.h) and compress them into a file named StudentID_FirstName.zip
Note: use Winrar to compress your files.

Doubly Circular Linked List
Write your own code to implement a doubly circular linked list that has the following properties.

Doubly Circular Linked List does not have a null pointer at the end. How do you know that you have reached the end of the list?

download doublyCircularLL.h here.

doublyCircularLL class


using namespace std;

template <class Type>
struct nodeType
	Type info;
	nodeType* next;
	nodeType* back;

template <class Type>
class doublyCircularLL
	doublyCircularLL ();
	doublyCircularLL (const doublyCircularLL<Type>& otherlist);
	~doublyCircularLL ();

	const doublyCircularLL<Type>& operator= (const doublyCircularLL<Type>& otherlist);

	bool isEmptyList () const;
	Type front () const;

	Type back () const;
	nodeType<Type>* begin () const;

	nodeType<Type>* end () const;

	// implement the functions below yourself
	int lenght () const;
	Type maximum () const;

	Type minimum () const;

	void print () const;

	void insert (const Type& newItem);

	void deleteNode (const Type& deleteItem);

	bool search (const Type& searchItem) const;

	void destroy ();


	nodeType<Type>* first;		// pointer to first node

	void copyList (const doublyCircularLL<Type>& otherlist);
...			// functions definitions here 

  1. [2 point]
    int lenght () const;

    Returns how many nodes in the list.
  2. [1 point]
    Type maximum () const;

    In an ordered list, maximum is the last node.
  3. [1 point]
    Type minimum () const;

    In an ordered list, minimum is the first node.
  4. [1 point]
    void print () const;

    Prints all elements in the list.
  5. [2 point]
    void insert (const Type& newItem);

    if newItem is already in the list, nothing will happen.

    find a node that has info greater than newItem and insert it right before that node.

    otherwise, insert newItem at the end of the list.

  6. [2 point]
    void deleteNode (const Type& deleteItem);

    if deleteItem is not in the list, nothing will happen.
    delete deleteItem.
  7. [2 point]
    bool search (const Type& searchItem) const;

    returns true if searchItem is in the list, false otherwise.
  8. [2 point]
    void copyList (const doubleCircularLL& otherlist);

    Make this object an exact copy of otherlist. This function is called in the copy constructor and assignment operator overlaoding function.
  9. [7 points]
    In main.cpp
    , test all the functionality of doublyCircularLL class.