Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need help creating this program with the following requirements. Thank you! To emphasize that the linked list is not the only way to

Hello, I need help creating this program with the following requirements. Thank you! image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
To emphasize that the linked list is not the only way to implement the List ADT, implement an ArrayList class with some of the same functions as the List class provided in the repository. However, this time you must use an array to store the items, instead of a linked IIst Also, the list items will be strings, not integers. NOTE Don't use std:ivector or stduarray. I want you to use a C-style array so that you have to do everything yourself NOTE. The array must store string objects, not pointers to string objects. To use an array for storage, you must dynamically allocate the array, because the maximum size is not known when the list is created. Start with an array size of 4 . (Why so smal? Makes it easien for us to test.) If more than three items are added, you must allocate a new, larger atry and copy the existing items into that array. (Just increase the size by 4 - you could double it but this could be wasteful for large arays) Your Arraylist class must include the following - Public defautt constructor that createn an empty list. - Public copy constructor that creates a copy of another list. - Public destructor that deletes all the items in the list. - Public member functions: bool enpty() - returns true if list is empty, false otherwise (NOTE: this is a const function). int size() - returns the number of items in the list (NOTE this is a const function) void push_back(const std: :strings) - adds a copy of the string to the end of the list (no return value) void push_front(const std: istringg) - adds a copy of the string to the head of the list (no return value) bool pop_front(stdi:strings) - temoves the first item of the last and atores it into the reference passed in, returns true if. item is removed, false if list was empty. bool pop_back(std:: strings) - removes thelast item of the list and stores it into the reference passed ind roturns true if item is removed, false is list was empty NotE This data structure is also known as a Deque (pronounced 'deck') or double-ended queve, because you can insert/remove from both the head and the tail. Some implementation hints: - Devise a way to keep track of how many valid items are in the array. in other words, if the array size is 4 , but there are only two strings in the list, how can you tell? (There is no "special" way to denote an empty string. A string with zero characters is still a string, and is a valid data hem) - The array must grow whenever too many strings are added, but does the size of the array ever shrink? Should it? - The head of thelist does not need to be stored at index 0 , and the tal does not need to be stored at index size-1. When you remove the head, you donit HAVE to move the array elements around. (But you can, if you want lo.) Consider using a circulat buifier This would avoid growing the array if you do a bunch of pushes and pops without having a lot of items in the list at any given time. - Try to make your code etficient. Think about when you should or should not move array elements around, or when you should or should not increase the size of the array. Your grade wont depend on efficiency, but its good to be thinking about theye issues. implement the class in two fises named ArrayList.h and ArrayList.cpp in the lib directory the main cpp file is irrelevant and will not be used in the testing You should write you own main() function to tert your ArcayList implementation. You have to upload main cpp to enoble grading, but as long as it comples, the content of that file doesn't matter. \#include "ArrayList.h" int main() I / I main function does nothing return 0; )

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

Step: 3

blur-text-image

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

What is a job cost sheet?

Answered: 1 week ago

Question

List some problems associated with risk tolerance questionnaires.

Answered: 1 week ago

Question

explain the concept of strategy formulation

Answered: 1 week ago