Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
Question
Book Icon
Chapter 3, Problem 33C
Program Plan Intro

Initial consideration:

While the circularly liked list implementation has to be provided using inheritance in such a way that a DoublyLinkedList class inherits from the existing CircularlyLinkedList, and the DoublyLinkedList.Node nested class inherits from CircularlyLinkedList.Node.

The following consideration has to be made before implementation:

  • A circular version of a doubly linked list has to be implemented that is not having any sentinels that can generally supports the public behaviors of the original and new update methods.
  • The implemented circular doubly linked list should have method called rotate() which is used to rotate the linked list counter clockwise and rotateBackward() method that can support the  public behaviors of the linked list.
  • There is no need to use the sentinel nodes which are more generally useful with linked list implementation that helps to maintain the reference of all nodes of a doubly linked list.
  • The node in the circular version of doubly linked list maintains two references with the previous and the next node in the doubly linked list.

Doubly-linked list:

  • Doubly-linked list is a kind of data structure in which every node in the list has two link pointers where one link is pointing to previous node and the link will point to the next node in the list.
  • The first node in the linked list generally points to a Null pointer and the next link of the last node in the linked list is pointing to the Null.

CircularlyLinkedList:

  • Circular Linked List is also a kind of data structure where all the nodes in the list are in the formed of a circular fashion.
  • The circular pattern can be a singly or doubly linked list. Unlike doubly linked list there is no Null pointer in the circular linked list. The nodes are added and removed based on the constant time factor.
  • The main advantage of circular linked list is the ability to traverse the nodes of the linked list.

Inheritance:

  • In object-oriented programming (OOP) inheritance is a procedure to create new class from an existing class which is known as base class or super class and the inherited class is known as derived class or sub class and the new class will inherits all the properties of the existing parent class.

Blurred answer
Students have asked these similar questions
4. Suppose our MyLinkedList class represented a doubly linked list, where each Node is implemented as follows: private class Node { Node prev, next; E element; } public Node (E element) { } this.element = element; Each Node has a reference to the previous Node as well as to the next Node in the list. MINIMALLY modify the add(int index, E element) method below to work properly with the doubly linked Nodes, and highlight or underline your changes.
Programming Exercise 8 asks you to redefine the class to implement the nodes of a linked list so that the instance variables are private. Therefore, the class linkedListType and its derived classes unorderedLinkedList and orderedLinkedList can no longer directly access the instance variables of the class nodeType. Rewrite the definitions of these classes so that these classes use the member functions of the class nodeType to access the info and link fields of a node. Also write programs to test various operations of the classes unorderedLinkedList and orderedLinkedList.   template <class Type>class nodeType{public:const nodeType<Type>& operator=(const nodeType<Type>&);//Overload the assignment operator.void setInfo(const Type& elem);//Function to set the info of the node.//Postcondition: info = elem;Type getInfo() const;//Function to return the info of the node.//Postcondition: The value of info is returned.void setLink(nodeType<Type>…
Use the ArrayList class Add and remove objects from an ArrayList Protect from index errors when removing Practice with input loop Details: This homework is for you to get practice adding and removing objects from an ArrayList. The Voter class was used to create instances of Voters which held their name and a voter identification number as instance variables, and the number of instances created as a static variable. This was the class diagram:   The constructor takes a string, passed to the parameter n, which is the name of the voter and which should be assigned to the name instance variable. Every time a new voter is created, the static variable nVoters should be incremented. Also, every time a new voter is created, a new voterID should be constructed by concatenating the string “HI” with the value of nVoters and the length of the name. For example, if the second voter is named “Clark Kent”, then the voterID should be “HI210” because 2 is the value of nVoters and 10 is the number…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning