Question: 1. Draw a sketch of a singly linked list containing the following int values: 3, 1, 4, 1, 5. The 3 should be at the

1. Draw a sketch of a singly linked list containing the following int values: 3, 1, 4, 1, 5. The 3 should be at the front of the list. Remember to sketch the head pointer, each node, and each node's next pointer.

2. Write the code for the following new member function for our SinglyLinkedList class. You should write out the definition of the function, but do not need to write out all of the rest of the class. Your code should use the assert macro to enforce any relevant contracts.

// Insert x at the second position in the list. The current front element will remain at the front; // x will be the element immediately after the front; and any other elements come after x. // This function must not be called when the list is empty. void add_after_front(ELT x); 

3. Write the code for the following new member function for our SinglyLinkedList class. You should write out the definition of the function, but do not need to write out all of the rest of the class. Your code should use the assert macro to enforce any relevant contracts. Hint: you will need to use a loop or recursion.

// Return the last element contained in the list. // This function must not be called when the list is empty. ELT back(); 

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!