Question: C++ Programming help : Explaination on assignment : This is just more explanation of assingment nothing else. one class or two? you need to create
C++ Programming help :
Explaination on assignment :
This is just more explanation of assingment nothing else.
one class or two? you need to create one single class that contains both a dynamic array and a singly linked list.
(2) size vs. capacity? using our hotel analogy, the capacity of a hotel is the total number of rooms this hotel has; whereas size the number of rooms that are currently occupied by guests. The only difference is that our dynamic array's capacity can be increased as needed. See the next item.
(3) value of capacity? you are strongly recommended to initialized the capacity of the dynamic array to, for example, 100 in the default constructor. This implies that you will need to call the new operator to allocate space correspondingly.
Capacity will likely be increased (e.g., double its value) when calling push_back(). Specifically, push_back() will check if the array's size has reached its capacity. If the answer is yes, push_back() will first resize the array to a larger capacity (e.g., change capacity from 100 to 200); then insert the new value right after all the existing numbers stored in the array.
(4) same contents in the dynamic array and linked list? Yes, that's correct. As mentioned yesterday, the main purpose is to create opportunities for you to practice on pointers. This said, we are not as concerned whether such an ADT is practically useful as we should in practice.
(5) resize the capacity using a separate member function? No, you don't need to create a separate member function to do this. See item(3) above for more details.
----------------------------------
Assingment :
Use pointers to implement a dynamic array and a singly linked list. You will encapsulate both in an ADT. Specifically, your ADT will include the following data members:
int *array; //dynamic array
int size_array; //number of elements stored in the dynamic array
int capacity; //the current number of integer spaces allocated to the dynamic array
struct Node {
int value;
Node *next
};
Node *head; //point to the first node on the linked list
int size_linkedList; //number of nodes on the linked list
Your ADT will also include the following member functions:
a default constructor to initialize the array and linked list correspondingly
the "big-3": destructor, copy constructor and overloaded assignment operator
void push_back(int val ); This member function inserts the value 'val' to the end of the dynamic array and the end of the linked list. Note that this function will require memory allocation (i.e., need to call the new operator).
void pop_back(); This member function deletes the last number from the array, and the last number from the linked list. Note that this function will require memory deallocation, i,e., need to call the delete operator.
an overloaded put operator (<<) to print out all the data items stored on the dynamic array and the linked list. Note that you are recommended to overload this operator as a friend function of your ADT.
Make sure you test all these above functions in the main() function. Separate compilation is required.
Archive your header file and the two .cpp files into one zip file and submit this zip file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
