Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Extend the source code for the Singly Linked List (attached to the quiz description) by adding a member function to find the middle value of

image text in transcribed

Extend the source code for the Singly Linked List (attached to the quiz description) by adding a member function to find the middle value of the elements in the List. Also, extend the main function given in the source code to call the member function and print the return value (i.e., the middle value of the elements in the List). Test your program with both even and odd values for the size of the Linked List. If 'n' is the size of the Linked List, the program should print the n/2th element in the Linked List if 'n' is even and print the (n - 1)/2th element in the Linked List if 'n' is odd. You should test the program with two values (an odd value and an even value) for the size of the Linked List that could range anywhere from 10 to 20. The maximum value for any element in the Linked List is 50. You are not supposed to add any indexing variable or member function to the Node class. Also, you are required to use the existing private variables and public member functions of the List class in the source code and do the implementation. All of the computations should be incorporated in the member function to compute the middle value of the elements in the List. Consider the implementation of the List class using dynamic arrays (attached to the quiz description). Add a member function called clone() to the List class that returns an object of class 'List' itself. List clone(){ ...... } The clone function should basically create a new List object, copy the contents of the original integerList object on which the function is called to the new List and return the clone to the main function. You should not create any other function to do this cloning and just make use of one or more of the existing functions in the current version of the List class as posted in the Lecture code. You should be able to print the contents of the cloned list by calling the print() member function on the cloned List object. If 'integerList' is the name of the original object of class List created in your main function, the clone() should be called as follows. The call to the print() function should follow next. List clonel.ist = integerList.clone(): clonelList.print(): Submission (through Canvas): Submit a single word document that contains the complete C++/Java code (that includes the new member functions added along with the existing member functions) of the linked list-based List class and the main function (for question 1) and the dynamic array-based List class and the main function (for question 2) along with a screenshot of the execution

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions