Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a singly linked list ADT to store a collection of integers. The ADT wi

ID: 3801906 • Letter: I

Question

Implement a singly linked list ADT to store a collection of integers.

The ADT will include the following member functions:

--- a default constructor

--- the "big-3": destructor, copy constructor and overloaded assignment operator

1. a member function InsertFront(int data) that inserts a number at the front of the list

2. a member function append(int data) that appends a number at the back of the list

3. a member function popFirst() that removes first element of the list.

4. a member function popLast() that removes last element of the list.

6. a member function that deletes a number and all its copies from the list, where these copies can be located anywhere in the list.

7. a member function MtoLastElement(int M) that returns Mth to the last element of a list such that when M = 0, the last element of the list is returned.

8. a member function that returns the size of the list.

9. an overloaded put operator (<<) to print out all the data items stored on a linked list. Note that you are recommended to overload this operator as a friend function of the List class.

10. a member function that reverses a linked list without recreating a temporary copy of this linked list. In other words, your function CAN NOT use the 'new' operator. Here is an example, if a list contains the following data items, 3 -> 5 -> 1 -> 7; this reverse() function will change the list to 7 -> 1 -> 5 -> 3.

Explanation / Answer

Linked list :-

A linked list is a collection of nodes that together form a linear ordering. It takes many different forms and implementation. In its most simplest form, a singly linked list is a linked list where each node is an object that stores a reference to an element and a reference, called next, to another node. Note that a node is defined in terms of itself, which is called self-referential structure.

singly likned list:-

Singly linked lists contain nodes which have a data field as well as a next field, which points to the next node in the sequence. Operations that can be performed on singly linked lists are insertion, deletion and traversal.

-------------------

/*code for above

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote