Question: Figure 4.8 shows the linked list implementation, named LList. LList inherits from abstract class List and so must implement all of the member functions of

Figure 4.8 shows the linked list implementation, named LList. LList inherits from abstract class List and so must implement all of the member functions of List (Figure 4.1).

Figure 4.8 shows the linked list implementation, named LList. LList inherits from

A circular linked list is one in which the next field for the last link node of the list points to the first link node of the list. This can be useful when you wish to have a relative positioning for elements, but no concept of an absolute first or last position.

a)Modify the code of Figure 4.8 to implement circular singly linked lists.

abstract class List and so must implement all of the member functions

of List (Figure 4.1). A circular linked list is one in which

template class List // List ADT private void operator = (const List&) List (const List&) // Protect assignment // Protect copy constructor {} public / Default constructor List) virtual List) // Base destructor // Clear contents from the list, to make it empty virtual void clear 0; / Insert an element at the current location // item: The element to be inserted virtual void insert (const E& item)0; // Append an element at the end of the list // item: The element to be appended virtual void append(const E& item) = 0; / Remove and return the current element / Return: the element that was removed virtual E remove() 0; // Set the current position to the start of the list virtual void moveToStart )0 /l Set the current position to the end of the list virtual void moveToEnd) 0; // Move the current position one step left. No change // if already at beginning virtual void prev() 0; // Move the current position one step right. No change // if already at end virtual void next ) 0; // Return: The number of elements in the list virtual int length ) const 0; // Return: The position of the current element. virtual int currPos ) const0 // Set current position // pos The position to make current virtual void moveToPos (int pos)0 / Return: The current element. virtual const E& getValue ) const0; Figure 4.1 The ADT for a list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!