Question: With c++ application A. Convert the singly linked list class that we implemented in the lab -or the one under content- to have a circularly
With c++ application
A. Convert the singly linked list class that we implemented in the lab -or the one under content- to have a circularly linked list.
Set the next reference of the tail node of the singly linked list to reference back to the head of the list.
Modify all the public behaviors of the singly linked list to match the modification of the circularly linked list
Define method rotate(), this method moves the first element to the end of the list
B. Implement a doubly linked list: In a doubly linked list each node keeps an explicit reference prev to the node before it and a reference next to the node after it.
Add special dummy nodes at both ends of the list, name them header & trailer: these are sentinels node, they dont store elements of the primary sequence.
When using sentinel nodes, an empty list is initialized so that the next field of the header points to the trailer, and the prev field of the trailer points to the header; the remaining fields of the sentinels are irrelevant
Make sure to implement all the following methods
size( ): Returns the number of elements in the list.
isEmpty( ): Returns true if the list is empty, and false otherwise.
first( ): Returns (but does not remove) the first element in the list.
last( ): Returns (but does not remove) the last element in the list.
addFirst(e): Adds a new element to the front of the list.
addLast(e): Adds a new element to the end of the list.
removeFirst( ): Removes and returns the first element of the list.
removeLast( ): Removes and returns the last element of the list.
Dont forget to implement the Display() and toString() functions.
Add comments Write the main function that shows the usage of both lists
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
